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
File details
Details for the file minihydra_leviathan-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: minihydra_leviathan-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9e5aad3a365601c623ffff8deaae31ed187f7a941d93f777931ff1460a980eb |
|
MD5 | 23f715ff282b0c3938302f046c4c8560 |
|
BLAKE2b-256 | 4159bfe0e278433fc35dcd76b1bb3e722a23d626b527f96b23b9a67114a863d2 |