Skip to content

Commit

Permalink
Remove ambiguous **kwargs argument from Experiment.version
Browse files Browse the repository at this point in the history
The signature in Experiment().version() allowed configuration
specifications that are invalid, for instance for the call
`version({"components": {}}, components={})` the later argument
would be ignored.
  • Loading branch information
frthjf committed Aug 31, 2020
1 parent 19c57b4 commit f419b71
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/machinable/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def components(self, node, components=None, resources=None):
multiple=True,
)

def version(self, config=None, **kwargs):
def version(self, config=None):
"""Applies a configuration update
Selected components use the default configuration as specified in the machinable.yaml.
Expand All @@ -325,30 +325,19 @@ def version(self, config=None, **kwargs):
want to apply the version locally, use the version parameter in the local method.
# Arguments
config: Configuration update represented as dictionary
config: Configuration update dictionary
# Examples
```python
import machinable as ml
experiment = ml.Experiment().components('evolution').components('sgd')
from machinable import Experiment
experiment = Experiment().components('evolution').components('sgd')
# use a dictionary to override configuration values
experiment.version({'data': {'shuffle': True}, 'components': {'lr': 0.01}})
# or kwargs
experiment.version(data={'shuffle': True}, components={'lr': 0.01})
# use a specified version of the machinable.yaml
experiment.version(data='~shuffled')
# use a mixin configuration
experiment.version(data='_mnist_')
experiment.version({'data': {'shuffle': True}, 'lr': 0.01})
```
"""
if config is None:
config_version = copy.deepcopy(kwargs)
else:
if isinstance(config, dict):
config_version = copy.deepcopy(config)
else:
config_version = {"components": copy.deepcopy(config)}

# We wrap the version under a components key to allow for future extension where
# overrides are specific to main or sub-components only etc.
config_version = {"components": copy.deepcopy(config)}
self._spec("version", config_version, multiple=True)

return self
Expand Down

0 comments on commit f419b71

Please sign in to comment.