From cdb1bfe6433cf843d539df7f74b9d104456d4ced Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Mon, 9 Sep 2024 12:12:55 -0700 Subject: [PATCH] Mark deprecated REST endpoints --- .../server/handlers/_external.py | 4 ++++ .../daf/butler/remote_butler/server_models.py | 6 ++++++ tests/test_server.py | 21 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/python/lsst/daf/butler/remote_butler/server/handlers/_external.py b/python/lsst/daf/butler/remote_butler/server/handlers/_external.py index 1ac350dc91..982c008c42 100644 --- a/python/lsst/daf/butler/remote_butler/server/handlers/_external.py +++ b/python/lsst/daf/butler/remote_butler/server/handlers/_external.py @@ -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 ) @@ -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" ) diff --git a/python/lsst/daf/butler/remote_butler/server_models.py b/python/lsst/daf/butler/remote_butler/server_models.py index d1e61a17d3..6573d70967 100644 --- a/python/lsst/daf/butler/remote_butler/server_models.py +++ b/python/lsst/daf/butler/remote_butler/server_models.py @@ -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.""" @@ -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.""" @@ -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.""" diff --git a/tests/test_server.py b/tests/test_server.py index 4b41c5d01b..be7d0cd81c 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -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 = "" @@ -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"