Skip to content

Refactor train CLI into core, with CLI and API shims - #39

Open
joanise wants to merge 5 commits into
dev.ej/fs2-prepro-v2from
dev.ej/refactor-train
Open

joanise wants to merge 5 commits into
dev.ej/fs2-prepro-v2from
dev.ej/refactor-train

Conversation

@joanise

@joanise joanise commented Sep 23, 2026

Copy link
Copy Markdown
Member

@roedoejet roedoejet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks good, same vein as the preprocess refactor. I think the model dump needs to be addressed and a couple other minor things. Also, my comment on the preprocess PR about sys.exit also applies here.

Comment thread styletts2/core/train.py Outdated
shutil.copy(config_file_s, os.path.join(log_dir, config_file_s))
# Log the full in-memory config object as really used, including any
# --config-args overrides on the CLI or programmatic changes to config
with open(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we can yaml.dump here because that will miss the pydantic logic we have for exporting functions and paths correctly which is why we use config.model_dump_json() instead of model_dump(). Is there a reason not to use the base_cli.helpers.save_configuration_to_log_dir though? I think it would be good to use that fn across all train commands for all models.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hum, yeah, that's probably going to be a problem, you're right. train_base_command uses save_configuration_to_log_dir, so I think all other submodules use that.

As long as that function works for StyleTTS2 as well, then yes, it's the right thing to call here.

Comment thread styletts2/core/train.py Outdated
os.makedirs(log_dir, exist_ok=True)
if config_file is not None:
config_file_s = str(config_file)
shutil.copy(config_file_s, os.path.join(log_dir, config_file_s))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, shouldn't this be os.path.join(log_dir, Path(config_file).name) or something similar? The old code was:

shutil.copy(str(config_file), os.path.join(log_dir, config_file.name))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, good catch.

@joanise
joanise force-pushed the dev.ej/refactor-train branch from 16c1a28 to cea050d Compare October 28, 2026 19:07
joanise and others added 5 commits November 4, 2026 16:06
As I prepare the refactor cli.train to core.train with cli and api
shims in every submodule, I also want to bring StyleTTS2 a little closer
to our standard where that makes sense.
@joanise
joanise force-pushed the dev.ej/refactor-train branch 2 times, most recently from 4c5c321 to b344bce Compare November 6, 2026 20:13
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.

2 participants