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

update_metadata cannot handle invalid blank attributes #52

Open
corviday opened this issue Dec 21, 2018 · 0 comments
Open

update_metadata cannot handle invalid blank attributes #52

corviday opened this issue Dec 21, 2018 · 0 comments
Labels

Comments

@corviday
Copy link
Contributor

corviday commented Dec 21, 2018

I'm not sure if fixing this issue is actually possible.

I attempted to use the update_metadata script to remove an invalid global attribute from some netCDF files. Specifically, some files had a blank string for global: history, which results in all sorts of weird errors.

I wasn't able to remove the invalid attribute with update metadata, and got this traceback:

2018-12-20 16:17:39 INFO: Processing file: /storage/data/climate/downscale/BCCAQ2/bccaqv2_with_metadata/tasmin_day_BCCAQv2+ANUSPLIN300_BNU-ESM_historical+rcp45_r1i1p1_19500101-21001231.nc
2018-12-20 16:17:39 INFO: Global attributes:
Traceback (most recent call last):
  File "climate-explorer-data-prep/scripts/update_metadata", line 31, in <module>
    main(args)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 247, in main
    process_updates(dataset, updates)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 227, in process_updates
    apply_attribute_updates(dataset, target, update)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 202, in apply_attribute_updates
    apply_attribute_updates(dataset, target, element)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 196, in apply_attribute_updates
    modify_attribute(dataset, target, *attr_updates)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 181, in modify_attribute
    return delete_attribute(target, name)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/dp/update_metadata.py", line 145, in delete_attribute
    if hasattr(target, name):
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/nchelpers/decorators.py", line 26, in wrapper
    res = func(*args, **kwargs)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/nchelpers/__init__.py", line 353, in __getattribute__
    is_indirected, indirected_property = _indirection_info(value)
  File "/local_temp/lzeman/climate-explorer-data-prep/venv/lib64/python3.4/site-packages/nchelpers/__init__.py", line 148, in _indirection_info
    if isinstance(value, six.string_types) and value[0] == '@':
IndexError: string index out of range

As a workaround, I first set the attribute to a valid string with update_metadata. Then I ran update_metadata a second time to delete the attribute.

Not a very high priority, since there is a workaround.

@corviday corviday added the bug label May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant