Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept input, output and config #60

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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