pip install minihydra-leviathan
# run.py
from minihydra import just_args
args = just_args()
print(args, '\n')
print(args.hello)
print(args.number)
print(args.goodbye.cruel)
> python run.py hello=world number=42 goodbye.cruel='[world]'
{'hello': 'world', 'number': 42, {'goodbye': {'cruel': ['world']}}}
world
42
[world]
# path/to/args.yaml
hello: world
number: 42
goodbye:
cruel:
- world
# run.py
from minihydra import just_args
args = just_args(source='path/to/args.yaml')
print(args, '\n')
print(args.hello)
print(args.number)
print(args.goodbye.cruel)
> python run.py number=43
{'hello': 'world', 'number': 43, {'goodbye': {'cruel': ['world']}}}
world
43
[world]
# run.py
from minihydra import get_args
@get_args(source='path/to/args.yaml')
def main(args):
print(args)
if __name__ == '__main__':
main()
> python run.py
{'hello': 'world', 'number': 42, {'goodbye': {'cruel': ['world']}}}
Further features include literals, function calls, instantiation, imports, interpolation, custom grammars, expanding module and yaml search paths, project directory inference, instantiation tinkering-syntax inference, portals, and pseudonyms.
For deeper documentation, please consider sponsoring.