From b04cf7e3143320e0fa4e8c938db1f9541bc4a7ad Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 18 Aug 2023 12:15:33 -0400 Subject: [PATCH 1/6] drop gwcs and pytest-openfiles test deps --- pyproject.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1834068f4..bc71ed4f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,6 @@ tests = [ "psutil", "pytest>=6", "pytest-doctestplus", - "pytest-openfiles", "pytest-remotedata", ] [project.urls] @@ -107,15 +106,13 @@ minversion = 4.6 norecursedirs = ['build', 'docs/_build', 'docs/sphinxext'] doctest_plus = 'enabled' remote_data_strict = true -# The asdf.asdftypes module emits a warning on import, -# which pytest trips over during collection: filterwarnings = [ 'error', 'ignore:numpy.ndarray size changed:RuntimeWarning', ] # Configuration for pytest-doctestplus text_file_format = 'rst' -addopts = '--color=yes --doctest-rst' +addopts = '--color=yes --doctest-rst -rsx' [tool.coverage.run] omit = [ From 22e75deb42e656b1c96e64bddefe6ae4602d03b2 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 18 Aug 2023 12:49:45 -0400 Subject: [PATCH 2/6] remove astropy test dependency --- asdf/_tests/tags/core/tests/test_ndarray.py | 36 ++++++++++++++++-- asdf/_tests/test_api.py | 18 --------- asdf/_tests/test_file_format.py | 2 - asdf/_tests/test_schema.py | 42 +++++++++++++++------ pyproject.toml | 1 - 5 files changed, 64 insertions(+), 35 deletions(-) diff --git a/asdf/_tests/tags/core/tests/test_ndarray.py b/asdf/_tests/tags/core/tests/test_ndarray.py index 45373326f..a25441f32 100644 --- a/asdf/_tests/tags/core/tests/test_ndarray.py +++ b/asdf/_tests/tags/core/tests/test_ndarray.py @@ -241,12 +241,42 @@ def test_table_inline(tmpdir): def test_array_inline_threshold_recursive(tmpdir): - models = pytest.importorskip("astropy.modeling.models") + """ + Test that setting the inline threshold works for objects + that contain (and when serialized produce a ndarray) + """ + + class NDArrayContainer: + def __init__(self, array): + self._array = array + + @property + def array(self): + return np.array(self._array) + + + class NDArrayContainerConverter: + tags = ["http://somewhere.org/tags/foo-1.0.0"] + types = [NDArrayContainer] + + def to_yaml_tree(self, obj, tag, ctx): + return {'array': obj.array} + + def from_yaml_tree(self, node, tag, ctx): + return NDArrayContainer(node['array']) + + + class NDArrayContainerExtension: + tags = NDArrayContainerConverter.tags + converters = [NDArrayContainerConverter()] + extension_uri = "http://somewhere.org/extensions/foo-1.0.0" + - aff = models.AffineTransformation2D(matrix=[[1, 2], [3, 4]]) - tree = {"test": aff} + container = NDArrayContainer([[1, 2], [3, 4]]) + tree = {"test": container} with asdf.config_context() as config: + config.add_extension(NDArrayContainerExtension()) config.array_inline_threshold = 100 # we can no longer use _helpers.assert_roundtrip_tree here because # the model no longer has a CustomType which results in equality testing diff --git a/asdf/_tests/test_api.py b/asdf/_tests/test_api.py index 3d394ce6f..0c5b8a575 100644 --- a/asdf/_tests/test_api.py +++ b/asdf/_tests/test_api.py @@ -7,7 +7,6 @@ import numpy as np import pytest -from astropy.modeling import models from numpy.testing import assert_array_equal import asdf @@ -117,23 +116,6 @@ def test_atomic_write(tmp_path, small_tree): ff.write_to(tmpfile) -def test_overwrite(tmp_path): - """ - This is intended to reproduce the following issue: - https://github.com/asdf-format/asdf/issues/100 - """ - tmpfile = str(tmp_path / "test.asdf") - aff = models.AffineTransformation2D(matrix=[[1, 2], [3, 4]]) - f = asdf.AsdfFile() - f.tree["model"] = aff - f.write_to(tmpfile) - model = f.tree["model"] - - ff = asdf.AsdfFile() - ff.tree["model"] = model - ff.write_to(tmpfile) - - def test_default_version(): """ See https://github.com/asdf-format/asdf/issues/364 diff --git a/asdf/_tests/test_file_format.py b/asdf/_tests/test_file_format.py index 6c9cc593b..6a82671a6 100644 --- a/asdf/_tests/test_file_format.py +++ b/asdf/_tests/test_file_format.py @@ -59,7 +59,6 @@ def test_no_final_newline(tmp_path): assert len(ff.tree) == 2 -@pytest.mark.filterwarnings("ignore::astropy.io.fits.verify.VerifyWarning") def test_no_asdf_header(tmp_path): content = b"What? This ain't no ASDF file" @@ -98,7 +97,6 @@ def test_empty_file(): assert len(ff._blocks.blocks) == 0 -@pytest.mark.filterwarnings("ignore::astropy.io.fits.verify.VerifyWarning") @pytest.mark.filterwarnings("ignore::asdf.exceptions.AsdfDeprecationWarning") def test_not_asdf_file(): buff = io.BytesIO(b"SIMPLE") diff --git a/asdf/_tests/test_schema.py b/asdf/_tests/test_schema.py index 7496d5bbb..f37f95db9 100644 --- a/asdf/_tests/test_schema.py +++ b/asdf/_tests/test_schema.py @@ -64,22 +64,42 @@ class TagReferenceExtension: def test_tagging_scalars(): - pytest.importorskip("astropy", "3.0.0") - from astropy import units as u + class Scalar: + def __init__(self, value): + self.value = value - yaml = """ -unit: !unit/unit-1.0.0 + scalar_tag = 'http://somewhere.org/tags/scalar-1.0.0' + class ScalarConverter: + tags = [scalar_tag] + types = [Scalar] + + def to_yaml_tree(self, obj, tag, ctx): + return obj.value + + def from_yaml_tree(self, node, tag, ctx): + return Scalar(node) + + class ScalarExtension: + tags = [scalar_tag] + converters = [ScalarConverter()] + extension_uri = 'http://somewhere.org/extensions/scalar-1.0.0' + + yaml = f""" +tagged: !<{scalar_tag}> m -not_unit: +not_tagged: m """ - buff = helpers.yaml_to_asdf(yaml) - with asdf.open(buff) as ff: - assert isinstance(ff.tree["unit"], u.UnitBase) - assert not isinstance(ff.tree["not_unit"], u.UnitBase) - assert isinstance(ff.tree["not_unit"], str) + with asdf.config_context() as cfg: + cfg.add_extension(ScalarExtension()) + buff = helpers.yaml_to_asdf(yaml) + with asdf.open(buff) as ff: + assert isinstance(ff.tree["tagged"], Scalar) + assert not isinstance(ff.tree["not_tagged"], Scalar) + assert isinstance(ff.tree["not_tagged"], str) - assert ff.tree == {"unit": u.m, "not_unit": "m"} + assert ff.tree["tagged"].value == "m" + assert ff.tree["not_tagged"] == "m" def test_read_json_schema(): diff --git a/pyproject.toml b/pyproject.toml index bc71ed4f8..19bee6fe4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,6 @@ docs = [ 'tomli; python_version < "3.11"', ] tests = [ - "astropy>=5.0.4", "fsspec[http]>=2022.8.2", "asdf-astropy>=0.4.0", "lz4>=0.10", From 2e186dc03ff799333aeb866ce0208147a6c14bc5 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 18 Aug 2023 12:51:38 -0400 Subject: [PATCH 3/6] clean up requirements-dev --- asdf/_tests/tags/core/tests/test_ndarray.py | 7 ++----- asdf/_tests/test_schema.py | 5 +++-- requirements-dev.txt | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/asdf/_tests/tags/core/tests/test_ndarray.py b/asdf/_tests/tags/core/tests/test_ndarray.py index a25441f32..941c6a125 100644 --- a/asdf/_tests/tags/core/tests/test_ndarray.py +++ b/asdf/_tests/tags/core/tests/test_ndarray.py @@ -254,24 +254,21 @@ def __init__(self, array): def array(self): return np.array(self._array) - class NDArrayContainerConverter: tags = ["http://somewhere.org/tags/foo-1.0.0"] types = [NDArrayContainer] def to_yaml_tree(self, obj, tag, ctx): - return {'array': obj.array} + return {"array": obj.array} def from_yaml_tree(self, node, tag, ctx): - return NDArrayContainer(node['array']) - + return NDArrayContainer(node["array"]) class NDArrayContainerExtension: tags = NDArrayContainerConverter.tags converters = [NDArrayContainerConverter()] extension_uri = "http://somewhere.org/extensions/foo-1.0.0" - container = NDArrayContainer([[1, 2], [3, 4]]) tree = {"test": container} diff --git a/asdf/_tests/test_schema.py b/asdf/_tests/test_schema.py index f37f95db9..82cea9238 100644 --- a/asdf/_tests/test_schema.py +++ b/asdf/_tests/test_schema.py @@ -68,7 +68,8 @@ class Scalar: def __init__(self, value): self.value = value - scalar_tag = 'http://somewhere.org/tags/scalar-1.0.0' + scalar_tag = "http://somewhere.org/tags/scalar-1.0.0" + class ScalarConverter: tags = [scalar_tag] types = [Scalar] @@ -82,7 +83,7 @@ def from_yaml_tree(self, node, tag, ctx): class ScalarExtension: tags = [scalar_tag] converters = [ScalarConverter()] - extension_uri = 'http://somewhere.org/extensions/scalar-1.0.0' + extension_uri = "http://somewhere.org/extensions/scalar-1.0.0" yaml = f""" tagged: !<{scalar_tag}> diff --git a/requirements-dev.txt b/requirements-dev.txt index 82af43cfc..3460c6d90 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,11 +1,12 @@ -git+https://github.com/astropy/asdf-astropy git+https://github.com/asdf-format/asdf-coordinates-schemas git+https://github.com/asdf-format/asdf-standard git+https://github.com/asdf-format/asdf-transform-schemas git+https://github.com/asdf-format/asdf-unit-schemas.git git+https://github.com/asdf-format/asdf-wcs-schemas -git+https://github.com/astropy/astropy #git+https://github.com/yaml/pyyaml.git numpy>=0.0.dev0 +# although we don't use scipy, we include it here so that any dependency +# that uses it during these tests will use the development version +# which is more likely to work with the above development version of numpy scipy>=0.0.dev0 From ec7621cacf2d3a3fc5653d496250e821b232b8b9 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 18 Aug 2023 12:58:38 -0400 Subject: [PATCH 4/6] remove open-files argument in tox.ini --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 42c494872..8ad71e31b 100644 --- a/tox.ini +++ b/tox.ini @@ -46,7 +46,6 @@ commands = --remote-data \ --durations=10 \ jsonschema: --jsonschema \ - coverage: --open-files \ parallel: --numprocesses auto \ # the OpenAstronomy workflow appends `--cov-report` in `{posargs}`, which `coverage` doesn't recognize !coverage: {posargs} From 0ef6544d35c8be539b7630635416475d0407fc04 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 21 Aug 2023 09:24:22 -0400 Subject: [PATCH 5/6] another attempt at 3.12 --- .github/workflows/ci.yml | 2 ++ asdf/_tests/test_asdf.py | 5 ++++- asdf/_tests/test_generic_io.py | 5 ++++- pyproject.toml | 3 +-- requirements-dev.txt | 2 +- tox.ini | 3 ++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 485fc08f5..7de90d9f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,8 @@ jobs: - linux: py39-devdeps-parallel - linux: py310-devdeps-parallel - linux: py311-devdeps-parallel + - linux: py312-devdeps-parallel + python-version: '3.12-dev' oldest: needs: [core, asdf-schemas] diff --git a/asdf/_tests/test_asdf.py b/asdf/_tests/test_asdf.py index d41e2b31a..8584367d8 100644 --- a/asdf/_tests/test_asdf.py +++ b/asdf/_tests/test_asdf.py @@ -1,6 +1,5 @@ import os -import fsspec import pytest from asdf import config_context @@ -361,6 +360,8 @@ def test_fsspec(tmp_path): Issue #1146 reported errors when opening a fsspec 'file' This is a regression test for the fix in PR #1226 """ + fsspec = pytest.importorskip("fsspec") + tree = {"a": 1} af = AsdfFile(tree) fn = tmp_path / "test.asdf" @@ -378,6 +379,8 @@ def test_fsspec_http(httpserver): filesystem) This is a regression test for the fix in PR #1228 """ + fsspec = pytest.importorskip("fsspec") + tree = {"a": 1} af = AsdfFile(tree) path = os.path.join(httpserver.tmpdir, "test") diff --git a/asdf/_tests/test_generic_io.py b/asdf/_tests/test_generic_io.py index fbc8427cc..b92047b00 100644 --- a/asdf/_tests/test_generic_io.py +++ b/asdf/_tests/test_generic_io.py @@ -5,7 +5,6 @@ import sys import urllib.request as urllib_request -import fsspec import numpy as np import pytest @@ -786,6 +785,8 @@ def test_fsspec(tmp_path): Issue #1146 reported errors when opening a fsspec 'file' This is a regression test for the fix in PR #1226 """ + fsspec = pytest.importorskip("fsspec") + ref = b"01234567890" fn = tmp_path / "test" @@ -809,6 +810,8 @@ def test_fsspec_http(httpserver): filesystem) This is a regression test for the fix in PR #1228 """ + fsspec = pytest.importorskip("fsspec") + ref = b"01234567890" path = os.path.join(httpserver.tmpdir, "test") diff --git a/pyproject.toml b/pyproject.toml index 19bee6fe4..3e4ba6053 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,8 +43,7 @@ docs = [ 'tomli; python_version < "3.11"', ] tests = [ - "fsspec[http]>=2022.8.2", - "asdf-astropy>=0.4.0", + #"fsspec[http]>=2022.8.2", "lz4>=0.10", "psutil", "pytest>=6", diff --git a/requirements-dev.txt b/requirements-dev.txt index 3460c6d90..a552322cc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,7 +3,7 @@ git+https://github.com/asdf-format/asdf-standard git+https://github.com/asdf-format/asdf-transform-schemas git+https://github.com/asdf-format/asdf-unit-schemas.git git+https://github.com/asdf-format/asdf-wcs-schemas -#git+https://github.com/yaml/pyyaml.git +git+https://github.com/yaml/pyyaml.git numpy>=0.0.dev0 # although we don't use scipy, we include it here so that any dependency diff --git a/tox.ini b/tox.ini index 8ad71e31b..87f88ce22 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,8 @@ env_list = compatibility coverage - py{39,310,311}{,-compatibility,-coverage,-jsonschema}{,-parallel} + devdep{,-parallel} + py{39,310,311,312}{,-compatibility,-coverage,-jsonschema}{,-parallel} asdf{-standard,-transform-schemas,-unit-schemas,-wcs-schemas,-coordinates-schemas,-astropy} gwcs jwst From ae2132d2d5a6ab15c0d3311669e1f884624c3dcc Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 22 Sep 2023 14:43:00 -0400 Subject: [PATCH 6/6] re-add fsspec as a test dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3e4ba6053..3f954c247 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ docs = [ 'tomli; python_version < "3.11"', ] tests = [ - #"fsspec[http]>=2022.8.2", + "fsspec[http]>=2022.8.2", "lz4>=0.10", "psutil", "pytest>=6",