Skip to content

Commit

Permalink
ci issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aradhakrishnanGFDL committed Jul 30, 2024
1 parent 95fffac commit 865065a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion catalogbuilder/scripts/configs/config-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ output_file_template: ['realm','time_range','variable_id']
#######################################################

input_path: "archive/am5/am5/am5f3b1r0/c96L65_am5f3b1r0_pdclim1850F/gfdl.ncrc5-deploy-prod-openmp/pp"
output_path: "/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog" # ENTER NAME OF THE CSV AND JSON, THE SUFFIX ALONE. e.g catalog (the builder then generates catalog.csv and catalog.json. This can also be an absolute path)
output_path: "sample-mdtf-catalog"
#output_path: "/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog" # ENTER NAME OF THE CSV AND JSON, THE SUFFIX ALONE. e.g catalog (the builder then generates catalog.csv and catalog.json. This can also be an absolute path)
3 changes: 1 addition & 2 deletions catalogbuilder/scripts/gen_intake_gfdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def create_catalog(input_path=None, output_path=None, config=None, filter_realm=
#if(df['variable_id'].eq(k)).any():
df['standard_name'].loc[(df['variable_id'] == k)] = v
#df['standard_name'] = v

if(slow == False) & ('standard_name' in headers):
if ((df is not None) & (len(df) != 0) ):
with open(csv_path, 'w') as csvfile:
Expand All @@ -110,7 +109,7 @@ def create_catalog(input_path=None, output_path=None, config=None, filter_realm=
print("JSON generated at:", os.path.abspath(json_path))
print("CSV generated at:", os.path.abspath(csv_path))
logger.info("CSV generated at" + os.path.abspath(csv_path))
return(os.path.abspath(csv_path),os.path.abspath(json_path))
return(csv_path,json_path)

#Setting up argument parsing/flags
@click.command()
Expand Down
3 changes: 2 additions & 1 deletion catalogbuilder/scripts/gen_intake_gfdl_runner_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

#This is an example call to run catalog builder using a yaml config file.
package_dir = os.path.dirname(os.path.abspath(__file__))
configyaml = os.path.join(package_dir, '../configs/config-example.yml')
configyaml = os.path.join(package_dir, 'configs/config-example.yml')

def create_catalog_from_config(config=configyaml):
csv, json = gen_intake_gfdl.create_catalog(config=configyaml)
return(csv,json)

11 changes: 7 additions & 4 deletions catalogbuilder/tests/make_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@
import os
from pathlib import Path

realm_mapping = [realm]
root_dir = 'archive/am5/am5/am5f3b1r0/c96L65_am5f3b1r0_pdclim1850F/gfdl.ncrc5-deploy-prod-openmp/pp'
freq_mapping = [freq]
chunk_freq = '1yr'

def make_sample_data():
# Create directory
try:
import subdirs
except:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import sys
print((os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),"tests")))
sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),"tests"))
import subdirs
from subdirs import *
from subdirs import realm, freq, time,vars
realm_mapping = [realm]
freq_mapping = [freq]

realm_ctr = (len(subdirs.realm))
i = 0
for j in range(0, realm_ctr):
Expand Down
6 changes: 4 additions & 2 deletions catalogbuilder/tests/test_create_catalog.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
def test_create_catalog():
from pathlib import Path
import catalogbuilder
from catalogbuilder.scripts import gen_intake_gfdl_runner_config
from catalogbuilder.tests import make_sample_data
make_sample_data.make_sample_data()
json, csv = gen_intake_gfdl_runner_config.create_catalog_from_config()
#to output success/failure in pytest run with conda pkg local install in extra-tests CI workflow#
csv = "/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog.csv"
json = "/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog.json"
csv = "/home/a1r/git/forkCatalogBuilder-/catalogbuilder/sample-mdtf-catalog.csv" # "/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog.csv"
json = "/home/a1r/git/forkCatalogBuilder-/catalogbuilder/sample-mdtf-catalog.json" #"/home/runner/work/forkCatalogBuilder-/sample-mdtf-catalog.json"
print(csv)
csvpath = Path(csv)
jsonpath = Path(json)
assert csvpath.is_file()
Expand Down

0 comments on commit 865065a

Please sign in to comment.