From 2dca472460a23c6dedb3f5efd29e9c83ff32dab1 Mon Sep 17 00:00:00 2001 From: Mihai Boldeanu <35964395+mihaiboldeanu@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:23:13 +0200 Subject: [PATCH] Changed fixtures that open file from aws to use local file (#139) * Changed fixtures that open file from aws to use local file * If local files do not exist they are opened from aws --- tests/conftest.py | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index e1d3be9..0742360 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -196,11 +196,19 @@ def ed_ek_60_for_Sv(): bucket = "ncei-wcsd-archive" base_path = "data/raw/Bell_M._Shimada/SH1707/EK60/" filename = "Summer2017-D20170620-T011027.raw" - rawdirpath = base_path + filename - - s3raw_fpath = f"s3://{bucket}/{rawdirpath}" - storage_opts = {"anon": True} - ed = ep.open_raw(s3raw_fpath, sonar_model="EK60", storage_options=storage_opts) # type: ignore + local_path = os.path.join(TEST_DATA_FOLDER, filename) + if os.path.isfile(local_path): + ed = ep.open_raw( + local_path, + sonar_model="EK60", + ) + else: + rawdirpath = base_path + filename + s3raw_fpath = f"s3://{bucket}/{rawdirpath}" + storage_opts = {"anon": True} + ed = ep.open_raw( + s3raw_fpath, + sonar_model="EK60",storage_options=storage_opts) # type: ignore return ed @@ -218,14 +226,22 @@ def enriched_ek60_Sv(ed_ek_60_for_Sv): def ed_ek_80_for_Sv(): base_url = "noaa-wcsd-pds.s3.amazonaws.com/" path = "data/raw/Sally_Ride/SR1611/EK80/" - file_name = "D20161109-T163350.raw" - raw_file_address = base_url + path + file_name - - rf = raw_file_address # Path(raw_file_address) - ed_EK80 = ep.open_raw( - f"https://{rf}", - sonar_model="EK80", - ) + filename = "D20161109-T163350.raw" + + local_path = os.path.join(TEST_DATA_FOLDER, filename) + if os.path.isfile(local_path): + ed_EK80 = ep.open_raw( + local_path, + sonar_model="EK80", + ) + else: + raw_file_address = base_url + path + file_name + rf = raw_file_address # Path(raw_file_address) + ed_EK80 = ep.open_raw( + f"https://{rf}", + sonar_model="EK80", + ) + return ed_EK80