question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update nested config of ingredient

See original GitHub issue

Currently I work with experiments which inject multiple ingredients. Each of the ingredients has its own YAML config file which is loaded via the ingredient.add_config method. For example ingredient.yaml:

...
solver_cfg:
  ada_lr:
    factor: 0.1
    epochs: [] 
...

Now I want to change one of the nested configuration parameters only for one of the experiments. The change should also be in the respective experiment.yaml:

...
update_ingredient:
  solver_cfg:
    ada_lr:
      epochs: [100] 
...

Is there a way to achieve this with the currently available methods? config_hook and option_hook only work on config updates which are implied by the command line. I could put the updates in a separate YAML file and add this to the ingredient only for the experiment but this will overwrite and not update the solver_cfg entry which loses the factor parameter. Am I missing something?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Qwlousecommented, Apr 18, 2018

In the short-term ingredients will remain the same, because I currently don’t have the time for an in-depth refactoring. In the medium term, I would like to make ingredients classes, that you include by instantiating them as part of the configuration process. This would make their usage very flexible and hopefully intuitive. Something along these lines:

class MyDataset(Ingredient):
    def __init__(self, variant="variant1"):
        self.path = "foo/bar/{}".format(variant)
        self.normalize = True

@ex.config
def cfg():
    learn_rate = 0.1
    problem = "A"
    if problem == "A":
        dataset = MyDataset()
    elif problem == "B":
        dataset = MyDataset(variant="variant2")
    else:
        dataset = MyOtherDataset()

Which could result in a config like this:

Configuration:
    learn_rate = 0.1
    problem = "B"
    seed = 1234
    dataset:
        path = "foo/bar/variant2"
        normalize = True
0reactions
Qwlousecommented, May 6, 2018

Closing this issue, since we sort-of solved your problem, and solving it completely probably requires larger changes that deserve their own issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I update the state of an object nested in an array from ...
I do this by creating an empty object in an ingredients array within RecipeCreate, and then iterate over this array of empty objects,...
Read more >
Ingredients — Sacred 0.8.3 documentation
Ingredients are a way of defining a configuration with associated functions and possibly commands that can be reused by many different experiments.
Read more >
Rails: Nested resource scaffold - devroom.io
This makes sure you only show ingredients for this recipe, and not all ingredients in the database. Because we changed the route for...
Read more >
How to UPDATE Nested Object and Table Columns, Part 2
Line 16 use the SUBMULTISET set operator to ensure that only new add elements when they don't already exist in the ingredient ADT...
Read more >
Use a nested dynamic form with a has_many :through association in ...
Use a nested dynamic form with a has_many :through association in Rails. ... Ingredients have a name, an amount, and a description. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found