Skip to content

Commit

Permalink
Changed fixtures that open file from aws to use local file (#139)
Browse files Browse the repository at this point in the history
* Changed fixtures that open file from aws to use local file

* If local files do not exist they are opened from aws
  • Loading branch information
mihaiboldeanu authored Nov 16, 2023
1 parent 4bd87c2 commit 2dca472
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand Down

0 comments on commit 2dca472

Please sign in to comment.