Skip to content

Commit

Permalink
Update for http utils used for MRMS
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhamer-noaa committed Nov 1, 2024
1 parent 47bf8d9 commit 7621107
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 15 additions & 0 deletions python/idsse/testing/idsse_common/mrms_response.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /data/3DRefl/MergedReflectivityQC_00.50</title>
</head>
<body>
<h1>Index of /data/3DRefl/MergedReflectivityQC_00.50</h1>
<tr><td><a href="/data/3DRefl/">Parent Directory</a></td><td>&nbsp;</td><td align="right"> - </td></tr>
<tr><td><a href="MRMS_MergedReflectivityQC_00.50.latest.grib2.gz">MRMS_MergedReflectivityQC_00.50_20241030-205640.grib2.gz</a></td><td align="right">31-Oct-2024 14:43 </td><td align="right">381K</td></tr>
<tr><td><a href="MRMS_MergedReflectivityQC_00.50_20241030-205438.grib2.gz">MRMS_MergedReflectivityQC_00.50_20241030-205438.grib2.gz</a></td><td align="right">30-Oct-2024 14:01 </td><td align="right">227K</td></tr>
<tr><td><a href="MRMS_MergedReflectivityQC_00.50_20241030-205640.grib2.gz">MRMS_MergedReflectivityQC_00.50_20241030-205640.grib2.gz</a></td><td align="right">30-Oct-2024 14:03 </td><td align="right">228K</td></tr>
<tr><th colspan="3"><hr></th></tr>
</table>
</body></html>

7 changes: 4 additions & 3 deletions python/idsse/testing/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ def get_resource_from_file(package: str, filename: str) -> dict | Sequence[Seque
_, file_extension = path.splitext(filename)
if file_extension == '.nc':
return _load_netcdf_resource(resources.files(package).joinpath(filename))
print(filename, file_extension)
file_stream = resources.files(package).joinpath(filename).open('r')
if file_extension == '.json':
return _load_json_resource(file_stream)
if file_extension == '.csv':
return _load_csv_resource(file_stream)
if file_extension == '.html':
return _load_html_resource(file_stream)
raise ValueError(f'Unable to load test data from unsupported extension {file_extension}')


Expand All @@ -88,6 +89,6 @@ def _load_csv_resource(stream: TextIO) -> Sequence[Sequence[any]]:
return [list(map(float, row)) for row in file_reader]


def _load_netcdf_resource(filename: str) -> tuple[dict, np.ndarray]:
def _load_html_resource(filestream: TextIO) -> str:
"""utility to load NetCDF file from package"""
return read_netcdf(filename)
return filestream.read()
3 changes: 2 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def package_files(directory):
'idsse.testing.risk_processor.simple',
'idsse.testing.risk_processor.syracuse',
'idsse.testing.utils'],
data_files=[('idsse.testing.data_access.data_cache', package_files('idsse/testing/data_access/data_cache')),
data_files=[('idsse.testing.idsse_common', package_files('idsse/testing/idsse_common/')),
('idsse.testing.data_access.data_cache', package_files('idsse/testing/data_access/data_cache')),
('idsse.testing.data_access.mrms_aws_grib', package_files('idsse/testing/data_access/mrms_aws_grib')),
('idsse.testing.data_access.nbm_aws_grib', package_files('idsse/testing/data_access/nbm_aws_grib')),
('idsse.testing.data_access.validation', package_files('idsse/testing/data_access/validation'))],
Expand Down

0 comments on commit 7621107

Please sign in to comment.