Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment config_hook does not change ingredient's config #936

Open
cmditch opened this issue Nov 13, 2024 · 0 comments
Open

Experiment config_hook does not change ingredient's config #936

cmditch opened this issue Nov 13, 2024 · 0 comments

Comments

@cmditch
Copy link

cmditch commented Nov 13, 2024

It seems that any ingredient level changes within an experiment's config hook do not actually alter the ingredient's config. It seems they are being overwritten right about here.

Code to reproduce the issue:

import sacred

feats = sacred.Ingredient("feats")
feats.add_config({"name": "feats"})

ex = sacred.Experiment("coury_sacred_test", ingredients=[feats])
ex.add_config({"name": "experiment"})


@ex.config_hook
def ex_config_hook(config, command_name, logger):
    config["feats"]["name"] = "feats_changed"
    print("Config hook changes:", config)
    return config


@ex.automain
def main(_run):
    print(_run.config)

Output:

> python scratch_sacred_config_hook_debug.py print_config

Config hook changes: {'name': 'experiment', 'feats': {'name': 'feats_changed'}}
INFO - coury_sacred_test - Running command 'print_config'
INFO - coury_sacred_test - Started
Configuration (modified, added, typechanged, doc):
  name = 'experiment'
  seed = 149828750
  feats:
    name = 'feats'
INFO - coury_sacred_test - Completed after 0:00:00
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

No branches or pull requests

1 participant