Skip to content

Commit

Permalink
Add remote registry getDatasetLocations
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 20, 2023
1 parent 9359e02 commit 98b18dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/lsst/daf/butler/registries/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ def getDatastoreBridgeManager(self) -> DatastoreRegistryBridgeManager:

def getDatasetLocations(self, ref: DatasetRef) -> Iterable[str]:
# Docstring inherited from lsst.daf.butler.registry.Registry
raise NotImplementedError()
path = f"v1/registry/datasetLocations/{ref.id}"
response = self._client.get(self._get_url(path))
response.raise_for_status()
return response.json()

def expandDataId(
self,
Expand Down
15 changes: 14 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import os.path
import unittest
import uuid

try:
import lsst.daf.butler.server
Expand All @@ -31,7 +32,7 @@
from fastapi.testclient import TestClient
except ImportError:
TestClient = None
from lsst.daf.butler import Butler, Config, DataCoordinate
from lsst.daf.butler import Butler, Config, DataCoordinate, DatasetRef

try:
from lsst.daf.butler.server import app
Expand Down Expand Up @@ -111,6 +112,18 @@ def test_registry(self):
ref = self.butler.registry.getDataset(datasets[0].id)
self.assertEqual(ref, datasets[0])

locations = self.butler.registry.getDatasetLocations(ref)
self.assertEqual(locations[0], "FileDatastore@<butlerRoot>")

fake_ref = DatasetRef(
dataset_type,
dataId={"instrument": "DummyCamComp", "physical_filter": "d-r", "visit": 424},
id=uuid.uuid4(),
run="missing",
)
locations = self.butler.registry.getDatasetLocations(fake_ref)
self.assertEqual(locations, [])

dataIds = list(self.butler.registry.queryDataIds("visit", dataId={"instrument": "DummyCamComp"}))
self.assertEqual(len(dataIds), 2)

Expand Down

0 comments on commit 98b18dd

Please sign in to comment.