Skip to content

Commit 561bedf

Browse files
committedOct 28, 2024
Add docs for netcdf validation
1 parent e507302 commit 561bedf

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
 

‎DiveDB/services/data_uploader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def _write_event_to_duckpond(
235235
del batch_table
236236
gc.collect()
237237

238-
def _validate_netcdf(self, ds: xr.Dataset):
238+
def validate_netcdf(self, ds: xr.Dataset):
239239
"""
240240
Validates netCDF file before upload.
241241

‎README.md

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ For any files to be uploaded to the data lake, they must be in netCDF format and
116116
Requires a labeling dimension.
117117
Attribute: variables with the variables' names (duplicates the dimension).
118118

119+
**Validation:**
120+
- We have a validation function in `DataUploader.validate_netcdf` that checks if a netCDF file meets the above requirements and provides helpful error messages if not. See [validate_netcdf in data_uploader.py](DiveDB/services/data_uploader.py).
121+
119122
**Example:**
120123
- A sample netCDF file is included in the repository: `oror-002_2024-01-16.nc` that meets the above requirements and can be used as a template for your own data.
121124

‎tests/services/test_data_uploader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def valid_netcdf_dataset():
3535
def test_validate_data_valid(valid_netcdf_dataset):
3636
uploader = DataUploader()
3737
ds = valid_netcdf_dataset
38-
assert uploader._validate_netcdf(ds)
38+
assert uploader.validate_netcdf(ds)
3939

4040

4141
def test_validate_data_invalid(valid_netcdf_dataset):
@@ -44,4 +44,4 @@ def test_validate_data_invalid(valid_netcdf_dataset):
4444
ds = ds.rename({"sensor_samples": "sensor"})
4545

4646
with pytest.raises(NetCDFValidationError):
47-
uploader._validate_netcdf(ds)
47+
uploader.validate_netcdf(ds)

0 commit comments

Comments
 (0)
Please sign in to comment.