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-36303: Replace RFC-878/879 deprecations with removals #891

Merged
merged 18 commits into from Jan 10, 2024
Merged

Conversation

timj
Copy link
Member

@timj timj commented Sep 29, 2023

Checklist

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

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 24 lines in your changes are missing coverage. Please review.

Comparison is base (d8d7886) 88.37% compared to head (8ee1e29) 88.34%.

Files Patch % Lines
python/lsst/daf/butler/registry/sql_registry.py 57.57% 10 Missing and 4 partials ⚠️
...ython/lsst/daf/butler/registry/queries/_results.py 60.00% 2 Missing and 2 partials ⚠️
python/lsst/daf/butler/cli/cmd/commands.py 25.00% 2 Missing and 1 partial ⚠️
python/lsst/daf/butler/direct_query_results.py 80.00% 2 Missing ⚠️
.../butler/registry/datasets/byDimensions/_manager.py 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #891      +/-   ##
==========================================
- Coverage   88.37%   88.34%   -0.03%     
==========================================
  Files         301      301              
  Lines       38854    38752     -102     
  Branches     8186     8165      -21     
==========================================
- Hits        34337    34237     -100     
+ Misses       3343     3334       -9     
- Partials     1174     1181       +7     

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

Copy link
Member Author

@timj timj left a comment

Choose a reason for hiding this comment

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

The rebase took a while because the first batch of changes turned out to already be applied on main but in slightly different ways. I think everything looks reasonable now and all tests pass and mypy is happy.

We do still issue a warning for components in the tests because we are calling _iter_by_dataset_type which calls the .components property on the result (and then calls withComponents. Presumably that code could be cleaned up as well.

@@ -1229,8 +1237,11 @@ def find_dataset(
)
if ref is not None and dimension_records:
ref = ref.expanded(self._registry.expandDataId(ref.dataId, dimensions=ref.datasetType.dimensions))
if ref is not None and component_name:
ref = ref.makeComponentRef(component_name)
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is sufficient to make all the Butler.get() tests with components work. I do understand that doing this means that Butler.find_dataset is handling components but Butler.query_datasets() does not. If we don't like this the above code will have to move into _findDatasetRef.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with handling components here like this.

@@ -281,7 +281,7 @@ def queryDatasetTypes(
self,
expression: Any = ...,
*,
components: bool | None = None,
components: bool = False,
Copy link
Member Author

Choose a reason for hiding this comment

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

When I was working on #937, it occurred to me that we really want to be warning if people set the components flag to False. What do you think about having this be something like:

components : bool | _Sentinel = _DefaultSentinel

and then warning if components is False ?

Copy link
Member

@TallJimbo TallJimbo Jan 9, 2024

Choose a reason for hiding this comment

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

👍, but we should instead warn if components is not _DefaultSentinal in case somebody is still passing None and isn't running MyPy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was trying to say that we should warn any time it's not _DefaultSentinel because that would imply someone actually tried to set it. We should likely raise if they set it to anything other than False.

@timj timj marked this pull request as ready for review January 5, 2024 22:05
@timj timj force-pushed the tickets/DM-36303 branch 2 times, most recently from cbbeb84 to 85ce59c Compare January 8, 2024 21:39
@timj timj requested a review from TallJimbo January 8, 2024 23:13
Copy link
Member

@TallJimbo TallJimbo left a comment

Choose a reason for hiding this comment

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

registry.queries.ParentDatasetQueryResults.withComponents seems to have escaped deprecation originally, so we should definitely add that deprecation now. I think that means we also have to defer removing the _components attribute until that's removed; after other changes on this ticket it should be possible for it to be constructed with anything other than components=[None] except for via withComponents.

And then I think we want to reimplement _iter_by_dataset_type to just use _components and duplicate the implementation of withComponents internally. That will keep it from emitting any warnings of its own, while the deprecation of withComponents will close the last remaining avenue for making it actually iterate over components without a warning.

There's also the issue that the "parent" in that class name and in byParentDatasetTypes is not so great anymore. I'm inclined to leave it on the old registry result types, but we should fix the Butler._query_results versions since those aren't public yet.

@@ -281,7 +281,7 @@ def queryDatasetTypes(
self,
expression: Any = ...,
*,
components: bool | None = None,
components: bool = False,
Copy link
Member

@TallJimbo TallJimbo Jan 9, 2024

Choose a reason for hiding this comment

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

👍, but we should instead warn if components is not _DefaultSentinal in case somebody is still passing None and isn't running MyPy.

@@ -1229,8 +1237,11 @@ def find_dataset(
)
if ref is not None and dimension_records:
ref = ref.expanded(self._registry.expandDataId(ref.dataId, dimensions=ref.datasetType.dimensions))
if ref is not None and component_name:
ref = ref.makeComponentRef(component_name)
Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with handling components here like this.

@TallJimbo
Copy link
Member

I've pushed three new commits to deal with ParentDatasetQueryResults.

TallJimbo and others added 16 commits January 9, 2024 15:00
This involves some guesses about how we'll update the RemoteRegistry
server, which I'm not attempting to change right now since I don't know
how to test it.
Dataset type wildcards are no longer permitted in queryDataIds and
queryDimensionRecords, and missing dataset types are now an error in
those contexts.
Should have been deprecated earlier, but better late than never.
Since getting a component DatasetRef from a parent one is just a method
call, there's no need for this complexity in the query system.
The components parameter is deprecated. Warn if False is specified
explicitly in addition to raising if any other value is used.
@timj timj merged commit eae7056 into main Jan 10, 2024
16 of 18 checks passed
@timj timj deleted the tickets/DM-36303 branch January 10, 2024 15:14
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

2 participants