Skip to content

Make fitting_parallel.py private to make sure function parallel_fit_dask is imported from astropy.modeling.fitting#16974

Merged
astrofrog merged 2 commits intoastropy:mainfrom
astrofrog:make-parallel-fitting-private
Sep 16, 2024
Merged

Make fitting_parallel.py private to make sure function parallel_fit_dask is imported from astropy.modeling.fitting#16974
astrofrog merged 2 commits intoastropy:mainfrom
astrofrog:make-parallel-fitting-private

Conversation

@astrofrog
Copy link
Member

@astrofrog astrofrog commented Sep 9, 2024

Although we haven't really reached a consensus on the public API APE, we might as well make this new file private by default since it isn't meant to be used directly.

Blocked by

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2024

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 instructions for rebase and squash.
  • 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?
  • 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.

@astrofrog astrofrog force-pushed the make-parallel-fitting-private branch from e189c17 to 350628d Compare September 9, 2024 10:33
@pllim pllim added this to the v7.0.0 milestone Sep 9, 2024
pllim
pllim previously approved these changes Sep 9, 2024
Copy link
Member

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Note to self: First added in #16696 also milestoned to v7.0.0 , so this is changing an unreleased feature and does not need change log.

@pllim pllim added Affects-dev PRs and issues that do not impact an existing Astropy release API change PRs and issues that change an existing API, possibly requiring a deprecation period labels Sep 9, 2024
@pllim
Copy link
Member

pllim commented Sep 9, 2024

Broke RTD

WARNING: py:func reference target not found: astropy.modeling.fitting.parallel_fit_dask

@pllim
Copy link
Member

pllim commented Sep 9, 2024

pre-commit.ci autofix

@pllim pllim dismissed their stale review September 9, 2024 21:21

Didn't see RTD was broken, withdrawing approval

@astrofrog
Copy link
Member Author

Huh, any idea why this would have broken RTD?

@pllim
Copy link
Member

pllim commented Sep 9, 2024

The ref does not exist anymore because module is private?

@astrofrog
Copy link
Member Author

But the ref is pointing to the fitting.py file not parallel_fitting.py, so it should be fine?

@pllim
Copy link
Member

pllim commented Sep 10, 2024

I am not the one you have to convince...

@neutrinoceros
Copy link
Contributor

Could you try explicitly re-exporting it ?

diff --git a/astropy/modeling/fitting.py b/astropy/modeling/fitting.py
index 40f0bac01d..dee76ed6ce 100644
--- a/astropy/modeling/fitting.py
+++ b/astropy/modeling/fitting.py
@@ -33,7 +33,7 @@ import numpy as np
 from astropy.units import Quantity
 from astropy.utils.exceptions import AstropyUserWarning
 
-from ._fitting_parallel import parallel_fit_dask
+from ._fitting_parallel import parallel_fit_dask as parallel_fit_dask  # noqa: PLC0414
 from .optimizers import DEFAULT_ACC, DEFAULT_EPS, DEFAULT_MAXITER, SLSQP, Simplex
 from .spline import (
     SplineExactKnotsFitter,

@astrofrog
Copy link
Member Author

@neutrinoceros - no that didn't seem to work either.

I've pushed a hack that does fix it. The issue is that sphinx-automodapi uses function.module to determine the fully qualified name of a function and excludes it by default if it is not local to the submodule being documented (which is sensible).

@nstarman - this is going to be a major issue if we do use this pattern to make submodules private. Do you know of a way around it?

@nstarman
Copy link
Member

This may be a configuration issue? I think Sphinx needs something like:

.. automodule:: fitting
   :members:
   :undoc-members:
   :show-inheritance:
# Automatically document members imported in modules
autodoc_default_options = {
    'members': True,
    'imported-members': True,  # Include imported members
    'undoc-members': True,  # Include members w/out docstrings
    'show-inheritance': True,
}

@astrofrog
Copy link
Member Author

I think the solution has to be different here because we are using sphinx-automodapi which lists the individual classes and functions. We usually don't have this issue when we import up one level, I think this is because it is a 'sideways' import. I wonder if it is a bug in sphinx-automodapi's smart_resolver, will investigate.

@astrofrog
Copy link
Member Author

Working on it in astropy/sphinx-automodapi#190

@astrofrog
Copy link
Member Author

Ok so astropy/sphinx-automodapi#190 should fix this, would appreciate some reviews of that PR, then I can release a new version of sphinx-automodapi and try it here.

@astrofrog astrofrog force-pushed the make-parallel-fitting-private branch from 346705e to 4f5e09f Compare September 16, 2024 10:22
@astrofrog
Copy link
Member Author

Triggering a new build to pick up sphinx-automodapi v0.18.0

@astrofrog
Copy link
Member Author

Seems to work! 🎉

@astrofrog astrofrog requested a review from Cadair September 16, 2024 12:04
@astrofrog astrofrog merged commit 3051730 into astropy:main Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Affects-dev PRs and issues that do not impact an existing Astropy release API change PRs and issues that change an existing API, possibly requiring a deprecation period installation modeling no-changelog-entry-needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants