Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-39227: Add support for deprecating connections. #349

Closed
wants to merge 3 commits into from

Conversation

TallJimbo
Copy link
Member

@TallJimbo TallJimbo commented Jun 30, 2023

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09 🎉

Comparison is base (e6f13a4) 82.72% compared to head (786867b) 82.81%.

❗ Current head 786867b differs from pull request most recent head 8b58026. Consider uploading reports for the commit 8b58026 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #349      +/-   ##
==========================================
+ Coverage   82.72%   82.81%   +0.09%     
==========================================
  Files          66       66              
  Lines        7246     7252       +6     
  Branches     1408     1411       +3     
==========================================
+ Hits         5994     6006      +12     
+ Misses       1005     1000       -5     
+ Partials      247      246       -1     
Impacted Files Coverage Δ
python/lsst/pipe/base/config.py 70.12% <ø> (ø)
python/lsst/pipe/base/connectionTypes.py 87.50% <100.00%> (+0.40%) ⬆️
python/lsst/pipe/base/connections.py 78.12% <100.00%> (+0.27%) ⬆️
tests/test_connections.py 98.91% <100.00%> (+0.10%) ⬆️

... and 9 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

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

Is it enough to announce the deprecation in the Config class? Does it make sense to also warn in the construction of the Connections class?

python/lsst/pipe/base/connectionTypes.py Outdated Show resolved Hide resolved
@@ -57,6 +57,14 @@ class BaseConnection:
doc: str = ""
multiple: bool = False

deprecated: str | None = dataclasses.field(default=None, kw_only=True)
"""A description of why this connection is deprecated, including the
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems a bug that we are not documenting doc above. It seems weird that the docs for this are here and not up with the docstring like the others. What does sphinx perfer? I know python does nothing with strings defined below an attribute and just drops them on the floor, so interactively the docs are unavailable. Can you make these docs consistent one way or another?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I hadn't even noticed that the others had been documented earlier. I usually think of the class doc's "Parameters" section as being for __init__ arguments, not instance attributes, but I suppose for dataclasses there's (usually) not much distinction. I'll just move this docstring up with the rest.

Copy link
Contributor

@natelust natelust Jun 30, 2023

Choose a reason for hiding this comment

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

In a dataclass they are all init args unless you play with that though right? Though I think that is a bit of a pain because of playing with the sense of args.

Copy link
Contributor

Choose a reason for hiding this comment

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

Like I said, I am fine if you want to move them all there, but it is a bit sad because it wont show up with help

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. My tendency is to add class Parameters to a dataclass only if I actually define an __init__ but to always document the attributes. I don't think that's obviously better or worse than only documenting them in class Parameters as you've done here, though maybe we should always be documenting both? (Of course, duplication is then its own problem.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have actually moved the new one to Parameters; I was just explaining my usual practice elsewhere. I'd rather resolve the general question about which (if either) of us should adopt the other's practice outside this ticket, and just keep things closer to the way they are already are for now.

@TallJimbo
Copy link
Member Author

Does it make sense to also warn in the construction of the Connections class?

I was originally thinking that'd have to be an unconditional warning, which would be bad, but I think I could make it warn if any deprecated connections have not been removed by the end of the Connections construction. I'll give that a try.

@TallJimbo
Copy link
Member Author

TallJimbo commented Jun 30, 2023

@natelust, two more commits here for when you have a moment:

  • 9c7b402 implements your suggestion to warn at connections class construction;
  • 8b58026 adds support for deprecating the config fields that go with connection templates.

This intentionally just deprecates the corresponding config entry,
keeping those config fields from being written.  The expectation is
that deprecated templates may be used in also-deprecated connections
without emitting another warning, and then both can be removed
together.
@TallJimbo
Copy link
Member Author

@andy-slac , I just realized that @natelust is out for a few days and hence won't see my previous comment about the last two commits here. Would you mind filling in as reviewer for those?

Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

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

Looks good.

@TallJimbo
Copy link
Member Author

Since the rest of this ticket has a longer test-and-review future ahead of it and it's logically distinct, I've moved the changes on this branch to DM-39902 and #351.

@TallJimbo TallJimbo closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants