Skip to content

Commit

Permalink
Merge pull request #110 from lsst/tickets/DM-16819
Browse files Browse the repository at this point in the history
DM-16819: attribute to declare Butler generation and miscellaneous fixes.
  • Loading branch information
TallJimbo committed Dec 19, 2018
2 parents b06e05d + ac5032c commit a61fb9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion python/lsst/daf/butler/butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from .core.config import Config, ConfigSubset
from .core.butlerConfig import ButlerConfig
from .core.composites import CompositesMap
from .core.dimensions import DataId


__all__ = ("Butler",)
Expand Down Expand Up @@ -79,6 +80,14 @@ class Butler:
config, or if both are provided and are inconsistent.
"""

GENERATION = 3
"""This is a Generation 3 Butler.
This attribute may be removed in the future, once the Generation 2 Butler
interface has been fully retired; it should only be used in transitional
code.
"""

@staticmethod
def makeRepo(root, config=None, standalone=False, createRegistry=True):
"""Create an empty data repository by adding a butler.yaml config
Expand Down Expand Up @@ -437,7 +446,15 @@ def getUri(self, datasetRefOrType, dataId=None, predict=False, **kwds):
guessing is not allowed.
"""
datasetType, dataId = self._standardizeArgs(datasetRefOrType, dataId, **kwds)
ref = self.registry.find(self.collection, datasetType, dataId, **kwds)
dataId = DataId(dataId, dimensions=datasetType.dimensions, universe=self.registry.dimensions, **kwds)
ref = self.registry.find(self.collection, datasetType, dataId)
if ref is None:
if predict:
if self.run is None:
raise ValueError("Cannot predict location from read-only Butler.")
ref = DatasetRef(datasetType, dataId, run=self.run)
else:
raise FileNotFoundError(f"Dataset {datasetType} {dataId} does not exist in Registry.")
return self.datastore.getUri(ref, predict)

def datasetExists(self, datasetRefOrType, dataId=None, **kwds):
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/formatters/fitsRawFormatterBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def readFull(self, fileDescriptor, parameters=None):
full.setVariance(variance)
metadata = self.readMetadata(fileDescriptor)
info = full.getInfo()
info.setVisitInfo(self.makeVisitInfo(metadata))
info.setWcs(self.makeWcs(metadata))
info.setVisitInfo(self.makeVisitInfo(metadata))
# We shouldn't have to call stripMetadata() here because that should
# have been done by makeVisitInfo and makeWcs (or by subclasses that
# strip metadata for other components when constructing them).
Expand Down

0 comments on commit a61fb9a

Please sign in to comment.