Skip to content

Make PyYAML a strict dependency of astropy #11626

Closed

Description

@taldcroft

Description

The yaml library (provided by PyYAML) is central to the serialization functionality used for losslessly storing Table data to ECSV, FITS and HDF5 formats. The ECSV format in particular is seeing fairly wide usage, and is now supported in the StarLink java library STIL and TOPCAT. To this point we have accepted having yaml as an optional dependency, but this means that it cannot be used in any required parts of astropy.

A recent example was to improve the storage of cosmological model parameters. This would nicely be done as an ECSV table, but the yaml dependence was a stopper.

While we do not intend to go down a slippery slope of adding many dependencies, it seems like yaml is justified and would enable future enhancements to astropy core using ECSV or YAML-based storage of data within the package itself.

From the Python packaging perspective this is a small package and should not measurably change the package footprint for a typical astropy installation.

Additional context

#11570

Activity

  1. mhvk commented on Apr 22, 2021

    @mhvk
    Contributor

    I'm in favour. I feel any additional dependency needs to have a clear logic, and pyyaml satisfies that: numpy for array-based computation, erfa for astronomy specific calculations, and pyyaml to allow round-trip storage.

    I think that if we stick to requiring similarly broad use for any new dependencies, the risk of adding too many remains small. I do think it may be useful to have a "recommended" set of possible additional packages (scipy, matplotlib being the obvious ones).

  2. mwcraig commented on Apr 22, 2021

    @mwcraig
    Member

    I'm in favor of this. It is a pretty light-weight dependency and seems relevant to several subpackages.

  3. kabartay commented on Apr 23, 2021

    @kabartay

    I'm in favor of this. It has a lot of advantages that can be later beneficial for Astropy package.

  4. astrofrog commented on Apr 23, 2021

    @astrofrog
    Member

    I’m in favour of this

  5. taldcroft commented on Apr 23, 2021

    @taldcroft
    MemberAuthor

    @pllim or other infrastructure wizard - so far we have all agreement on this idea. How to make this a reality with a PR? I'm not sure where are all the places that need update. My first guess would be searching the repo for pyerfa and use that as a starting point. It shows up 32 places, which isn't too bad??

    It would be really sweet to get this for 4.3. 😸

  6. Cadair commented on Apr 23, 2021

    @Cadair
    Member

    pyyaml can happily build from an sdist without compiled extensions right?

  7. pllim commented on Apr 23, 2021

    @pllim
    Member

    Can we wait till 5.0? Introducing a new required dependency a week before feature freeze is kinda last-minute?

  8. taldcroft commented on Apr 23, 2021

    @taldcroft
    MemberAuthor

    @pllim - OK, maybe I got over-excited.. I guess 5.0 would make sense.

  9. pllim commented on Apr 23, 2021

    @pllim
    Member

    @taldcroft , probably want to send out a memo to astropy-dev mailing list too...

  10. taldcroft commented on Apr 23, 2021

    @taldcroft
    MemberAuthor

    pyyaml can happily build from an sdist without compiled extensions right?

    It does use Cython. I don't see any obvious other extensions but I'm not entirely sure.

    There is the subtlety that libyaml is highly recommended along with PyYAML for performance, but it runs just fine (according to the docs) without it.

  11. taldcroft commented on Apr 23, 2021

    @taldcroft
    MemberAuthor

    And of course there are the doc tests, which are currently done without yaml. No matter how hard I try I still mess this up, like just now in #11569. There are a bunch of doc tests that are skipped because of yaml, so I'll be glad to fix that.

        + meta.get_yaml_from_header(header))
      File "/home/runner/work/astropy/astropy/.tox/py39-test/lib/python3.9/site-packages/astropy/table/meta.py", line 326, in get_yaml_from_header
        raise ImportError('`import yaml` failed, PyYAML package is '
    ImportError: `import yaml` failed, PyYAML package is required for serializing mixin columns
    /home/runner/work/astropy/astropy/docs/io/ascii/write.rst:53: UnexpectedException
    
  12. pllim commented on Apr 23, 2021

    @pllim
    Member

    the doc tests, which are currently done without yaml

    Pretty sure we have a test job that runs with all optional dependencies installed, but I can see the problem with core functionality not being tested in all the jobs.

  13. embray commented on Apr 26, 2021

    @embray
    Member

    👍 Also PyYAML is pretty commonly installed as a dependency of other packages.

  14. added this to the v5.0 milestone on Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions