Check attribute content against netCDF's constraints before saving
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
Hướng nghiên cứu
Read the netCDF saver and lib/iris/fileformats/netcdf/_attribute_handlers.py to locate where cube attributes are passed to setncattr; the issue does not name the saver file or a test. Check the existing tests for netCDF attribute saving, then add coverage for unsupported multidimensional values and errors that identify the attribute and variable. Done means invalid content fails before writing with a clear error, while valid attributes still save.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
(posted by Claude Opus)
Raised from @pp-mo's review of the Zarr I/O design spec: https://github.com/SciTools/iris/pull/7292#discussion_r4155016083
The problem
netCDF constrains what an attribute may hold: a scalar, a string, or a one-dimensional array. Iris does not check this before saving. A cube carrying, say, a 2-D array attribute reaches setncattr and fails inside netCDF4 with a message that names neither the attribute nor the cube.
@pp-mo:
For netCDF4 specifically, possible attribute content is further constrained (e.g. only 1-D arrays). We should make explicit checks and raise errors or warnings when saving unsupported content.
What to do
Check before writing, and raise an error naming the attribute, the variable and why the content cannot be stored.
Raise, do not warn-and-stringify. The same review suggested generalising the known-object handlers in lib/iris/fileformats/netcdf/_attribute_handlers.py — STASH codes, cell methods — into "convert anything unrecognised to its string form and emit a warning". @trexfeathers declined that, and the reasoning is worth keeping with the issue:
I confidently see
_attribute_handlersas a special case for things where there is an obvious and understood way to represent something as a string. This does not generalise to everything that might not be storable in the file (e.g. someone assigns an object which has a__str__and__repr__, but neither of which is adequate for reconstructing said object downstream; that would be a very different decision we are making). In Iris we are typically very careful about Cube-to-Cube roundtripping - can I save a Cube to a file then load back a Cube that is the same as the original - and falling back on converting all unsaveable content to a string seems to deviate from that.
The existing handlers convert where the string form is defined and reversible, and implement the reverse direction beside it. str(some_object) has neither property. A warning is also the wrong instrument here: it does not stop the save, so the user gets a file, is told in passing that part of it is now prose, and finds out at load time.
Scope
This is a behaviour change to the netCDF saver, so it is out of scope for the Zarr I/O programme (#6961) — PR 5 of that programme relocates this code without changing it. The Zarr write path already raises for a value it cannot represent, which is the same policy.
- Ngôn ngữ chính
- Python
- Star
- 730
- Fork
- 323
- Merge trung bình
- 3 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SciTools/iris
-
Link Checker ReportCó thể đã có người làm @stephenworsley đã nhận 12 ngày trước. Đang mởBot Type: Bug Type: Documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
SciTools/iris#7368 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
guess_bounds(yearly=True) fails on a single point, monthly=True worksCó thể đã có người làm @pp-mo đã nhận 48 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
SciTools/iris#7311 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Agentic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SciTools/iris
Issue tương tự
-
flaky: test_fire_returns_thread_per_http_entry_on_head waits 5 s per dispatch worker on busy shardsĐang mởstatus/accepted type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/apm#5309 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug vector-store
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
EverMind-AI/Raven#1413 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Tests: parallel pyinstallcheck runs oversubscribe the machine through nested TBB and BLAS poolsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
ACCESS-NRI/containerised-environments-infra#143 ·
Maintainer thường phản hồi trong vòng 2 ngày