Skip to content

Commit

Permalink
Mark deprecated REST endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirving committed Sep 9, 2024
1 parent d23cd84 commit f42382b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def _get_file_by_ref(butler: Butler, ref: DatasetRef) -> GetFileResponseModel:
return GetFileResponseModel(dataset_ref=ref.to_simple(), artifact=payload)


# TODO DM-46204: This can be removed once the RSP recommended image has been
# upgraded to a version that contains DM-46129.
@external_router.get(
"/v1/collection_info", summary="Get information about a collection", response_model_exclude_unset=True
)
Expand Down Expand Up @@ -233,6 +235,8 @@ def get_collection_summary(
return GetCollectionSummaryResponseModel(summary=butler.registry.getCollectionSummary(name).to_simple())


# TODO DM-46204: This can be removed once the RSP recommended image has been
# upgraded to a version that contains DM-46129.
@external_router.post(
"/v1/query_collections", summary="Search for collections with names that match an expression"
)
Expand Down
6 changes: 6 additions & 0 deletions python/lsst/daf/butler/remote_butler/server_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class ErrorResponseModel(pydantic.BaseModel):
"""Detailed explanation of the error that will be sent to the client."""


# TODO DM-46204: This can be removed once the RSP recommended image has been
# upgraded to a version that contains DM-46129.
class GetCollectionInfoResponseModel(pydantic.BaseModel):
"""Response model for get_collection_info."""

Expand Down Expand Up @@ -174,6 +176,8 @@ class ExpandDataIdResponseModel(pydantic.BaseModel):
data_coordinate: SerializedDataCoordinate


# TODO DM-46204: This can be removed once the RSP recommended image has been
# upgraded to a version that contains DM-46129.
class QueryCollectionsRequestModel(pydantic.BaseModel):
"""Request model for query_collections."""

Expand All @@ -183,6 +187,8 @@ class QueryCollectionsRequestModel(pydantic.BaseModel):
include_chains: bool


# TODO DM-46204: This can be removed once the RSP recommended image has been
# upgraded to a version that contains DM-46129.
class QueryCollectionsResponseModel(pydantic.BaseModel):
"""Response model for query_collections."""

Expand Down
21 changes: 21 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from lsst.daf.butler.remote_butler._authentication import _EXPLICIT_BUTLER_ACCESS_TOKEN_ENVIRONMENT_KEY
from lsst.daf.butler.remote_butler.server import create_app
from lsst.daf.butler.remote_butler.server._dependencies import butler_factory_dependency
from lsst.daf.butler.remote_butler.server_models import QueryCollectionsRequestModel
from lsst.daf.butler.tests.server import TEST_REPOSITORY_NAME, UnhandledServerError, create_test_server

reason_text = ""
Expand Down Expand Up @@ -426,6 +427,26 @@ def test_query_keepalive(self):
self.assertGreaterEqual(mock_timeout.call_count, 3)
self.assertGreaterEqual(mock_keep_alive.call_count, 2)

# TODO DM-46204: This can be removed once the RSP recommended image has
# been upgraded to a version that contains DM-46129.
def test_deprecated_collection_endpoints(self):
# These REST endpoints are no longer used by Butler client so they need
# to be checked separately until they can be removed.
json = self.butler._connection.get(
"collection_info",
params={"name": "imported_g", "include_doc": True, "include_parents": True},
).json()
self.assertEqual(json["name"], "imported_g")
self.assertEqual(json["type"], 1)

json = self.butler._connection.post(
"query_collections",
QueryCollectionsRequestModel(
search=["imported_*"], collection_types=[1], flatten_chains=False, include_chains=False
),
).json()
self.assertCountEqual(json["collections"], ["imported_g", "imported_r"])


def _create_corrupted_dataset(repo: MetricTestRepo) -> DatasetRef:
run = "corrupted-run"
Expand Down

0 comments on commit f42382b

Please sign in to comment.