Skip to content

Commit

Permalink
adding some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
beckynevin committed Apr 15, 2024
1 parent 72e5cf4 commit 7c4f5e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,36 @@

from utils.config import Config
from utils.defaults import Defaults
from data import DataModules
from models import ModelModules
from metrics import Metrics
from plots import Plots
from data import DataModules
#from models import ModelModules
#from metrics import Metrics
#from plots import Plots


def parser():
def parser():
parser = ArgumentParser()
parser.add_argument("--config", '-c', default=None)

# Model
# Model
parser.add_argument("--model_path", '-m', default=None)
parser.add_argument("--model_engine", '-e', default=Defaults['model']['model_engine'], choices=ModelModules.keys())
# parser.add_argument("--model_engine", '-e', default=Defaults['model']['model_engine'], choices=ModelModules.keys())

# Data
# Data
parser.add_argument("--data_path", '-d', default=None)
parser.add_argument("--data_engine", '-g', default=Defaults['data']['data_engine'], choices=DataModules.keys())
parser.add_argument("--simulator", '-s', default=None)
parser.add_argument("--data_engine", '-dl', default=Defaults['data']['data_engine'], choices=DataModules.keys())

# Common
parser.add_argument("--out_dir", default=Defaults['common']['out_dir'])

# List of metrics (cannot supply specific kwargs)
parser.add_argument("--metrics", nargs='+', default=list(Defaults['metrics'].keys()), choices=Metrics.keys())
# parser.add_argument("--metrics", nargs='+', default=list(Defaults['metrics'].keys()), choices=Metrics.keys())

# List of plots
parser.add_argument("--plots", nargs='+', default=list(Defaults['plots'].keys()), choices=Plots.keys())
# parser.add_argument("--plots", nargs='+', default=list(Defaults['plots'].keys()), choices=Plots.keys())


args = parser.parse_args()
if args.config is not None:
if args.config is not None:
config = Config(args.config)

else:
Expand All @@ -42,8 +42,8 @@ def parser():

input_yaml = {
"common": {"out_dir":args.out_dir},
"model": {"model_path":args.model_path, "model_engine":args.model_engine},
"data": {"data_path":args.data_path, "data_engine":args.data_engine, "simulator": args.simulator},
#"model": {"model_path":args.model_path, "model_engine":args.model_engine},
"data": {"data_path":args.data_path, "data_engine":args.data_engine},
"plots": {key: {} for key in args.plots},
"metrics": {key: {} for key in args.metrics},
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def get_section(section, raise_exception=True):
class Config:
ENV_VAR_PATH = "DeepDiagnostics_Config"
def __init__(self, config_path:Optional[str]=None) -> None:
# okay what Maggie is doing here is a little trick or "cheat"
# where the config_path is saved to the ENV_VAR_PATH
# the first time this thing is called and then later it
# can be loaded from this temp location saving on memory
if config_path is not None:
# Add it to the env vars in case we need to get it later.
os.environ[self.ENV_VAR_PATH] = config_path
Expand All @@ -39,6 +43,8 @@ def _read_config(self, path):
config = yaml.safe_load(f)
return config

# if raise_exception is True, then throws an error if we're missing
# otherwise, pull value from the defaults.py
def get_item(self, section, item, raise_exception=True):
try:
return self.config[section][item]
Expand Down

0 comments on commit 7c4f5e7

Please sign in to comment.