Skip to content

Commit 9b890d9

Browse files
committed
updated readme
1 parent eb1202d commit 9b890d9

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ For more detailed information on available command-line arguments and usage exam
4343

4444
PyArgWriter depends strongly on information stated in the docstring. Your docstring should have a minimal structure like:
4545

46-
```python
46+
```python
4747
def add(a: int, b: int) -> int:
4848
"""_summary_
4949
@@ -118,6 +118,31 @@ In the function of the process class you want to create the argument parser, fol
118118
python -m pyargwriter generate-argparser --input examples/shopping.py examples/car.py --output examples --pretty
119119
```
120120

121+
## Hydra Integration
122+
123+
As an additional feature we support to combine your existing `ArgumentParser` with the [Hydra](https://hydra.cc/docs/intro/) framework. All you need to do is to use a decorator we provide with our framework. A short example can be viewed below.
124+
125+
```python
126+
from omegaconf import DictConfig
127+
from pyargwriter.decorator import add_hydra
128+
129+
class Entrypoint:
130+
"""ML training pipeline"""
131+
def __init__(self):
132+
"""initiate pipeline"""
133+
pass
134+
@add_hydra("config", version_base=None)
135+
def train(config: DictConfig, device: str):
136+
"""start training process
137+
138+
Args:
139+
config (DictConfig): container which contains
140+
device (str): where to train on
141+
"""
142+
```
143+
The decorator is indeed callable. Additionally to the usual hydra-arguments you have to pass in the `config_var_name` which specifies which argument in the `train` signature is the config object. After calling the pyargwriter tool you are now ready to go with a CLI which can now handle also almost all Hydra commands. Except the normal `help` message you get from Hydra. For further interest in this message please refer to their [website](https://hydra.cc/docs/intro/)
144+
145+
121146
## Documentation
122147

123148
The complete documentation for PyArgWriter, including detailed usage instructions and examples, can be found in the [official documentation](documentation/latex/refman.pdf) or at the [documentation website](https://htmlpreview.github.io/?https://github.com/RobinU434/PyArgWriter/blob/main/documentation/html/index.htm).

0 commit comments

Comments
 (0)