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-45536: address edge cases in task mocking system #432

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/DM-45536.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix support for task metadata as inputs in the `PipelineTask` mocking system.
11 changes: 2 additions & 9 deletions python/lsst/pipe/base/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,8 @@

datasetRef: DatasetRef

@property
def datasetType(self) -> DatasetType:
"""The dataset type for this dataset."""
return self.datasetRef.datasetType

@property
def dataId(self) -> DataCoordinate:
"""The data ID for this dataset."""
return self.datasetRef.dataId
def __getattr__(self, name: str) -> Any:
return getattr(self.datasetRef, name)

Check warning on line 497 in python/lsst/pipe/base/connections.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/connections.py#L497

Added line #L497 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

This change is because you needed some other method on datasetRef? Or because you wanted to simplify the code a bit?

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, there was some previously-unused code in the mocking stuff that needed id that was uncovered by the other change.



class PipelineTaskConnections(metaclass=PipelineTaskConnectionsMetaclass):
Expand Down
5 changes: 5 additions & 0 deletions python/lsst/pipe/base/tests/mocks/_pipeline_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@
raise ValueError(
f"Unmocked dataset type {connection.name!r} cannot be used as an init-output."
)
elif connection.name.endswith("_metadata") and connection.storageClass == "TaskMetadata":
# Task metadata does not use a mock storage class, because it's
# written by the system, but it does end up with the _mock_*
# prefix because the task label does.
connection = dataclasses.replace(connection, name=get_mock_name(connection.name))

Check warning on line 432 in python/lsst/pipe/base/tests/mocks/_pipeline_task.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/pipe/base/tests/mocks/_pipeline_task.py#L432

Added line #L432 was not covered by tests
setattr(self, name, connection)

def getSpatialBoundsConnections(self) -> Iterable[str]:
Expand Down
Loading