Skip to content

Commit

Permalink
fix: support interpolated cli seed
Browse files Browse the repository at this point in the history
  • Loading branch information
percevalw committed Dec 9, 2024
1 parent 4011f20 commit 2baf1c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Support interpolated seed in the config file (as a reminder, the seed is treated specifically by confit to initialize random generators **before** any object is resolved)

## v0.7.2 (2024-11-23)

- Seed the program *BEFORE* the config file is resolved and components have been instantiated, to ensure reproducibility.
Expand Down
6 changes: 5 additions & 1 deletion confit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def command(ctx: Context, config: Optional[List[Path]] = None):
default_seed = model_fields.get("seed")
if default_seed is not None:
default_seed = default_seed.get_default()
seed = config.get(name, {}).get("seed", default_seed)
seed = Config.resolve(
config.get(name, {}).get("seed", default_seed),
registry=registry,
root=config,
)
if seed is not None:
set_seed(seed)
resolved_config = Config(config[name]).resolve(
Expand Down

0 comments on commit 2baf1c6

Please sign in to comment.