From 39e8b476da86c355dab967a88ac93e16d399b066 Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Thu, 2 Nov 2023 12:11:22 -0700 Subject: [PATCH] Make "/butler" URL prefix variable in client For phalanx deployments, all butler servers will have the same hostname but live under different paths. --- .../daf/butler/remote_butler/_remote_butler.py | 14 ++++++-------- tests/test_server.py | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/python/lsst/daf/butler/remote_butler/_remote_butler.py b/python/lsst/daf/butler/remote_butler/_remote_butler.py index ccb79768ad..841735a28b 100644 --- a/python/lsst/daf/butler/remote_butler/_remote_butler.py +++ b/python/lsst/daf/butler/remote_butler/_remote_butler.py @@ -77,9 +77,9 @@ def __init__( butler_config = ButlerConfig(config, searchPaths, without_datastore=True) # There is a convention in Butler config files where in a # configuration option refers to the directory containing the - # configuration file. We allow this for the remote butler's URL so + # configuration file. We allow this for the remote butler's URL so # that the server doesn't have to know which hostname it is being - # accessed from + # accessed from. server_url_key = ("remote_butler", "url") if server_url_key in butler_config: butler_config[server_url_key] = replaceRoot( @@ -442,20 +442,18 @@ def pruneDatasets( raise NotImplementedError() def _get_url(self, path: str, version: str = "v1") -> str: - """Form the complete path to an endpoint on the server + """Form the complete path to an endpoint on the server. Parameters ---------- path : `str` - The relative path to the server endpoint. Should not include the - "/butler" prefix. + The relative path to the server endpoint. version : `str`, optional Version string to prepend to path. Defaults to "v1". Returns ------- path : `str` - The full path to the endpoint + The full path to the endpoint. """ - prefix = "butler" - return f"{prefix}/{version}/{path}" + return f"{version}/{path}" diff --git a/tests/test_server.py b/tests/test_server.py index 2b0fe69350..2adc161aec 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -85,6 +85,7 @@ def create_factory_dependency(): # Set up the RemoteButler that will connect to the server cls.client = TestClient(app) + cls.client.base_url = "http://text.example/butler/" cls.butler = _make_remote_butler(cls.client) # Populate the test server.