Skip to content

Commit

Permalink
Merge pull request NOAA-GFDL#60 from aradhakrishnanGFDL/59-cli
Browse files Browse the repository at this point in the history
accept input, output and config
  • Loading branch information
ceblanton authored Sep 24, 2024
2 parents c254cbf + 4f032dc commit 4b7ce63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions catalogbuilder/intakebuilder/configparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ def __init__(self, config):
configfile = yaml.safe_load(file)
try:
self.input_path = configfile['input_path']
print("input_path :",self.input_path)
#print("input_path :",self.input_path)
except:
raise KeyError("input_path does not exist in config")
try:
self.output_path = configfile['output_path']
print("output_path :",self.output_path)
#print("output_path :",self.output_path)
except:
raise KeyError("output_path does not exist in config")
try:
Expand Down
15 changes: 8 additions & 7 deletions catalogbuilder/scripts/gen_intake_gfdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ def create_catalog(input_path=None, output_path=None, config=None, filter_realm=
overwrite=False, append=False, slow = False):
configyaml = None
# TODO error catching
#print("input path: ",input_path, " output path: ", output_path)
if input_path is None or output_path is None:
print("No paths given, using yaml configuration")
if (config is not None):
configyaml = configparser.Config(config)
if configyaml.input_path is None or not configyaml.input_path :
sys.exit("Can't find paths, is yaml configured?")

input_path = configyaml.input_path
output_path = configyaml.output_path

if(input_path is None):
input_path = configyaml.input_path
if(output_path is None):
output_path = configyaml.output_path
if((input_path is None) or (output_path is None)):
sys.exit("Missing: input_path or output_path. Pass it in the config yaml or as command-line option")
if config is None or not configyaml.schema:
print("We will use catalog builder catalogbuilder/cats/gfdl_template.json as your json schema")
template_path = os.path.join(package_dir, '../cats/gfdl_template.json')
Expand All @@ -53,6 +53,7 @@ def create_catalog(input_path=None, output_path=None, config=None, filter_realm=
sys.exit("Input path does not exist. Adjust configuration.")
if not os.path.exists(Path(output_path).parent.absolute()):
sys.exit("Output path parent directory does not exist. Adjust configuration.")
print("input path: ",input_path, " output path: ", output_path)
project_dir = input_path
csv_path = "{0}.csv".format(output_path)
json_path = "{0}.json".format(output_path)
Expand Down

0 comments on commit 4b7ce63

Please sign in to comment.