Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-13246: Synchronize DMTN-056 with Butler prototype #6

Merged
merged 1 commit into from
Jan 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions python/lsst/butler/butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get(self, label, parameters=None):
The requested `Dataset`.
"""
assert isinstance(label, DatasetLabel)
handle = self.registry.find(self.run.tag, label)
handle = self.registry.find(self.run.collection, label)
if handle:
return self.getDirect(handle, parameters)
else:
Expand Down Expand Up @@ -148,7 +148,7 @@ def markInputUsed(self, quantum, ref):
ref : `DatasetRef`
The `Dataset` that is a true dependency of ``quantum``.
"""
handle = self.registry.find(self.run.tag, ref)
handle = self.registry.find(self.run.collection, ref)
self.registry.markInputUsed(handle, quantum)

def unlink(self, *labels):
Expand All @@ -160,7 +160,7 @@ def unlink(self, *labels):
labels : [`DatasetLabel`]
List of labels for `Dataset`s to unlink.
"""
handles = [self.registry.find(self.run.tag, label)
handles = [self.registry.find(self.run.collection, label)
for label in labels]
for handle in self.registry.disassociate(self.run.tag, handles, remove=True):
for handle in self.registry.disassociate(self.run.collection, handles, remove=True):
self.datastore.remove(handle.uri)
2 changes: 1 addition & 1 deletion python/lsst/butler/ci_hsc/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def run(filename=None, create=True, skipCamera=False, verbose=False):
db = engine.connect()
if verbose:
db.set_trace_callback(print)
db.execute("INSERT INTO Run (run_id, registry_id, tag) VALUES (0, 1, 'ingest')")
db.execute("INSERT INTO Run (run_id, registry_id, collection) VALUES (0, 1, 'ingest')")
loadTable(db, "DatasetType")
loadTable(db, "DatasetTypeUnits")
loadTable(db, "Dataset", extra={"unit_hash": "''"})
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/butler/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@ def actualConsumers(self):
return _safeMakeMappingProxyType(self._actualConsumers)

def makeStorageHint(self, run, template=None):
"""Construct a storage hint by filling in template with the Collection tag and the values in the units tuple.
"""Construct a storage hint by filling in template with the Collection collection and the values in the units tuple.

Although a `Dataset` may belong to multiple Collections, only the one corresponding to its `Run` is used.
"""
if template is None:
template = self.type.template
units = {unit.__class__.__name__: unit.value for unit in self.units}
return template.format(DatasetType=self.type.name, Run=run.tag, **units)
return template.format(DatasetType=self.type.name, Run=run.collection, **units)


class DatasetHandle(DatasetRef):
Expand Down
12 changes: 6 additions & 6 deletions python/lsst/butler/datastore/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get(self, uri, storageClass, parameters=None):
raise NotImplementedError("Must be implemented by subclass")

@abstractmethod
def put(self, inMemoryDataset, storageClass, path, typeName=None):
def put(self, inMemoryDataset, storageClass, storageHint, typeName=None):
"""Write a `InMemoryDataset` with a given `StorageClass` to the store.

Parameters
Expand All @@ -79,8 +79,8 @@ def put(self, inMemoryDataset, storageClass, path, typeName=None):
The `Dataset` to store.
storageClass : `StorageClass`
The `StorageClass` associated with the `DatasetType`.
path : `str`
A `Path` that provides a hint that the `Datastore` may use as (part of) the URI.
storageHint : `str`
Provides a hint that the `Datastore` may use as (part of) the URI.
typeName : `str`
The `DatasetType` name, which may be used by this `Datastore` to override the
default serialization format for the `StorageClass`.
Expand Down Expand Up @@ -115,7 +115,7 @@ def remove(self, uri):
raise NotImplementedError("Must be implemented by subclass")

@abstractmethod
def transfer(self, inputDatastore, inputUri, storageClass, path, typeName=None):
def transfer(self, inputDatastore, inputUri, storageClass, storageHint, typeName=None):
"""Retrieve a `Dataset` with a given `URI` from an input `Datastore`,
and store the result in this `Datastore`.

Expand All @@ -127,8 +127,8 @@ def transfer(self, inputDatastore, inputUri, storageClass, path, typeName=None):
The `URI` of the `Dataset` in the input `Datastore`.
storageClass : `StorageClass`
The `StorageClass` associated with the `DatasetType`.
path : `str`
A `Path` that provides a hint that this `Datastore` may use as [part of] the `URI`.
storageHint : `str`
Provides a hint that this `Datastore` may use as [part of] the `URI`.
typeName : `str`
The `DatasetType` name, which may be used by this `Datastore` to override the default serialization format for the `StorageClass`.

Expand Down
16 changes: 8 additions & 8 deletions python/lsst/butler/datastore/posix/datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get(self, uri, storageClass, parameters=None):
raise ValueError("No such file: {0}".format(location.uri))
return formatter.read(FileDescriptor(location, storageClass.type, parameters))

def put(self, inMemoryDataset, storageClass, path, typeName=None):
def put(self, inMemoryDataset, storageClass, storageHint, typeName=None):
"""Write a `InMemoryDataset` with a given `StorageClass` to the store.

Parameters
Expand All @@ -96,8 +96,8 @@ def put(self, inMemoryDataset, storageClass, path, typeName=None):
The `Dataset` to store.
storageClass : `StorageClass`
The `StorageClass` associated with the `DatasetType`.
path : `str`
A `Path` that provides a hint that the `Datastore` may use as (part of) the URI.
storageHint : `str`
Provides a hint that the `Datastore` may use as (part of) the URI.
typeName : `str`
The `DatasetType` name, which may be used by this `Datastore` to override the
default serialization format for the `StorageClass`.
Expand All @@ -111,7 +111,7 @@ def put(self, inMemoryDataset, storageClass, path, typeName=None):
The latter will be empty if the `Dataset` is not a composite.
"""
formatter = self.formatterFactory.getFormatter(storageClass, typeName)
location = self.locationFactory.fromPath(path)
location = self.locationFactory.fromPath(storageHint)
storageDir = os.path.dirname(location.path)
if not os.path.isdir(storageDir):
safeMakeDir(storageDir)
Expand All @@ -133,7 +133,7 @@ def remove(self, uri):
raise FileNotFoundError("No such file: {0}".format(location.uri))
os.remove(location.path)

def transfer(self, inputDatastore, inputUri, storageClass, path, typeName=None):
def transfer(self, inputDatastore, inputUri, storageClass, storageHint, typeName=None):
"""Retrieve a `Dataset` with a given `URI` from an input `Datastore`,
and store the result in this `Datastore`.

Expand All @@ -145,8 +145,8 @@ def transfer(self, inputDatastore, inputUri, storageClass, path, typeName=None):
The `URI` of the `Dataset` in the input `Datastore`.
storageClass : `StorageClass`
The `StorageClass` associated with the `DatasetType`.
path : `str`
A `Path` that provides a hint that this `Datastore` may use as [part of] the `URI`.
storageHint : `str`
Provides a hint that this `Datastore` may use as [part of] the `URI`.
typeName : `str`
The `DatasetType` name, which may be used by this `Datastore` to override the default serialization format for the `StorageClass`.

Expand All @@ -160,4 +160,4 @@ def transfer(self, inputDatastore, inputUri, storageClass, path, typeName=None):
"""
assert inputDatastore is not self # unless we want it for renames?
inMemoryDataset = inputDatastore.get(inputUri, storageClass)
return self.put(inMemoryDataset, storageClass, path, typeName)
return self.put(inMemoryDataset, storageClass, storageHint, typeName)