Last active
October 16, 2020 22:51
-
-
Save pseeth/32d6a63d8b16cae3efc0871b254a8b85 to your computer and use it in GitHub Desktop.
ArgBind demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argbind | |
from typing import List | |
@argbind.bind() | |
def train(epochs : int = 50): | |
"""Run training. | |
Parameters | |
---------- | |
epochs : int, optional | |
Number of epochs, by default 50 | |
""" | |
print('train', epochs) | |
@argbind.bind() | |
def evaluate(save_folder : str = 'folder'): | |
"""Run evaluation. | |
Parameters | |
---------- | |
save_folder : str, optional | |
Where to save, by default '.' | |
""" | |
print('evaluate', save_folder) | |
@argbind.bind() | |
def run(stages : List[str] = ['train', 'evaluate']): | |
"""Run stages. | |
Parameters | |
---------- | |
stages : List[str], optional | |
Which stages to run, by default 'train' | |
""" | |
for stage in stages: | |
stage_fn = globals()[stage] | |
stage_fn() # will do train | |
if __name__ == "__main__": | |
args = argbind.parse_args() | |
with argbind.scope(args): | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Contents of
demo.yml
: