Advanced features¶
Getting values of all parameters¶
All parameter values can be injected to the function
call using a special AllParameters
type.
If a parameter has this annotation,
a dictionary containing all parameters will
be passed as the parameter value. The AllParameters
class supports additional string argument specifying the path
to the configuration. We show the usage in the following example:
@dataclass
class Model:
learning_rate: float = 1e-4
num_features: int = 5
@aclick.command()
def train(config: aclick.AllParameters, model: Model, num_epochs: int = 1):
import json
print(json.dumps(config))
We get the following output:
$ python train.py --model-num-features 3
{"num_epochs": 1, "model": {"learning_rate": 0.0001, "num_features": 3}}
We can also specify the config path as follows:
@aclick.command()
def train(config: aclick.AllParameters["model"], model: Model, num_epochs: int = 1):
import json
print(json.dumps(config))
With the following output:
$ python train.py --model-num-features 3
{"learning_rate": 0.0001, "num_features": 3}