-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from OlofHarrysson/develop
Adds support pre/post parsing of input args
- Loading branch information
Showing
7 changed files
with
147 additions
and
40 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
import anyfig | ||
from pathlib import Path | ||
import jsonpickle | ||
import time | ||
import argparse | ||
|
||
|
||
@anyfig.config_class | ||
class MainConfig(): | ||
@anyfig.config_class # Registers the class with anyfig | ||
class MyConfig(): | ||
def __init__(self): | ||
# YOOYOYOYOO | ||
self.yo = 0 | ||
# asdasd | ||
self.yo = 123 | ||
# Config-parameters goes as attributes | ||
self.experiment_note = 'Changed stuff' | ||
self.save_directory = Path('output') | ||
self.start_time = time.time() | ||
|
||
self.shiiiet = [1, 2, 3] | ||
# self.inner_config = InnerConfig() | ||
|
||
|
||
@anyfig.config_class | ||
class InnerConfig(): | ||
def __init__(self): | ||
self.save_directory = 12 | ||
self.inner_text = "Yo Dawg" | ||
|
||
|
||
# parser = argparse.ArgumentParser() | ||
|
||
def main(): | ||
config = anyfig.init_config(default_config=MainConfig) | ||
print(config) | ||
# parser.add_argument("--start_time", | ||
# type=int, | ||
# help="display a square of a given number") | ||
# dict_args = vars(parser.parse_args()) | ||
# print('known', dict_args) | ||
# print('unknown', unknown) | ||
# args = dict(args) | ||
# print(args) | ||
|
||
import sys | ||
dict_args = sys.argv[1:] | ||
print(dict_args) | ||
dict_args = anyfig.parse_cli_args(dict_args) | ||
print(dict_args) | ||
dict_args.pop('start_time', None) | ||
|
||
if __name__ == '__main__': | ||
main() | ||
config = anyfig.init_config(default_config=MyConfig, cli_args=dict_args) | ||
print(config) |
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
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
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
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
f1f90af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: