Skip to content

Optimize TrainProcessService Singleton Pattern Implementation#279

Merged
kevin-mindverse merged 2 commits intodevelopfrom
feature/fixTrainingModelSwitchBug
Apr 25, 2025
Merged

Optimize TrainProcessService Singleton Pattern Implementation#279
kevin-mindverse merged 2 commits intodevelopfrom
feature/fixTrainingModelSwitchBug

Conversation

@kevin-mindverse
Copy link
Copy Markdown
Contributor

@kevin-mindverse kevin-mindverse commented Apr 24, 2025

Changes

TrainProcessService Class Changes

  1. Parameter Validation Enhanced: Modified the TrainProcessService initialization function to require the current_model_name parameter, ensuring it cannot be None, thus guaranteeing a valid model name at all times
  2. Singleton Access Interface: Added the get_instance() class method, providing a unified interface for obtaining the singleton instance, conforming to standard singleton pattern design

Route Layer Adaptation Updates

  1. Invocation Method Update: Updated direct TrainProcessService instance construction calls to use the get_instance() method
  2. Code Format Optimization: Simplified some instance creation code formats for improved readability
  3. Redundant Endpoint Removal: Removed the no-longer-needed "/model_name" GET route

Benefits

  1. Code Consistency: Ensured access consistency through a single interface for obtaining the singleton instance
  2. Enhanced Parameter Validation: Prevents creation of invalid instances without a model name
  3. Clear Structure: Defined clear boundaries for singleton creation and retrieval, better conforming to design pattern standards

Testing Notes

Please test the following scenarios to ensure functionality:

  1. Creating a new TrainProcessService instance with a valid model name
  2. Obtaining an existing instance using get_instance()
  3. Verifying singleton state consistency by calling functions like reset_progress and stop_process

@kevin-mindverse kevin-mindverse changed the base branch from master to develop April 24, 2025 11:17
@kevin-mindverse kevin-mindverse changed the title Feature/fix training model switch bug Optimize TrainProcessService Singleton Pattern Implementation Apr 24, 2025
Copy link
Copy Markdown
Contributor

@kevinaimonster kevinaimonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevin-mindverse kevin-mindverse merged commit 29a17c8 into develop Apr 25, 2025
1 check passed
Cybercricetus pushed a commit to Cybercricetus/Second-Me that referenced this pull request May 29, 2025
…rse#279)

* feature: use uv to setup python environment

* TrainProcessService add singleten method: get_instance
EOMZON pushed a commit to EOMZON/Second-Me that referenced this pull request Feb 1, 2026
…rse#279)

* feature: use uv to setup python environment

* TrainProcessService add singleten method: get_instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants