Skip to content

Commit

Permalink
Make "/butler" URL prefix variable in client
Browse files Browse the repository at this point in the history
For phalanx deployments, all butler servers will have the same hostname but live under different paths.
  • Loading branch information
dhirving committed Nov 3, 2023
1 parent 9d6569e commit 39e8b47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
14 changes: 6 additions & 8 deletions python/lsst/daf/butler/remote_butler/_remote_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def __init__(
butler_config = ButlerConfig(config, searchPaths, without_datastore=True)
# There is a convention in Butler config files where <butlerRoot> 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(
Expand Down Expand Up @@ -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}"
1 change: 1 addition & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 39e8b47

Please sign in to comment.