Skip to content

Warn users about the upcoming move to UNC draft v0.2 - #39

Merged
shunt16 merged 4 commits into
mainfrom
unc-v0.2-notice
Oct 27, 2026
Merged

shunt16 merged 4 commits into
mainfrom
unc-v0.2-notice

Conversation

@shunt16

@shunt16 shunt16 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #40.

obsarray writes uncertainty metadata following v0.1 of the UNC specification. Draft v0.2 is a major revision. It has been proposed for inclusion in the CF conventions, is not backwards compatible with v0.1, and will become obsarray's default in a future release. This PR tells users about the change ahead of time, and adds the option that is intended to become the conventions backend selector.

Behaviour

  • UNCConventionsWarning: a subclass of FutureWarning, so Python shows it to end users by default.
    • It's issued once per session, the first time obsarray writes uncertainty metadata: adding an uncertainty variable with ds.unc[...] (tuple or DataArray), or creating one from a template.
    • It's not issued on import, or when reading existing uncertainty information.
    • Its stacklevel is found at runtime, so it points at the user's own code rather than obsarray internals.
  • obsarray.set_options(unc_conventions="v0.1"): works either globally or as a with block. Choosing a version explicitly silences the warning. "v0.1" is the only valid value for now; "v0.2" will be added with the new backend. obsarray.get_options() returns the current settings.
  • New modules: obsarray/options.py and obsarray/conventions.py. The second is intended to grow into the conventions backend system.

Docs

  • A new user guide page, "Upcoming change: UNC specification draft v0.2". It covers:
    • a table of the main attribute changes, linking to the spec's Appendix B;
    • when the warning appears and how to choose the version or filter the warning;
    • guidance for downstream packages: wrap their own metadata writes in with obsarray.set_options(unc_conventions="v0.1"): rather than setting the option globally.
  • A site-wide announcement banner linking to that page.
  • set_options, get_options and UNCConventionsWarning added to the API reference.
  • A notice in the README.

The docs examples already use :okwarning:, so the warning doesn't appear in the rendered examples.

Testing

  • 17 new tests in test_options.py and test_conventions.py. They cover: warning on both creation paths and the templater, once per session, silence under the option (global and block), no warning on read, the warning pointing at the calling code, the message content, and rejection of invalid options and values.
  • The full suite (190 tests), ruff and mypy pass locally.
  • The Sphinx docs build with no new warnings.

Notes for review

  • The banner and the warning both link to the new page on Read the Docs (/en/latest/...), which will return a 404 until this is merged and latest rebuilds.
  • The docs page states that v0.1 support will remain available, selectable with unc_conventions, after v0.2 becomes the default.
  • DSWriter.write doesn't warn, because it only writes out metadata that already exists. The warning fires when that metadata is created.
  • Downstream packages that add uncertainty variables (e.g. eoio) will surface the warning to their users until they adopt the with set_options(...) pattern.

obsarray writes uncertainty metadata following v0.1 of the UNC
specification. Draft v0.2 is being adopted into the CF conventions, is
not backwards compatible with v0.1, and will become obsarray's default
in a future release.

- Add obsarray.set_options / get_options, with an unc_conventions
  option. "v0.1" (current behaviour) is the only valid value for now;
  the option is intended to become the conventions backend selector.
- Add UNCConventionsWarning (a FutureWarning, so shown to end users by
  default). It is issued once per session, the first time obsarray
  writes uncertainty metadata (adding an uncertainty variable via the
  unc accessor or the templater), unless unc_conventions has been set
  explicitly. Reading uncertainty information never warns.
- The warning's stacklevel is found dynamically so it points at the
  first frame outside obsarray, i.e. the user's own code.
- New user guide page covering what changes between v0.1 and draft
  v0.2, when the warning is shown, how to choose the conventions version
  or filter the warning, and guidance for packages built on obsarray
- Site-wide announcement banner linking to it
- Add set_options, get_options and UNCConventionsWarning to the API
  reference
- Note the upcoming change in the README
@shunt16
shunt16 merged commit f6d70a5 into main Oct 27, 2026
4 checks passed
@shunt16
shunt16 deleted the unc-v0.2-notice branch October 28, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn users about upcoming move to UNC draft v0.2

1 participant