Skip to content

cosmo: make public io submodule#14982

Closed
nstarman wants to merge 3 commits into
astropy:mainfrom
nstarman:cosmo-move-connect
Closed

cosmo: make public io submodule#14982
nstarman wants to merge 3 commits into
astropy:mainfrom
nstarman:cosmo-move-connect

Conversation

@nstarman
Copy link
Copy Markdown
Member

@nstarman nstarman commented Jun 25, 2023

In a previous PR (#14842) I made the private io module actually private.
This PR:

  • introduces a public io module , which is much more carefully managed.
    • moves the contents of _io to io/_builtin.
  • moves the connect.py file to io as a private module, but publicly importing it's classes and attributes.
    • deprecates the connect.py module for later removal.
  • modifies the docs, though most of the content was introduced in Cosmo io docs #15090

TODO:

@nstarman nstarman added this to the v6.0 milestone Jun 25, 2023
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@nstarman nstarman force-pushed the cosmo-move-connect branch 5 times, most recently from 2cdf9e9 to 2a2ad35 Compare July 25, 2023 04:54
@nstarman nstarman force-pushed the cosmo-move-connect branch 7 times, most recently from f65c78b to 8b79cdd Compare August 7, 2023 19:09
@nstarman nstarman marked this pull request as ready for review August 7, 2023 19:11
@nstarman nstarman requested a review from a team as a code owner August 7, 2023 19:11
@nstarman nstarman requested review from WilliamJamieson, eerovaher and mhvk and removed request for a team August 7, 2023 19:11
@nstarman nstarman force-pushed the cosmo-move-connect branch from 8b79cdd to b44e240 Compare August 13, 2023 18:55
@nstarman
Copy link
Copy Markdown
Member Author

ping @mhvk, @eerovaher. If you have time to review this. I'm trying to consolidate and clean up the I/O structure. Most of this is very straightforward, just moving files around and adding __getattr__ to keep the API identical and enable a deprecation period.

@mhvk
Copy link
Copy Markdown
Contributor

mhvk commented Aug 14, 2023

See #15169 for discussion of how one should indicate what is private.

@nstarman
Copy link
Copy Markdown
Member Author

nstarman commented Aug 14, 2023

@mhvk, I think this PR can proceed as all the content currently lives in _io which is already private and nothing changes on this front in the move to io/_builtin. A resolution to #15159 and astropy/astropy-APEs#85 might require a new PR to rename _builtin to builtin but also to the current incarnation _io -> io.

@nstarman nstarman force-pushed the cosmo-move-connect branch from b44e240 to aa857b4 Compare August 23, 2023 02:14
@nstarman nstarman force-pushed the cosmo-move-connect branch 2 times, most recently from 9d4c2a8 to b9025ae Compare September 1, 2023 19:19
@nstarman
Copy link
Copy Markdown
Member Author

Thanks @eerovaher for the review.

@nstarman nstarman requested a review from eerovaher October 16, 2023 15:51
@saimn saimn modified the milestones: v6.0, v6.1 Oct 28, 2023
@nstarman nstarman force-pushed the cosmo-move-connect branch 2 times, most recently from 8072a97 to 2adb55b Compare January 14, 2024 00:10
@astrofrog astrofrog modified the milestones: v6.1.0, v7.0.0 Apr 4, 2024
@nstarman nstarman force-pushed the cosmo-move-connect branch 2 times, most recently from 69b2198 to 93317c6 Compare April 16, 2024 21:10
@nstarman
Copy link
Copy Markdown
Member Author

@mhvk @eerovaher @WilliamJamieson, I think this PR can proceed as all the content currently lives in _io which is already private and nothing changes on this front in the move to io/_builtin. A resolution to #15159 and astropy/astropy-APEs#85 might require a new PR to rename _builtin to builtin but also to the current incarnation _io -> io.

@nstarman nstarman force-pushed the cosmo-move-connect branch from 0594a0a to a7ccc4f Compare April 16, 2024 22:58
Comment on lines +40 to +43
>>> cosmo
FlatLambdaCDM(name="Planck18", H0=67.66 km / (Mpc s), Om0=0.30966,
Tcmb0=2.7255 K, Neff=3.046, m_nu=[0. 0. 0.06] eV, Ob0=0.04897)
FlatLambdaCDM(name='Planck18', H0=<Quantity 67.66 km / (Mpc s)>, Om0=0.30966,
Tcmb0=<Quantity 2.7255 K>, Neff=3.046,
m_nu=<Quantity [0. , 0. , 0.06] eV>, Ob0=0.04897)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming modules should not cause FlatLambdaCDM.__repr__() to produce different output, and it looks like pytest agrees with me. This is a large pull request, I'd rather not review it until it has been cleaned up.

Copy link
Copy Markdown
Member Author

@nstarman nstarman Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these doctests were being tested! Trying to find the exact change that made them start being tested.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to identify the change that caused all these docstrings to start being tested. But regardless of the cause, I can confirm that the old docstrings are wrong, the new ones are correct, and that the docstrings are now being tested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output here depends on the Python version, see

astropy/pyproject.toml

Lines 204 to 207 in dde34be

doctest_subpackage_requires = [
"astropy/cosmology/_io/mapping.py = python<3.12", # PYTHON_LT_3_12 (PR 14784)
"astropy/cosmology/_io/row.py = python<3.12", # PYTHON_LT_3_12 (PR 14784)
"astropy/cosmology/_io/table.py = python<3.12", # PYTHON_LT_3_12 (PR 14784)

There's no need to update the docstrings in this pull request.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. And since _io is now io...
I can separate this into 2 PRs, first for the re-org. Then for fixing the docstrings.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring difference looks like repr vs str on the quantities. Not sure repr is better here.

Copy link
Copy Markdown
Member Author

@nstarman nstarman Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'>>>' calls repr. We would have to do print for everything.

Maybe Quantity's repr should be updated to call repr on its contents and enable eval(repr(q))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that eval(repr(q)) doesn't work, but admittedly for arrays this is always going to be a problem (at least large ones). And ndarray doesn't produce a repr that can be evaluated either... This is why I was wondering if it really made sense to use repr(q) in cosmology.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And ndarray doesn't produce a repr that can be evaluated either...

But other array types can! Maybe Quantity 2.0 is a good opportunity to enable the repr behavior, to support all the other array types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerovaher, done! removed the doc edits to mapping, row, and table.

@nstarman nstarman force-pushed the cosmo-move-connect branch from a7ccc4f to 322df98 Compare April 19, 2024 19:10
Copy link
Copy Markdown
Member

@eerovaher eerovaher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few remarks, but I might have a few more when I've had a look at the rendered docs.

Comment thread astropy/cosmology/connect.py Outdated
Comment thread astropy/cosmology/io/__init__.py Outdated
Comment thread astropy/cosmology/io/_connect.py Outdated
Comment thread docs/whatsnew/7.0.rst Outdated
Comment thread docs/whatsnew/7.0.rst Outdated
Comment thread docs/whatsnew/7.0.rst Outdated
Comment on lines +88 to +313
:mod:`~astropy.cosmology.connect` module. It is intended that more public I/O
functionality will be added to the :mod:`~astropy.cosmology.io` module in the future.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's a good idea to make such public promises.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make much of the contents of _builtin that are related to converting between formats publicly accessible. I don't think there's a good way to type hint to(from)_format and I also want to both support a more functional approach to I/O. Also I would love to enable entry points so 3rd party packages can better register I/O formats. All it takes is copious free time to do...

Comment thread docs/cosmology/io/index.rst Outdated
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Sep 17, 2024
@github-actions
Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@nstarman nstarman force-pushed the cosmo-move-connect branch 2 times, most recently from 11f6067 to 8cf4f4c Compare October 9, 2024 20:52
@nstarman nstarman removed the Close? Tell stale bot that this issue/PR is stale label Oct 9, 2024
nstarman and others added 3 commits October 10, 2024 11:36
Signed-off-by: Nathaniel Starkman <[email protected]>
Signed-off-by: nstarman <[email protected]>
Co-authored-by: Eero Vaher <[email protected]>
Signed-off-by: nstarman <[email protected]>

Update docs/whatsnew/7.0.rst

Co-authored-by: Eero Vaher <[email protected]>
@nstarman nstarman requested a review from eerovaher October 10, 2024 17:04
@saimn saimn modified the milestones: v7.0.0, v7.1.0 Oct 26, 2024
@nstarman nstarman closed this Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants