LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst.daf.persistence.repository.Repository Class Reference
Inheritance diagram for lsst.daf.persistence.repository.Repository:

Public Member Functions

def __init__ (self, repoData)
 
def write (self, butlerLocation, obj)
 
def read (self, butlerLocation)
 
def mappers (self)
 Mapper Access #. More...
 
def getRegistry (self)
 
def getKeys (self, args, kwargs)
 
def map (self, args, kwargs)
 
def queryMetadata (self, args, kwargs)
 
def backup (self, args, kwargs)
 
def getMapperDefaultLevel (self)
 
def exists (self, location)
 

Detailed Description

Represents a repository of persisted data and has methods to access that data.

Definition at line 127 of file repository.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.daf.persistence.repository.Repository.__init__ (   self,
  repoData 
)
Initialize a Repository with parameters input via RepoData.

Parameters
----------
repoData : RepoData
    Object that contains the parameters with which to init the Repository.

Definition at line 131 of file repository.py.

131  def __init__(self, repoData):
132  """Initialize a Repository with parameters input via RepoData.
133 
134  Parameters
135  ----------
136  repoData : RepoData
137  Object that contains the parameters with which to init the Repository.
138  """
139  self._storage = Storage.makeFromURI(repoData.cfg.root)
140  if repoData.cfg.dirty and not repoData.isV1Repository and repoData.cfgOrigin != 'nested':
141  self._storage.putRepositoryCfg(repoData.cfg, repoData.cfgRoot)
142  self._mapperArgs = repoData.cfg.mapperArgs # keep for reference in matchesArgs
143  self._initMapper(repoData)
144 
def __init__(self, minimum, dataRange, Q)

Member Function Documentation

◆ backup()

def lsst.daf.persistence.repository.Repository.backup (   self,
  args,
  kwargs 
)
Perform mapper.backup.

See mapper.backup for more information about args and kwargs.

:param args: arguments to be passed on to mapper.backup
:param kwargs: keyword arguments to be passed on to mapper.backup
:return: None

Definition at line 263 of file repository.py.

263  def backup(self, *args, **kwargs):
264  """Perform mapper.backup.
265 
266  See mapper.backup for more information about args and kwargs.
267 
268  :param args: arguments to be passed on to mapper.backup
269  :param kwargs: keyword arguments to be passed on to mapper.backup
270  :return: None
271  """
272  if self._mapper is None:
273  return None
274  self._mapper.backup(*args, **kwargs)
275 

◆ exists()

def lsst.daf.persistence.repository.Repository.exists (   self,
  location 
)
Check if location exists in storage.

Parameters
----------
location : ButlerLocation
    Desrcibes a location in storage to look for.

Returns
-------
bool
    True if location exists, False if not.

Definition at line 291 of file repository.py.

291  def exists(self, location):
292  """Check if location exists in storage.
293 
294  Parameters
295  ----------
296  location : ButlerLocation
297  Desrcibes a location in storage to look for.
298 
299  Returns
300  -------
301  bool
302  True if location exists, False if not.
303  """
304  butlerLocationStorage = location.getStorage()
305  if butlerLocationStorage:
306  return butlerLocationStorage.exists(location)
307  else:
308  return self._storage.exists(location)
309 

◆ getKeys()

def lsst.daf.persistence.repository.Repository.getKeys (   self,
  args,
  kwargs 
)
Get the keys available in the repository/repositories.
:param args:
:param kwargs:
:return: A dict of {key:valueType}

Definition at line 219 of file repository.py.

219  def getKeys(self, *args, **kwargs):
220  """
221  Get the keys available in the repository/repositories.
222  :param args:
223  :param kwargs:
224  :return: A dict of {key:valueType}
225  """
226  # todo: getKeys is not in the mapper API
227  if self._mapper is None:
228  return None
229  keys = self._mapper.getKeys(*args, **kwargs)
230  return keys
231 

◆ getMapperDefaultLevel()

def lsst.daf.persistence.repository.Repository.getMapperDefaultLevel (   self)
Get the default level of the mapper.

This is typically used if no level is passed into butler methods that call repository.getKeys and/or
repository.queryMetadata. There is a bug in that code because it gets the default level from this
repository but then uses that value when searching all repositories. If this and other repositories
have dissimilar data, the default level value will be nonsensical. A good example of this issue is in
Butler.subset; it needs refactoring.

:return:

Definition at line 276 of file repository.py.

276  def getMapperDefaultLevel(self):
277  """Get the default level of the mapper.
278 
279  This is typically used if no level is passed into butler methods that call repository.getKeys and/or
280  repository.queryMetadata. There is a bug in that code because it gets the default level from this
281  repository but then uses that value when searching all repositories. If this and other repositories
282  have dissimilar data, the default level value will be nonsensical. A good example of this issue is in
283  Butler.subset; it needs refactoring.
284 
285  :return:
286  """
287  if self._mapper is None:
288  return None
289  return self._mapper.getDefaultLevel()
290 

◆ getRegistry()

def lsst.daf.persistence.repository.Repository.getRegistry (   self)
Get the registry from the mapper

Returns
-------
Registry or None
    The registry from the mapper or None if the mapper does not have one.

Definition at line 207 of file repository.py.

207  def getRegistry(self):
208  """Get the registry from the mapper
209 
210  Returns
211  -------
212  Registry or None
213  The registry from the mapper or None if the mapper does not have one.
214  """
215  if self._mapper is None:
216  return None
217  return self._mapper.getRegistry()
218 

◆ map()

def lsst.daf.persistence.repository.Repository.map (   self,
  args,
  kwargs 
)
Find a butler location for the given arguments.
See mapper.map for more information about args and kwargs.

:param args: arguments to be passed on to mapper.map
:param kwargs: keyword arguments to be passed on to mapper.map
:return: The type of item is dependent on the mapper being used but is typically a ButlerLocation.

Definition at line 232 of file repository.py.

232  def map(self, *args, **kwargs):
233  """Find a butler location for the given arguments.
234  See mapper.map for more information about args and kwargs.
235 
236  :param args: arguments to be passed on to mapper.map
237  :param kwargs: keyword arguments to be passed on to mapper.map
238  :return: The type of item is dependent on the mapper being used but is typically a ButlerLocation.
239  """
240  if self._mapper is None:
241  raise RuntimeError("No mapper assigned to Repository")
242  loc = self._mapper.map(*args, **kwargs)
243  if not loc:
244  return None
245  loc.setRepository(self)
246  return loc
247 

◆ mappers()

def lsst.daf.persistence.repository.Repository.mappers (   self)

Mapper Access #.

Definition at line 204 of file repository.py.

204  def mappers(self):
205  return (self._mapper, )
206 

◆ queryMetadata()

def lsst.daf.persistence.repository.Repository.queryMetadata (   self,
  args,
  kwargs 
)
Gets possible values for keys given a partial data id.

See mapper documentation for more explanation about queryMetadata.

:param args: arguments to be passed on to mapper.queryMetadata
:param kwargs: keyword arguments to be passed on to mapper.queryMetadata
:return:The type of item is dependent on the mapper being used but is typically a set that contains
available values for the keys in the format input argument.

Definition at line 248 of file repository.py.

248  def queryMetadata(self, *args, **kwargs):
249  """Gets possible values for keys given a partial data id.
250 
251  See mapper documentation for more explanation about queryMetadata.
252 
253  :param args: arguments to be passed on to mapper.queryMetadata
254  :param kwargs: keyword arguments to be passed on to mapper.queryMetadata
255  :return:The type of item is dependent on the mapper being used but is typically a set that contains
256  available values for the keys in the format input argument.
257  """
258  if self._mapper is None:
259  return None
260  ret = self._mapper.queryMetadata(*args, **kwargs)
261  return ret
262 

◆ read()

def lsst.daf.persistence.repository.Repository.read (   self,
  butlerLocation 
)
Read a dataset from Storage.

:param butlerLocation: Contains the details needed to find the desired dataset.
:return: An instance of the dataset requested by butlerLocation.

Definition at line 189 of file repository.py.

189  def read(self, butlerLocation):
190  """Read a dataset from Storage.
191 
192  :param butlerLocation: Contains the details needed to find the desired dataset.
193  :return: An instance of the dataset requested by butlerLocation.
194  """
195  butlerLocationStorage = butlerLocation.getStorage()
196  if butlerLocationStorage:
197  return butlerLocationStorage.read(butlerLocation)
198  else:
199  return self._storage.read(butlerLocation)
200 

◆ write()

def lsst.daf.persistence.repository.Repository.write (   self,
  butlerLocation,
  obj 
)
Write a dataset to Storage.

:param butlerLocation: Contains the details needed to find the desired dataset.
:param dataset: The dataset to be written.
:return:

Definition at line 176 of file repository.py.

176  def write(self, butlerLocation, obj):
177  """Write a dataset to Storage.
178 
179  :param butlerLocation: Contains the details needed to find the desired dataset.
180  :param dataset: The dataset to be written.
181  :return:
182  """
183  butlerLocationStorage = butlerLocation.getStorage()
184  if butlerLocationStorage:
185  return butlerLocationStorage.write(butlerLocation, obj)
186  else:
187  return self._storage.write(butlerLocation, obj)
188 

The documentation for this class was generated from the following file: