LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.daf.persistence.storageInterface.StorageInterface Class Reference
Inheritance diagram for lsst.daf.persistence.storageInterface.StorageInterface:
lsst.daf.persistence.posixStorage.PosixStorage

Public Member Functions

def __init__ (self, uri, create)
 
def getReadFormatter (cls, objType)
 
def getWriteFormatter (cls, objType)
 
def registerFormatters (cls, formatable, readFormatter=None, writeFormatter=None)
 
def write (self, butlerLocation, obj)
 
def read (self, butlerLocation)
 
def getLocalFile (self, path)
 
def exists (self, location)
 
def instanceSearch (self, path)
 
def search (cls, root, path)
 
def copyFile (self, fromLocation, toLocation)
 
def locationWithRoot (self, location)
 
def getRepositoryCfg (cls, uri)
 
def putRepositoryCfg (cls, cfg, loc=None)
 
def getMapperClass (cls, root)
 
def relativePath (cls, fromPath, toPath)
 
def absolutePath (cls, fromPath, relativePath)
 

Detailed Description

Defines the interface for a connection to a Storage location.

Parameters
----------
uri : string
    URI or path that is used as the storage location.
create : bool
    If True The StorageInterface subclass should create a new
    repository at the root location. If False then a new repository
    will not be created.

Raises
------
NoRepositroyAtRoot
    If create is False and a repository does not exist at the root
    specified by uri then NoRepositroyAtRoot is raised.

Definition at line 31 of file storageInterface.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.daf.persistence.storageInterface.StorageInterface.__init__ (   self,
  uri,
  create 
)
initialzer

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 51 of file storageInterface.py.

51  def __init__(self, uri, create):
52  """initialzer"""
53  pass
54 

Member Function Documentation

◆ absolutePath()

def lsst.daf.persistence.storageInterface.StorageInterface.absolutePath (   cls,
  fromPath,
  relativePath 
)
Get an absolute path for the path from fromUri to toUri

Parameters
----------
fromPath : the starting location
    A location at which to start. It can be a relative path or an
    absolute path.
relativePath : the location relative to fromPath
    A relative path.

Returns
-------
string
    Path that is an absolute path representation of fromPath +
    relativePath, if one exists. If relativePath is absolute or if
    fromPath is not related to relativePath then relativePath will be
    returned.

Definition at line 373 of file storageInterface.py.

373  def absolutePath(cls, fromPath, relativePath):
374  """Get an absolute path for the path from fromUri to toUri
375 
376  Parameters
377  ----------
378  fromPath : the starting location
379  A location at which to start. It can be a relative path or an
380  absolute path.
381  relativePath : the location relative to fromPath
382  A relative path.
383 
384  Returns
385  -------
386  string
387  Path that is an absolute path representation of fromPath +
388  relativePath, if one exists. If relativePath is absolute or if
389  fromPath is not related to relativePath then relativePath will be
390  returned.
391  """
392  return relativePath

◆ copyFile()

def lsst.daf.persistence.storageInterface.StorageInterface.copyFile (   self,
  fromLocation,
  toLocation 
)
Copy a file from one location to another on the local filesystem.

Parameters
----------
fromLocation : string
    Path and name of existing file.
 toLocation : string
    Path and name of new file.

Returns
-------
None

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 261 of file storageInterface.py.

261  def copyFile(self, fromLocation, toLocation):
262  """Copy a file from one location to another on the local filesystem.
263 
264  Parameters
265  ----------
266  fromLocation : string
267  Path and name of existing file.
268  toLocation : string
269  Path and name of new file.
270 
271  Returns
272  -------
273  None
274  """
275 

◆ exists()

def lsst.daf.persistence.storageInterface.StorageInterface.exists (   self,
  location 
)
Check if location exists.

Parameters
----------
location : ButlerLocation or string
    A a string or a ButlerLocation that describes the location of an
    object in this storage.

Returns
-------
bool
    True if exists, else False.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 199 of file storageInterface.py.

199  def exists(self, location):
200  """Check if location exists.
201 
202  Parameters
203  ----------
204  location : ButlerLocation or string
205  A a string or a ButlerLocation that describes the location of an
206  object in this storage.
207 
208  Returns
209  -------
210  bool
211  True if exists, else False.
212  """
213 

◆ getLocalFile()

def lsst.daf.persistence.storageInterface.StorageInterface.getLocalFile (   self,
  path 
)
Get a handle to a local copy of the file, downloading it to a
temporary if needed.

Parameters
----------
path : string
    A path to the the file in storage, relative to root.

Returns
-------
A handle to a local copy of the file. If storage is remote it will be
a temporary file. If storage is local it may be the original file or
a temporary file. The file name can be gotten via the 'name' property
of the returned object.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 181 of file storageInterface.py.

181  def getLocalFile(self, path):
182  """Get a handle to a local copy of the file, downloading it to a
183  temporary if needed.
184 
185  Parameters
186  ----------
187  path : string
188  A path to the the file in storage, relative to root.
189 
190  Returns
191  -------
192  A handle to a local copy of the file. If storage is remote it will be
193  a temporary file. If storage is local it may be the original file or
194  a temporary file. The file name can be gotten via the 'name' property
195  of the returned object.
196  """
197 

◆ getMapperClass()

def lsst.daf.persistence.storageInterface.StorageInterface.getMapperClass (   cls,
  root 
)
Get the mapper class associated with a repository root.

Parameters
----------
root : string
    The location of a persisted RepositoryCfg is (new style repos).

Returns
-------
A class object or a class instance, depending on the state of the
mapper when the repository was created.

Definition at line 333 of file storageInterface.py.

333  def getMapperClass(cls, root):
334  """Get the mapper class associated with a repository root.
335 
336  Parameters
337  ----------
338  root : string
339  The location of a persisted RepositoryCfg is (new style repos).
340 
341  Returns
342  -------
343  A class object or a class instance, depending on the state of the
344  mapper when the repository was created.
345  """
346 

◆ getReadFormatter()

def lsst.daf.persistence.storageInterface.StorageInterface.getReadFormatter (   cls,
  objType 
)
Search in the registered formatters for the objType read formatter.

Parameters
----------
objType : class type
    The type of class to find a formatter for.

Returns
-------
formatter callable
    The formatter callable used to read the object from the storageInterface.

Definition at line 86 of file storageInterface.py.

86  def getReadFormatter(cls, objType):
87  """Search in the registered formatters for the objType read formatter.
88 
89  Parameters
90  ----------
91  objType : class type
92  The type of class to find a formatter for.
93 
94  Returns
95  -------
96  formatter callable
97  The formatter callable used to read the object from the storageInterface.
98  """
99  return cls._readFormatters().get(objType, None)
100 

◆ getRepositoryCfg()

def lsst.daf.persistence.storageInterface.StorageInterface.getRepositoryCfg (   cls,
  uri 
)
Get a persisted RepositoryCfg

Parameters
----------
uri : URI or path to a RepositoryCfg
    Description

Returns
-------
A RepositoryCfg instance or None

Definition at line 294 of file storageInterface.py.

294  def getRepositoryCfg(cls, uri):
295  """Get a persisted RepositoryCfg
296 
297  Parameters
298  ----------
299  uri : URI or path to a RepositoryCfg
300  Description
301 
302  Returns
303  -------
304  A RepositoryCfg instance or None
305  """
306 

◆ getWriteFormatter()

def lsst.daf.persistence.storageInterface.StorageInterface.getWriteFormatter (   cls,
  objType 
)
Search in the registered formatters for the objType write formatter.

Parameters
----------
objType : class type
    The type of class to find a formatter for.

Returns
-------
formatter callable
    The formatter callable used to write the object to the storageInterface.

Definition at line 102 of file storageInterface.py.

102  def getWriteFormatter(cls, objType):
103  """Search in the registered formatters for the objType write formatter.
104 
105  Parameters
106  ----------
107  objType : class type
108  The type of class to find a formatter for.
109 
110  Returns
111  -------
112  formatter callable
113  The formatter callable used to write the object to the storageInterface.
114  """
115  return cls._writeFormatters().get(objType, None)
116 

◆ instanceSearch()

def lsst.daf.persistence.storageInterface.StorageInterface.instanceSearch (   self,
  path 
)
Search for the given path in this storage instance.

