From 67bea3c1d843731222b569b78c5deb3f5bd3363d Mon Sep 17 00:00:00 2001 From: Jordan Laser Date: Mon, 30 Sep 2024 14:25:32 -0600 Subject: [PATCH] fix naming --- forcingprocessor/src/forcingprocessor/processor.py | 8 ++++---- forcingprocessor/src/forcingprocessor/utils.py | 7 +------ forcingprocessor/tests/test_hf2ds.py | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/forcingprocessor/src/forcingprocessor/processor.py b/forcingprocessor/src/forcingprocessor/processor.py index 059092fd..c6f7826a 100644 --- a/forcingprocessor/src/forcingprocessor/processor.py +++ b/forcingprocessor/src/forcingprocessor/processor.py @@ -931,9 +931,9 @@ def prep_ngen_data(conf): metadata_df = pd.DataFrame.from_dict(metadata) if storage_type == 's3': - bucket, key = convert_url2key(output_path,forcing_path) + bucket, key = convert_url2key(output_path,storage_type) - meta_path = f"{key}/metadata/forcings_metadata/" + meta_path = f"{key}metadata/forcings_metadata/" buf = BytesIO() if "parquet" in output_file_type: filename = f"metadata.parquet" @@ -994,8 +994,8 @@ def prep_ngen_data(conf): log_time("TAR_END", log_file) if storage_type == "s3": - bucket, key = convert_url2key(metaf_path,forcing_path) - log_path = key + '/profile_fp.txt' + bucket, key = convert_url2key(metaf_path,storage_type) + log_path = key + 'profile_fp.txt' s3.upload_file( f'./profile_fp.txt', bucket, diff --git a/forcingprocessor/src/forcingprocessor/utils.py b/forcingprocessor/src/forcingprocessor/utils.py index 6db44446..ddd50fe2 100644 --- a/forcingprocessor/src/forcingprocessor/utils.py +++ b/forcingprocessor/src/forcingprocessor/utils.py @@ -69,12 +69,7 @@ def convert_url2key(nwm_file,fs_type): _nc_file_parts = nwm_file.split('/') layers = _nc_file_parts[3:] for jlay in layers: - bucket_key += "/" + jlay + bucket_key += jlay + "/" - if fs_type == 's3': - bucket_key = _nc_file_parts[2][:-17] + bucket_key - elif fs_type == 'google': - bucket_key = "gs:/" + bucket_key - if "s3://" in nwm_file: bucket_key = bucket_key[1:] bucket = _nc_file_parts[2] return bucket, bucket_key \ No newline at end of file diff --git a/forcingprocessor/tests/test_hf2ds.py b/forcingprocessor/tests/test_hf2ds.py index 5ee38048..3e27630b 100644 --- a/forcingprocessor/tests/test_hf2ds.py +++ b/forcingprocessor/tests/test_hf2ds.py @@ -1,7 +1,6 @@ from forcingprocessor.weights_hf2ds import hf2ds from pathlib import Path import os -import pandas as pd HF_VERSION="v2.1.1" test_dir = Path(__file__).parent