From 5f3956ffe80e686dd3df54ee8cef9ff56c158e76 Mon Sep 17 00:00:00 2001 From: Tom Nicholas Date: Thu, 24 Oct 2024 16:10:12 -0600 Subject: [PATCH] Warning about repo being archived (#344) * add DeprecationWarning on import * big wrarning in README * add big fat warning to docs landing page too * try adding prolog to every page * rearrange emojis * try updating micromamba action * also update micromamba for other job * fix expected repr diff * pin xarray * pin to earlier version * upgrade the python version for docs * require a more recent version of `sphinx` * replace `sphinx-panels` with `sphinx-design` * disable the mypy hook * autoupdate hook versions * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ignore `flake8` errors that conflict with `black` * update link in warning to release discussion upstream * update links --------- Co-authored-by: Justus Magin Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .flake8 | 2 ++ .github/workflows/main.yaml | 8 +++---- .pre-commit-config.yaml | 36 +++++++++++++++---------------- README.md | 12 +++++++---- ci/doc.yml | 8 +++---- ci/environment.yml | 2 +- datatree/__init__.py | 10 +++++++++ datatree/datatree.py | 3 +-- datatree/formatting_html.py | 8 ++++--- datatree/iterators.py | 3 +-- datatree/tests/test_datatree.py | 6 ++---- datatree/tests/test_formatting.py | 6 +++--- docs/source/conf.py | 5 +++++ docs/source/index.rst | 12 +++++++++++ pyproject.toml | 2 +- 15 files changed, 77 insertions(+), 46 deletions(-) diff --git a/.flake8 b/.flake8 index f1e3f927..d7bdd345 100644 --- a/.flake8 +++ b/.flake8 @@ -10,6 +10,8 @@ ignore = E731 # line break before binary operator W503 + E701 + E704 exclude= .eggs doc diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 37034fc5..ab2f585c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -25,12 +25,12 @@ jobs: - uses: actions/checkout@v4 - name: Create conda environment - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: cache-downloads: true micromamba-version: 'latest' environment-file: ci/environment.yml - extra-specs: | + create-args: >- python=${{ matrix.python-version }} - name: Conda info @@ -70,12 +70,12 @@ jobs: - uses: actions/checkout@v4 - name: Create conda environment - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v1 with: cache-downloads: true micromamba-version: 'latest' environment-file: ci/environment.yml - extra-specs: | + create-args: >- python=${{ matrix.python-version }} - name: Conda info diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ea73c38d..15e9a8d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: isort # https://github.com/python/black#version-control-integration - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/keewis/blackdoc @@ -23,7 +23,7 @@ repos: hooks: - id: blackdoc - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.1.1 hooks: - id: flake8 # - repo: https://github.com/Carreau/velin @@ -31,22 +31,22 @@ repos: # hooks: # - id: velin # args: ["--write", "--compact"] - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.8.0 - hooks: - - id: mypy - # Copied from setup.cfg - exclude: "properties|asv_bench|docs" - additional_dependencies: [ - # Type stubs - types-python-dateutil, - types-pkg_resources, - types-PyYAML, - types-pytz, - # Dependencies that are typed - numpy, - typing-extensions>=4.1.0, - ] + # - repo: https://github.com/pre-commit/mirrors-mypy + # rev: v1.13.0 + # hooks: + # - id: mypy + # # Copied from setup.cfg + # exclude: "properties|asv_bench|docs" + # additional_dependencies: [ + # # Type stubs + # types-python-dateutil, + # types-pkg_resources, + # types-PyYAML, + # types-pytz, + # # Dependencies that are typed + # numpy, + # typing-extensions>=4.1.0, + # ] # run this occasionally, ref discussion https://github.com/pydata/xarray/pull/3194 # - repo: https://github.com/asottile/pyupgrade # rev: v1.22.1 diff --git a/README.md b/README.md index 43d73a1d..7fd9cc62 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,17 @@ that was more flexible than a single `xarray.Dataset` object. The initial motivation was to represent netCDF files / Zarr stores with multiple nested groups in a single in-memory object, but `datatree.DataTree` objects have many other uses. -### DEPRECATION NOTICE +# :rotating_light: :bell: :warning: NO LONGER MAINTAINED :warning: :bell: :rotating_light: -Datatree is in the process of being merged upstream into xarray (as of [v0.0.14](https://github.com/xarray-contrib/datatree/releases/tag/v0.0.14), see xarray issue [#8572](https://github.com/pydata/xarray/issues/8572)). We are aiming to preserve the record of contributions to this repository during the migration process. However whilst we will hapily accept new PRs to this repository, this repo will be deprecated and any PRs since [v0.0.14](https://github.com/xarray-contrib/datatree/releases/tag/v0.0.14) might be later copied across to xarray without full git attribution. +**This repository has been archived and the code is no longer maintained!** -Hopefully for users the disruption will be minimal - and just mean that in some future version of xarray you only need to do `from xarray import DataTree` rather than `from datatree import DataTree`. Once the migration is complete this repository will be archived. +Datatree has been [merged upstream into `pydata/xarray`](https://github.com/pydata/xarray/issues/8572), and released as of xarray version `2024.10.0`. -PLEASE RAISE NEW ISSUES ON THE XARRAY REPOSITORY UPSTREAM +There will be no further bugfixes or feature additions to this respository. + +Users of this repository should migrate to using `xarray.DataTree` instead, following the [Migration Guide](https://github.com/pydata/xarray/discussions/9680). + +The information below is all outdated, and is left only for historical interest. ### Installation You can install datatree via pip: diff --git a/ci/doc.yml b/ci/doc.yml index f3b95f71..0978d95d 100644 --- a/ci/doc.yml +++ b/ci/doc.yml @@ -3,12 +3,12 @@ channels: - conda-forge dependencies: - pip - - python>=3.9 + - python>=3.12 - netcdf4 - scipy - - sphinx>=4.2.0 + - sphinx>=6.0.0 - sphinx-copybutton - - sphinx-panels + - sphinx-design - sphinx-autosummary-accessors - sphinx-book-theme >= 0.0.38 - nbsphinx @@ -18,7 +18,7 @@ dependencies: - ipython - h5netcdf - zarr - - xarray + - "xarray>=2022.06.0, <=2024.07.0" - pip: - -e .. - sphinxext-rediraffe diff --git a/ci/environment.yml b/ci/environment.yml index fc0c6d97..0305daf9 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -13,4 +13,4 @@ dependencies: - h5netcdf - zarr - pip: - - xarray>=2022.05.0.dev0 + - "xarray>=2022.06.0, <=2024.07.0" diff --git a/datatree/__init__.py b/datatree/__init__.py index 3b97ea9d..9705f44b 100644 --- a/datatree/__init__.py +++ b/datatree/__init__.py @@ -1,3 +1,5 @@ +import warnings + # import public API from .datatree import DataTree from .extensions import register_datatree_accessor @@ -5,6 +7,14 @@ from .mapping import TreeIsomorphismError, map_over_subtree from .treenode import InvalidTreeError, NotFoundInTreeError +warnings.warn( + "The repository `xarray-contrib/datatree` has been archived! It is no longer maintained as of October 2024. " + "Datatree functionality has been migrated upstream to `pydata/xarray`, so please use `xarray.DataTree` instead. " + "To help you migrate a guide can be found by following https://github.com/pydata/xarray/discussions/9680", + DeprecationWarning, +) + + try: # NOTE: the `_version.py` file must not be present in the git repository # as it is generated by setuptools at install time diff --git a/datatree/datatree.py b/datatree/datatree.py index c86c2e2e..b29a3da5 100644 --- a/datatree/datatree.py +++ b/datatree/datatree.py @@ -177,8 +177,7 @@ def __getitem__(self, key: Hashable) -> DataArray: # type: ignore[misc] ... @overload - def __getitem__(self, key: Any) -> Dataset: - ... + def __getitem__(self, key: Any) -> Dataset: ... def __getitem__(self, key) -> DataArray: # TODO call the `_get_item` method of DataTree to allow path-like access to contents of other nodes diff --git a/datatree/formatting_html.py b/datatree/formatting_html.py index 4531f5ae..bebfa27c 100644 --- a/datatree/formatting_html.py +++ b/datatree/formatting_html.py @@ -22,9 +22,11 @@ def summarize_children(children: Mapping[str, Any]) -> str: lines_callback = lambda n, c, end: _wrap_repr(node_repr(n, c), end=end) children_html = "".join( - lines_callback(n, c, end=False) # Long lines - if i < N_CHILDREN - else lines_callback(n, c, end=True) # Short lines + ( + lines_callback(n, c, end=False) # Long lines + if i < N_CHILDREN + else lines_callback(n, c, end=True) + ) # Short lines for i, (n, c) in enumerate(children.items()) ) diff --git a/datatree/iterators.py b/datatree/iterators.py index 52ed8d22..a13dba95 100644 --- a/datatree/iterators.py +++ b/datatree/iterators.py @@ -60,8 +60,7 @@ def __next__(self) -> Iterator[Tree]: @staticmethod @abstractmethod - def _iter(children: List[Tree], filter_, stop, maxlevel) -> Iterator[Tree]: - ... + def _iter(children: List[Tree], filter_, stop, maxlevel) -> Iterator[Tree]: ... @staticmethod def _abort_at_level(level, maxlevel): diff --git a/datatree/tests/test_datatree.py b/datatree/tests/test_datatree.py index e9f373d7..9e6215a7 100644 --- a/datatree/tests/test_datatree.py +++ b/datatree/tests/test_datatree.py @@ -166,8 +166,7 @@ def test_assign_when_already_child_with_variables_name(self): dt.ds = new_ds -class TestGet: - ... +class TestGet: ... class TestGetItem: @@ -450,8 +449,7 @@ def test_setitem_dataarray_replace_existing_node(self): xrt.assert_identical(results.to_dataset(), expected) -class TestDictionaryInterface: - ... +class TestDictionaryInterface: ... class TestTreeFromDict: diff --git a/datatree/tests/test_formatting.py b/datatree/tests/test_formatting.py index 0f64644c..76c6e072 100644 --- a/datatree/tests/test_formatting.py +++ b/datatree/tests/test_formatting.py @@ -108,13 +108,13 @@ def test_diff_node_data(self): Data in nodes at position '/a' do not match: Data variables only on the left object: - v int64 1 + v int64 8B 1 Data in nodes at position '/a/b' do not match: Differing data variables: - L w int64 5 - R w int64 6""" + L w int64 8B 5 + R w int64 8B 6""" ) actual = diff_tree_repr(dt_1, dt_2, "equals") assert actual == expected diff --git a/docs/source/conf.py b/docs/source/conf.py index 8a9224de..b6d2804b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -30,6 +30,11 @@ parent = os.path.dirname(cwd) sys.path.insert(0, parent) +# -- Deprecation Warning banner ----------------------------------------------------- + +rst_prolog = """.. attention:: + This repository has been archived. Please use xarray.DataTree instead. +""" # -- General configuration ----------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index a88a5747..0398863e 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -5,6 +5,18 @@ Datatree **Datatree is a prototype implementation of a tree-like hierarchical data structure for xarray.** +# !!! NO LONGER MAINTAINED !!! + +**This repository has been archived and the code is no longer maintained!** + +Datatree has been `merged upstream into pydata/xarray `_, and released as of xarray version `2024.10.0`. + +There will be no further bugfixes or feature additions to this respository. + +Users of this repository should migrate to using `xarray.DataTree` instead, following the `Migration Guide `_. + +The information below is all outdated, and is left only for historical interest. + Why Datatree? ~~~~~~~~~~~~~ diff --git a/pyproject.toml b/pyproject.toml index 40f7d5a5..90e2c86f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ classifiers = [ ] requires-python = ">=3.9" dependencies = [ - "xarray >=2023.12.0", + "xarray >=2023.12.0, <=2024.07.0", "packaging", ] dynamic = ["version"]