feat(config): produce annotated config.toml during legacy migration (FXC-3298) #2929
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Legacy migrations now materialize a fully annotated
config.tomlthrough the config manager instead of copying the flat file. Saved configs drop redundant section header comments while keeping inline field notes. Added coverage ensures the migration helper and CLI path output the structured TOML and preserved spacing.Greptile Overview
Updated On: 2025-10-27 08:45:28 UTC
Greptile Summary
Changes the legacy migration process to output a fully annotated, structured
config.tomlfile instead of copying the flat legacy config file. This produces a TOML file with all default sections and field-level comments, improving documentation and user experience. Also fixes config source override order so runtime changes now correctly take precedence over environment variables.Major changes:
finalize_legacy_migration()function that loads legacy config data, creates aConfigManager, updates sections with legacy values, and saves to structured TOML format with all defaultsmigrate_legacy_config()to callfinalize_legacy_migration()after copying the directory treeConfigManager._reload()so runtime overrides apply after environment variablesEnvAPI usageConfidence Score: 5/5
Important Files Changed
File Analysis
finalize_legacy_migrationfunction to promote legacy flat config files into structured TOML format with proper defaults and error handling. Also added deprecation warnings forEnvusage.finalize_legacy_migrationduring migration to ensure legacy config is promoted to structured format after directory copy.Sequence Diagram
sequenceDiagram participant CLI as CLI (tidy3d config migrate) participant Loader as migrate_legacy_config participant Copytree as shutil.copytree participant Finalize as finalize_legacy_migration participant Legacy as load_legacy_flat_config participant Manager as ConfigManager participant Serializer as serializer.build_document CLI->>Loader: migrate_legacy_config() Loader->>Copytree: Copy ~/.tidy3d to canonical dir Copytree-->>Loader: Files copied Loader->>Finalize: finalize_legacy_migration(canonical_dir) Finalize->>Legacy: load_legacy_flat_config(config_dir) Legacy-->>Finalize: legacy config data dict Finalize->>Manager: ConfigManager(config_dir) Finalize->>Manager: update_section with legacy values Finalize->>Manager: save(include_defaults=True) Manager->>Serializer: build_document with defaults Serializer-->>Manager: Annotated TOML with blank line separators Manager-->>Finalize: config.toml saved Finalize->>Finalize: Delete legacy flat config file Finalize-->>Loader: Migration finalized Loader-->>CLI: canonical_dir path