A lightweight sys-arg manager.
Project description
pip install minihydra-leviathan
Reading in args
# 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]
Via yaml
# 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]
As a decorator
# 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']}}}
Advanced
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for minihydra_leviathan-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30445f328d0e5afec470b8f5a0161ec35cd7a522ac3ab82321f92e10246c8c0c |
|
MD5 | 58fa37cdbd9f54b7ea4c33d36ce257bb |
|
BLAKE2b-256 | 25a47c44a1af549c67d1000bcded43d2b63f5340438438fc955209d396796fe6 |