Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't mutate cached data in DatasetInfoPlugin #153

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/test_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ def test_info(airtemp_ds, airtemp_app_client):
assert json_response['dimensions'] == airtemp_ds.dims
assert list(json_response['variables'].keys()) == list(airtemp_ds.variables.keys())

# Second request, to make sure the cached data wasn't changed
response = airtemp_app_client.get('/info')
assert response.status_code == 200
json_response = response.json()
assert json_response['dimensions'] == airtemp_ds.dims
assert list(json_response['variables'].keys()) == list(airtemp_ds.variables.keys())


def test_dict(airtemp_ds, airtemp_app_client):
response = airtemp_app_client.get('/dict')
Expand Down
2 changes: 1 addition & 1 deletion xpublish/plugins/included/dataset_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def info(
meta = zmetadata['metadata']

for name, var in zvariables.items():
attrs = meta[f'{name}/{attrs_key}']
attrs = meta[f'{name}/{attrs_key}'].copy()
attrs.pop('_ARRAY_DIMENSIONS')
info['variables'][name] = {
'type': var.data.dtype.name,
Expand Down