Import YAML configs into Arguments for Python
Project description
bibiflags is a python tool to import YAML configs into Arguments for Python .
It provides 2 ways to use it:
- Parse all Arguments from YAML: see example .
- Merge Arguments form YAML and existing argparse.ArgumentParser: see example .
Getting Started
Requirements and Installation
- Python version >= 3.8
- libaries:
- "PyYAML>=6.0.1"
- "OmegaConf>=2.3.0"
- "loguru>=0.7.2"
pip install bibiflags
Install from source via:
pip install git+https://github.com/bibiparrot/bibiflags.git
Or clone the repository and install with the following commands:
git clone git@github.com:bibiparrot/bibiflags.git
cd bibiflags
pip install -e .
Usage
Parse all Arguments from YAML
from pathlib import Path
from pprint import pformat
from loguru import logger
from bibiflags.bibiflags import BibiFlags
if __name__ == '__main__':
flags = BibiFlags(root=str(Path(__file__).parent))
logger.info(pformat(flags.parameters))
Merge Arguments form YAML and existing argparse.ArgumentParser
from pathlib import Path
from pprint import pformat, pprint
from loguru import logger
from bibiflags.bibiflags import BibiFlags
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("echo")
flags = BibiFlags(argparser=parser,
root=str(Path(__file__).parent),
app_name='main')
pprint(flags.parameters)
Changelog
Version 0.1.0 2024-4-10
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bibiflags-0.1.1.tar.gz
(44.3 kB
view hashes)
Built Distribution
Close
Hashes for bibiflags-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67fa8563b868e12ebea9191c2eaf357f3350753ea9df68a5520808103ae8e4e8 |
|
MD5 | aec8f5af03214f1525eb3c62e224be91 |
|
BLAKE2b-256 | e2dee264c8abdc6e02926e37b7600d02322d69f77f24408f434cf30a7f5ddf1f |