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-40367: Add connection name to deprecation warning #367

Merged
merged 7 commits into from Aug 15, 2023
Merged

Conversation

timj
Copy link
Member

@timj timj commented Aug 14, 2023

This provides some context. Also remove the find_outside_stacklevel because there is nothing in the stack trace that is relevant to the deprecation warning.

Depends on lsst/utils#168

Checklist

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

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Patch coverage: 90.90% and project coverage change: -0.01% ⚠️

Comparison is base (3c4c2c3) 84.07% compared to head (e779e18) 84.06%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #367      +/-   ##
==========================================
- Coverage   84.07%   84.06%   -0.01%     
==========================================
  Files          77       77              
  Lines        9075     9082       +7     
  Branches     1739     1740       +1     
==========================================
+ Hits         7630     7635       +5     
- Misses       1159     1160       +1     
- Partials      286      287       +1     
Files Changed Coverage Δ
...ython/lsst/pipe/base/tests/mocks/_pipeline_task.py 52.28% <0.00%> (ø)
python/lsst/pipe/base/connectionTypes.py 88.73% <100.00%> (+1.43%) ⬆️
python/lsst/pipe/base/connections.py 79.01% <100.00%> (-0.07%) ⬇️
python/lsst/pipe/base/testUtils.py 96.92% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -372,7 +372,9 @@ def __call__(cls, *, config: PipelineTaskConfig | None = None) -> PipelineTaskCo
for obj in instance._allConnections.values():
if obj.deprecated is not None:
warnings.warn(
obj.deprecated, FutureWarning, stacklevel=find_outside_stacklevel("lsst.pipe.base")
f"{obj.name} (from {obj._deprecation_context}): {obj.deprecated}",
Copy link
Member

Choose a reason for hiding this comment

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

Instead of obj.name here, I think we want to iterate over _allConnections.items() and use the key from that mapping. Currently this is the dataset type name, which is not unique, and the mapping key is the task-internal connection name, which is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe if we had that info I wouldn't need to find the filename and line number where it was originally defined because the content would be unique enough that it could be found from searching the source.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the combination of the two would be good in addition to the work you did here for maximum info. something like "connection {dict key} with dataset type {obj.name} is deprecated....."

Copy link
Member Author

Choose a reason for hiding this comment

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

That was easy. Now it looks like:

FutureWarning: Connection finalizedPsfApCorrCatalog with datasetType finalVisitSummary (from /Users/timj/work/lsstsw/stack/lsst-scipipe-7.0.0/Darwin/pipe_tasks/g85f8d04a89+f020c27613/python/lsst/pipe/tasks/makeWarp.py:121): Deprecated in favor of 'visitSummary'.  Will be removed after v26.

@@ -372,7 +372,9 @@ def __call__(cls, *, config: PipelineTaskConfig | None = None) -> PipelineTaskCo
for obj in instance._allConnections.values():
if obj.deprecated is not None:
warnings.warn(
obj.deprecated, FutureWarning, stacklevel=find_outside_stacklevel("lsst.pipe.base")
f"{obj.name} (from {obj._deprecation_context}): {obj.deprecated}",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the combination of the two would be good in addition to the work you did here for maximum info. something like "connection {dict key} with dataset type {obj.name} is deprecated....."

This provides some context. Also remove the find_outside_stacklevel
because there is nothing in the stack trace that is relevant to
the deprecation warning.
This is then used in the warning message emitted later.
@timj timj merged commit bb42ac7 into main Aug 15, 2023
13 of 14 checks passed
@timj timj deleted the tickets/DM-40367 branch August 15, 2023 20:25
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.

None yet

3 participants