asdf-format / asdf-wcs-schemas

World Coordinate System (WCS) ASDF schemas
https://asdf-wcs-schemas.readthedocs.io/
Other
4 stars 5 forks source link

[0.2.0] Most CI tests fail because of unavailable resources #50

Closed olebole closed 1 year ago

olebole commented 1 year ago

When I run the test suite on the installed package, I get a lot of failures like:

_______________________ test_schema_integration[schema_path0] ________________________

schema_path = PosixPath('/home/ole/Projects/2011/debian/python/stsci/asdf-wcs-schemas/resources/schemas/stsci.edu/gwcs/snell3d-1.0.0.yaml')

    @pytest.mark.parametrize("schema_path", _SCHEMAS_ROOT.glob("**/*.yaml"))
    def test_schema_integration(schema_path):
        content = schema_path.read_bytes()
        schema = yaml.safe_load(content)
>       asdf_content = asdf.get_config().resource_manager[schema["id"]]

Projects/2011/debian/python/stsci/asdf-wcs-schemas/tests/test_integration.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ResourceManager len: 282>, uri = 'http://stsci.edu/schemas/gwcs/snell3d-1.0.0'

    def __getitem__(self, uri):
        if uri not in self._mappings_by_uri:
            msg = f"Resource unavailable for URI: {uri}"
>           raise KeyError(msg)
E           KeyError: 'Resource unavailable for URI: http://stsci.edu/schemas/gwcs/snell3d-1.0.0'

A full test run can be found here. The URL can also not be resolved manually. Would it be possible to have the tests self contained? Having the tests dependent on the availability of some external resources is always a bit dangerous and causes headaches for distributions like Debian.

braingram commented 1 year ago

Thanks for sharing the test log.

The uri vs url confusion is pretty common with asdf (we've tried to move to 'asdf' instead of 'http' uris but the schemas in this package still use 'http' for backwards compatibility). The uri (note, not a url) does not refer to a remote resource and instead is the id of the schema, found here: https://github.com/asdf-format/asdf-wcs-schemas/blob/68aa9749f8abcd1868f86bce53dee5e07be712ad/resources/schemas/stsci.edu/gwcs/snell3d-1.0.0.yaml#L4

I'm so far unable to replicate the issue you're having although I am unfamiliar with the debian build infrastructure to know how to try and replicate it beyond installing the python package and running the tests. I did notice a few things:

I'm happy to provide more details. Let me know what I can do to help debug the issue.

braingram commented 1 year ago

Looking at the data.tar.xz of the python3-asdf-wcs-schemas.deb file in the artifacts of the build system you linked I find no schema files.

./
./usr/
./usr/lib/
./usr/lib/python3/
./usr/lib/python3/dist-packages/
./usr/lib/python3/dist-packages/asdf_wcs_schemas/
./usr/lib/python3/dist-packages/asdf_wcs_schemas/__init__.py
./usr/lib/python3/dist-packages/asdf_wcs_schemas/_version.py
./usr/lib/python3/dist-packages/asdf_wcs_schemas/integration.py
./usr/lib/python3/dist-packages/asdf_wcs_schemas/resources/
./usr/lib/python3/dist-packages/asdf_wcs_schemas/resources/__init__.py
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/INSTALLER
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/METADATA
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/WHEEL
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/entry_points.txt
./usr/lib/python3/dist-packages/asdf_wcs_schemas-0.2.0.dist-info/top_level.txt
./usr/share/
./usr/share/doc/
./usr/share/doc/python3-asdf-wcs-schemas/
./usr/share/doc/python3-asdf-wcs-schemas/changelog.Debian.gz
./usr/share/doc/python3-asdf-wcs-schemas/changelog.gz
./usr/share/doc/python3-asdf-wcs-schemas/copyright

These are required by (and pretty much the only thing provided by) this package.

As this appears to be an issue with how this is being packaged for debian and not an issue with asdf-wcs-schemas I am going to close this issue. Please feel free to comment on this issue and we can continue the discussion about how to sort out packaging this for debian. I just want to close the issue to not mislead other users that might think there is an issue with 0.2.0.

Hellseher commented 8 months ago

Hi @braingram,

I've faced the same issue while updating the package in Guix to 0.3.0. I see the schema files resources are away from the module which may address the issue of missing them in final package. May you suggest where ASDF expects to find schema files from each asdf-* affiliated projects?

It is unclear from this documentation where they should be located https://github.com/asdf-format/asdf-wcs-schemas/blob/44de71fdd9d778beb3b13a4a784f1e162db5b34b/docs/index.rst#L17

Following would provide more details https://github.com/asdf-format/asdf/blob/7ae2d7eb198b4ef433eed6be8394a18ac22af619/docs/asdf/extending/resources.rst#installing-resources-via-entry-points

As far as I see now by reading pyproject.toml

[tool.setuptools]
packages = ["asdf_wcs_schemas", "asdf_wcs_schemas.resources"]

[tool.setuptools.package-data]
"asdf_wcs_schemas.resources" = ["resources/**/*.yaml"]

[tool.setuptools.package-dir]
'' = "src"
"asdf_wcs_schemas.resources" = "resources"

[tool.pytest.ini_options]
asdf_schema_root = 'resources/schemas'
asdf_schema_tests_enabled = 'true'
asdf_schema_ignore_unrecognized_tag = 'true'
testpaths = """
    tests
    resources
"""

I need to copy resources into asdf_wcs_schemas as the one final step of preparing package.

Came here from https://github.com/spacetelescope/roman_datamodels/issues/307

Thanks, Oleg

braingram commented 8 months ago

This package is designed to be built with setuptools: https://github.com/asdf-format/asdf-wcs-schemas/blob/44de71fdd9d778beb3b13a4a784f1e162db5b34b/pyproject.toml#L24-L30 Is it possible to use that for packaging this project for guix?

The package-dir options determines where the resources will be placed during build.

Building this package with setuptools results in a distribution archive with the resources located at the expected location (see a cutout from the build log below):

copying resources/schemas/stsci.edu/gwcs/celestial_frame-1.0.0.yaml -> build/lib/asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs
copying resources/schemas/stsci.edu/gwcs/composite_frame-1.0.0.yaml -> build/lib/asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs
copying resources/schemas/stsci.edu/gwcs/direction_cosines-1.0.0.yaml -> build/lib/asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs
copying resources/schemas/stsci.edu/gwcs/direction_cosines-1.1.0.yaml -> build/lib/asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs
...
adding 'asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs/celestial_frame-1.0.0.yaml'
adding 'asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs/composite_frame-1.0.0.yaml'
adding 'asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs/direction_cosines-1.0.0.yaml'
adding 'asdf_wcs_schemas/resources/schemas/stsci.edu/gwcs/direction_cosines-1.1.0.yaml'
Hellseher commented 8 months ago

Hi,

Thank you for the reply and detailed explanation, @braingram.

I can confirm that Guix's build phase uses the setuptools backend, and resources are copied into the final package. Please see https://ci.guix.gnu.org/build/3350157/log/raw.

I am noting here for future reference that the issue is in Guix's check phase, where the tests are invoked from a non-installed package.

Regards, Oleg