Skip to content

Commit

Permalink
Implement collections and run in RemoteButler
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirving committed Oct 25, 2023
1 parent c8c1681 commit 7eab7d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions python/lsst/daf/butler/remote_butler/_remote_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from .._storage_class import StorageClass
from ..datastore import DatasetRefURIs
from ..dimensions import DataId, DimensionConfig, DimensionUniverse
from ..registry import Registry
from ..registry import Registry, RegistryDefaults
from ..transfers import RepoExportContext
from ._config import RemoteButlerConfigModel

Expand All @@ -57,14 +57,21 @@ def __init__(
# These parameters are inherited from the Butler() constructor
config: Config | ResourcePathExpression | None = None,
*,
collections: Any = None,
run: str | None = None,
searchPaths: Sequence[ResourcePathExpression] | None = None,
writeable: bool | None = None,
inferDefaults: bool = True,
# Parameters unique to RemoteButler
http_client: httpx.Client | None = None,
**kwargs: Any,
):
butler_config = ButlerConfig(config, searchPaths, without_datastore=True)
self._config = RemoteButlerConfigModel.model_validate(butler_config)
self._dimensions: DimensionUniverse | None = None
# TODO: RegistryDefaults should have finish() called on it, but this
# requires getCollectionSummary() which is not yet implemented
self._registry_defaults = RegistryDefaults(collections, run, inferDefaults, **kwargs)

if http_client is not None:
# We have injected a client explicitly in to the class.
Expand Down Expand Up @@ -266,12 +273,12 @@ def validateConfiguration(
@property
def collections(self) -> Sequence[str]:
# Docstring inherited.
raise NotImplementedError()
return self._registry_defaults.collections

@property
def run(self) -> str | None:
# Docstring inherited.
raise NotImplementedError()
return self._registry_defaults.run

@property
def registry(self) -> Registry:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_remote_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ def test_instantiate_via_butler(self):
{
"cls": "lsst.daf.butler.remote_butler.RemoteButler",
"remote_butler": {"url": "https://validurl.example"},
}
},
collections=["collection1", "collection2"],
run="collection2",
)
assert isinstance(butler, RemoteButler)
self.assertEqual(butler.collections, ("collection1", "collection2"))
self.assertEqual(butler.run, "collection2")

def test_bad_config(self):
with self.assertRaises(ValidationError):
Expand Down

0 comments on commit 7eab7d5

Please sign in to comment.