If the path contains an HDU indicator (a number in brackets before the
dot, e.g. 'foo.fits[1]', this will be stripped when searching and so
will match filenames without the HDU indicator, e.g. 'foo.fits'. The
path returned WILL contain the indicator though, e.g. ['foo.fits[1]'].

Parameters
----------
path : string
    A filename (and optionally prefix path) to search for within root.

Returns
-------
string or None
    The location that was found, or None if no location was found.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 215 of file storageInterface.py.

215  def instanceSearch(self, path):
216  """Search for the given path in this storage instance.
217 
218  If the path contains an HDU indicator (a number in brackets before the
219  dot, e.g. 'foo.fits[1]', this will be stripped when searching and so
220  will match filenames without the HDU indicator, e.g. 'foo.fits'. The
221  path returned WILL contain the indicator though, e.g. ['foo.fits[1]'].
222 
223  Parameters
224  ----------
225  path : string
226  A filename (and optionally prefix path) to search for within root.
227 
228  Returns
229  -------
230  string or None
231  The location that was found, or None if no location was found.
232  """
233 

◆ locationWithRoot()

def lsst.daf.persistence.storageInterface.StorageInterface.locationWithRoot (   self,
  location 
)
Get the full path to the location.

Parameters
----------
location : string
    Path to a location within the repository relative to repository
    root.

Returns
-------
string
    Absolute path to to the locaiton within the repository.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 277 of file storageInterface.py.

277  def locationWithRoot(self, location):
278  """Get the full path to the location.
279 
280  Parameters
281  ----------
282  location : string
283  Path to a location within the repository relative to repository
284  root.
285 
286  Returns
287  -------
288  string
289  Absolute path to to the locaiton within the repository.
290  """
291 

◆ putRepositoryCfg()

def lsst.daf.persistence.storageInterface.StorageInterface.putRepositoryCfg (   cls,
  cfg,
  loc = None 
)
Serialize a RepositoryCfg to a location.

When loc == cfg.root, the RepositoryCfg is to be written at the root
location of the repository. In that case, root is not written, it is
implicit in the location of the cfg. This allows the cfg to move from
machine to machine without modification.

Parameters
----------
cfg : RepositoryCfg instance
    The RepositoryCfg to be serailized.
loc : string, optional
    The URI location (can be relative path) to write the RepositoryCfg.
    If loc is None, the location will be read from the root parameter
    of loc.

Returns
-------
None

Definition at line 309 of file storageInterface.py.

309  def putRepositoryCfg(cls, cfg, loc=None):
310  """Serialize a RepositoryCfg to a location.
311 
312  When loc == cfg.root, the RepositoryCfg is to be written at the root
313  location of the repository. In that case, root is not written, it is
314  implicit in the location of the cfg. This allows the cfg to move from
315  machine to machine without modification.
316 
317  Parameters
318  ----------
319  cfg : RepositoryCfg instance
320  The RepositoryCfg to be serailized.
321  loc : string, optional
322  The URI location (can be relative path) to write the RepositoryCfg.
323  If loc is None, the location will be read from the root parameter
324  of loc.
325 
326  Returns
327  -------
328  None
329  """
330 

◆ read()

def lsst.daf.persistence.storageInterface.StorageInterface.read (   self,
  butlerLocation 
)
Read from a butlerLocation.

Parameters
----------
butlerLocation : ButlerLocation
    The location & formatting for the object(s) to be read.

Returns
-------
A list of objects as described by the butler location. One item for
each location in butlerLocation.getLocations()

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 166 of file storageInterface.py.

166  def read(self, butlerLocation):
167  """Read from a butlerLocation.
168 
169  Parameters
170  ----------
171  butlerLocation : ButlerLocation
172  The location & formatting for the object(s) to be read.
173 
174  Returns
175  -------
176  A list of objects as described by the butler location. One item for
177  each location in butlerLocation.getLocations()
178  """
179 
std::shared_ptr< table::io::Persistable > read(table::io::InputArchive const &archive, table::io::CatalogVector const &catalogs) const override
Definition: warpExposure.cc:0

◆ registerFormatters()

def lsst.daf.persistence.storageInterface.StorageInterface.registerFormatters (   cls,
  formatable,
  readFormatter = None,
  writeFormatter = None 
)
Register read and/or write formatters for a storageInterface subclass

Parameters
----------
cls : StorageInterface subclass
    The type of StorageInterface the formatter is being registered for.
formatable : class object
    The class object whose instances can be formatted by the formatter.
readFormatter : a read formatter callable
    The formatter function that can be used by the StorageInterface instance to read the object from
    the storage.
writeFormatter : a write formatter callable
    The formatter function that can be used by the StorageInterface instance to write the object to
    the storage.

Raises
------
RuntimeError
    For each object type and StorageInterface subclass the read and write formatters should only be
    registered once. If a second registration occurs for either a RuntimeError is raised.

Definition at line 118 of file storageInterface.py.

118  def registerFormatters(cls, formatable, readFormatter=None, writeFormatter=None):
119  """Register read and/or write formatters for a storageInterface subclass
120 
121  Parameters
122  ----------
123  cls : StorageInterface subclass
124  The type of StorageInterface the formatter is being registered for.
125  formatable : class object
126  The class object whose instances can be formatted by the formatter.
127  readFormatter : a read formatter callable
128  The formatter function that can be used by the StorageInterface instance to read the object from
129  the storage.
130  writeFormatter : a write formatter callable
131  The formatter function that can be used by the StorageInterface instance to write the object to
132  the storage.
133 
134  Raises
135  ------
136  RuntimeError
137  For each object type and StorageInterface subclass the read and write formatters should only be
138  registered once. If a second registration occurs for either a RuntimeError is raised.
139  """
140  def register(formatable, formatter, formatters, storageInterface):
141  if formatable in formatters:
142  raise RuntimeError(("Registration of second formatter {} for formattable {} in "
143  " storageInterface {}").format(formatter, formatable, storageInterface))
144  formatters[formatable] = formatter
145 
146  if readFormatter:
147  formatters = cls._readFormatters()
148  register(formatable, readFormatter, formatters, cls)
149  if writeFormatter:
150  formatters = cls._writeFormatters()
151  register(formatable, writeFormatter, formatters, cls)
152 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ relativePath()

def lsst.daf.persistence.storageInterface.StorageInterface.relativePath (   cls,
  fromPath,
  toPath 
)
Get a relative path from a location to a location.

Parameters
----------
fromPath : string
    A path at which to start. It can be a relative path or an
    absolute path.
toPath : string
    A target location. It can be a relative path or an absolute path.

Returns
-------
string
    A relative path that describes the path from fromPath to toPath.

Definition at line 351 of file storageInterface.py.

351  def relativePath(cls, fromPath, toPath):
352  """Get a relative path from a location to a location.
353 
354  Parameters
355  ----------
356  fromPath : string
357  A path at which to start. It can be a relative path or an
358  absolute path.
359  toPath : string
360  A target location. It can be a relative path or an absolute path.
361 
362  Returns
363  -------
364  string
365  A relative path that describes the path from fromPath to toPath.
366  """
367  return toPath
368 

◆ search()

def lsst.daf.persistence.storageInterface.StorageInterface.search (   cls,
  root,
  path 
)
Look for the given path in the current root.

Also supports searching for the path in Butler v1 repositories by
following the Butler v1 _parent symlink

If the path contains an HDU indicator (a number in brackets, e.g.
'foo.fits[1]', this will be stripped when searching and so
will match filenames without the HDU indicator, e.g. 'foo.fits'. The
path returned WILL contain the indicator though, e.g. ['foo.fits[1]'].

Parameters
----------
root : string
    The path to the root directory.
path : string
    The path to the file within the root directory.

Returns
-------
string or None
    The location that was found, or None if no location was found.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 236 of file storageInterface.py.

236  def search(cls, root, path):
237  """Look for the given path in the current root.
238 
239  Also supports searching for the path in Butler v1 repositories by
240  following the Butler v1 _parent symlink
241 
242  If the path contains an HDU indicator (a number in brackets, e.g.
243  'foo.fits[1]', this will be stripped when searching and so
244  will match filenames without the HDU indicator, e.g. 'foo.fits'. The
245  path returned WILL contain the indicator though, e.g. ['foo.fits[1]'].
246 
247  Parameters
248  ----------
249  root : string
250  The path to the root directory.
251  path : string
252  The path to the file within the root directory.
253 
254  Returns
255  -------
256  string or None
257  The location that was found, or None if no location was found.
258  """
259 

◆ write()

def lsst.daf.persistence.storageInterface.StorageInterface.write (   self,
  butlerLocation,
  obj 
)
Writes an object to a location and persistence format specified by ButlerLocation

Parameters
----------
butlerLocation : ButlerLocation
    The location & formatting for the object to be written.
obj : object instance
    The object to be written.

Reimplemented in lsst.daf.persistence.posixStorage.PosixStorage.

Definition at line 154 of file storageInterface.py.

154  def write(self, butlerLocation, obj):
155  """Writes an object to a location and persistence format specified by ButlerLocation
156 
157  Parameters
158  ----------
159  butlerLocation : ButlerLocation
160  The location & formatting for the object to be written.
161  obj : object instance
162  The object to be written.
163  """
164 
void write(OutputArchiveHandle &handle) const override

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