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 | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.daf.persistence.repositoryCfg.RepositoryCfg Class Reference
Inheritance diagram for lsst.daf.persistence.repositoryCfg.RepositoryCfg:

Public Member Functions

def __init__ (self, root, mapper, mapperArgs, parents, policy)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def extend (self, other)
 
def extendParents (self, newParents)
 
def root (self)
 
def root (self, root)
 
def mapper (self)
 
def mapper (self, mapper)
 
def mapperArgs (self)
 
def mapperArgs (self, newDict)
 
def parents (self)
 
def addParents (self, newParents)
 
def policy (self)
 
def matchesArgs (self, repositoryArgs)
 
def __repr__ (self)
 

Static Public Member Functions

def v1Constructor (loader, node)
 
def makeFromArgs (repositoryArgs)
 

Public Attributes

 dirty
 
 root
 
 mapper
 
 mapperArgs
 
 parents
 
 policy
 

Static Public Attributes

string yaml_tag = u"!RepositoryCfg_v1"
 

Detailed Description

RepositoryCfg stores the configuration of a repository. Its contents are persisted to the repository
when the repository is created in persistent storage. Thereafter the the RepositoryCfg should not change.

Parameters
----------
mapper : string
    The mapper associated with the repository. The string should be importable to a class object.
mapperArgs : dict
    Arguments & values to pass to the mapper when initializing it.
parents : list of URI
    URIs to the locaiton of the parent RepositoryCfgs of this repository.
policy : dict
    Policy associated with this repository, overrides all other policy data (which may be loaded from
    policies in derived packages).
deserializing : bool
    Butler internal use only. This flag is used to indicate to the init funciton that the repository class
    is being deserialized and should not perform certain operations that normally happen in other uses of
    init.

Definition at line 32 of file repositoryCfg.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.__init__ (   self,
  root,
  mapper,
  mapperArgs,
  parents,
  policy 
)

Definition at line 54 of file repositoryCfg.py.

54  def __init__(self, root, mapper, mapperArgs, parents, policy):
55  self._root = root
56  self._mapper = mapper
57  self._mapperArgs = {} if mapperArgs is None else mapperArgs
58  self._parents = []
59  self.addParents(iterify(parents))
60  self._policy = policy
61  self.dirty = True # if dirty, the parameters have been changed since the cfg was read or written.
62 

Member Function Documentation

◆ __eq__()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.__eq__ (   self,
  other 
)

Definition at line 93 of file repositoryCfg.py.

93  def __eq__(self, other):
94  if not other:
95  return False
96  return self.root == other.root and \
97  self.mapper == other.mapper and \
98  self.mapperArgs == other.mapperArgs and \
99  self.parents == other.parents and \
100  self.policy == other.policy
101 

◆ __ne__()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.__ne__ (   self,
  other 
)

Definition at line 102 of file repositoryCfg.py.

102  def __ne__(self, other):
103  return not self.__eq__(other)
104 

◆ __repr__()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.__repr__ (   self)

Definition at line 309 of file repositoryCfg.py.

309  def __repr__(self):
310  return "%s(root=%r, mapper=%r, mapperArgs=%r, parents=%s, policy=%s)" % (
311  self.__class__.__name__,
312  self._root,
313  self._mapper,
314  self._mapperArgs,
315  self._parents,
316  self._policy)
317 
318 

◆ addParents()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.addParents (   self,
  newParents 
)
Add a parent or list of parents to this RepositoryCfg

Parameters
----------
newParents : string or RepositoryCfg instance, or list of these.
    If string, newParents should be a path or URI to the parent
    repository. If RepositoryCfg, newParents should be a RepositoryCfg
    that describes the parent repository in part or whole.

Definition at line 255 of file repositoryCfg.py.

255  def addParents(self, newParents):
256  """Add a parent or list of parents to this RepositoryCfg
257 
258  Parameters
259  ----------
260  newParents : string or RepositoryCfg instance, or list of these.
261  If string, newParents should be a path or URI to the parent
262  repository. If RepositoryCfg, newParents should be a RepositoryCfg
263  that describes the parent repository in part or whole.
264  """
265  newParents = self._normalizeParents(self.root, newParents)
266  for newParent in newParents:
267  if newParent not in self._parents:
268  self.dirty = True
269  self._parents.append(newParent)
270 
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

◆ extend()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.extend (   self,
  other 
)
Extend this RepositoryCfg with extendable values from the other RepositoryCfg.

Currently the only extendable value is parents; see `extendParents` for more detials about extending
the parents list.

Parameters
----------
other : RepositoryCfg
    A RepositoryCfg instance to update values from.

Raises
------
RuntimeError
    If non-extendable parameters do not match a RuntimeError will be raised.
    (If this RepositoryCfg's parents can not be extended with the parents of the other repository,
    extendParents will raise).

Definition at line 105 of file repositoryCfg.py.

105  def extend(self, other):
106  """Extend this RepositoryCfg with extendable values from the other RepositoryCfg.
107 
108  Currently the only extendable value is parents; see `extendParents` for more detials about extending
109  the parents list.
110 
111  Parameters
112  ----------
113  other : RepositoryCfg
114  A RepositoryCfg instance to update values from.
115 
116  Raises
117  ------
118  RuntimeError
119  If non-extendable parameters do not match a RuntimeError will be raised.
120  (If this RepositoryCfg's parents can not be extended with the parents of the other repository,
121  extendParents will raise).
122  """
123  if (self.root != other.root
124  or self.mapper != other.mapper
125  or self.mapperArgs != other.mapperArgs
126  or self.policy != other.policy):
127  raise RuntimeError("{} can not be extended with cfg:{}".format(self, other))
128  self.extendParents(other.parents)
129 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ extendParents()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.extendParents (   self,
  newParents 
)
Determine if a parents list matches our parents list, with extra items at the end. If a list of
parents does not match but the mismatch is because of new parents at the end of the list, then they
can be added to the cfg.

Parameters
----------
newParents : list of string
    A list of parents that contains all the parents that are to be recorded into this RepositoryCfg.
    This must include parents that may already be in this RepositoryCfg's parents list

Raises
------
ParentsListMismatch
    Description

Definition at line 149 of file repositoryCfg.py.

149  def extendParents(self, newParents):
150  """Determine if a parents list matches our parents list, with extra items at the end. If a list of
151  parents does not match but the mismatch is because of new parents at the end of the list, then they
152  can be added to the cfg.
153 
154  Parameters
155  ----------
156  newParents : list of string
157  A list of parents that contains all the parents that are to be recorded into this RepositoryCfg.
158  This must include parents that may already be in this RepositoryCfg's parents list
159 
160  Raises
161  ------
162  ParentsListMismatch
163  Description
164  """
165  newParents = self._normalizeParents(self.root, newParents)
166  doRaise = False
167  if self._parents != newParents:
168  if all(x == y for (x, y) in zip(self._parents, newParents)):
169  if len(self._parents) < len(newParents):
170  self._parents = newParents
171  self.dirty = True
172  elif len(self._parents) == len(newParents):
173  pass
174  else:
175  doRaise = True
176  else:
177  doRaise = True
178  if doRaise:
179  raise ParentsMismatch(("The beginning of the passed-in parents list: {} does not match the "
180  "existing parents list in this RepositoryCfg: {}").format(
181  newParents, self._parents))
182 
bool all(CoordinateExpr< N > const &expr) noexcept
Return true if all elements are true.

◆ makeFromArgs()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.makeFromArgs (   repositoryArgs)
static

Definition at line 276 of file repositoryCfg.py.

276  def makeFromArgs(repositoryArgs):
277  cfg = RepositoryCfg(root=repositoryArgs.root,
278  mapper=repositoryArgs.mapper,
279  mapperArgs=repositoryArgs.mapperArgs,
280  parents=None,
281  policy=repositoryArgs.policy)
282  return cfg
283 

◆ mapper() [1/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapper (   self)

Definition at line 194 of file repositoryCfg.py.

194  def mapper(self):
195  return self._mapper
196 
SchemaMapper * mapper
Definition: SchemaMapper.cc:71

◆ mapper() [2/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapper (   self,
  mapper 
)

Definition at line 198 of file repositoryCfg.py.

198  def mapper(self, mapper):
199  if self._mapper is not None:
200  raise RuntimeError("Should not set mapper over previous not-None value.")
201  self.dirty = True
202  self._mapper = mapper
203 

◆ mapperArgs() [1/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapperArgs (   self)

Definition at line 205 of file repositoryCfg.py.

205  def mapperArgs(self):
206  return self._mapperArgs
207 

◆ mapperArgs() [2/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapperArgs (   self,
  newDict 
)

Definition at line 209 of file repositoryCfg.py.

209  def mapperArgs(self, newDict):
210  self.dirty = True
211  self._mapperArgs = newDict
212 

◆ matchesArgs()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.matchesArgs (   self,
  repositoryArgs 
)
Checks that a repositoryArgs instance will work with this repositoryCfg. This is useful
when loading an already-existing repository that has a persisted cfg, to ensure that the args that are
passed into butler do not conflict with the persisted cfg.

Definition at line 284 of file repositoryCfg.py.

284  def matchesArgs(self, repositoryArgs):
285  """Checks that a repositoryArgs instance will work with this repositoryCfg. This is useful
286  when loading an already-existing repository that has a persisted cfg, to ensure that the args that are
287  passed into butler do not conflict with the persisted cfg."""
288  if repositoryArgs.root is not None and self._root != repositoryArgs.root:
289  return False
290 
291  repoArgsMapper = repositoryArgs.mapper
292  cfgMapper = self._mapper
293  if isinstance(repoArgsMapper, str):
294  repoArgsMapper = doImport(repoArgsMapper)
295  if isinstance(cfgMapper, str):
296  cfgMapper = doImport(cfgMapper)
297  if repoArgsMapper is not None and repoArgsMapper != cfgMapper:
298  return False
299  # check mapperArgs for any keys in common and if their value does not match then return false.
300  if self._mapperArgs is not None and repositoryArgs.mapperArgs is not None:
301  for key in set(self._mapperArgs.keys()) & set(repositoryArgs.mapperArgs):
302  if self._mapperArgs[key] != repositoryArgs.mapperArgs[key]:
303  return False
304  if repositoryArgs.policy and repositoryArgs.policy != self._policy:
305  return False
306 
307  return True
308 
daf::base::PropertySet * set
Definition: fits.cc:912

◆ parents()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.parents (   self)

Definition at line 214 of file repositoryCfg.py.

214  def parents(self):
215  return self._denormalizeParents(self.root, self._parents)
216 

◆ policy()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.policy (   self)

Definition at line 272 of file repositoryCfg.py.

272  def policy(self):
273  return self._policy
274 

◆ root() [1/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.root (   self)

Definition at line 184 of file repositoryCfg.py.

184  def root(self):
185  return self._root
186 

◆ root() [2/2]

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.root (   self,
  root 
)

Definition at line 188 of file repositoryCfg.py.

188  def root(self, root):
189  if root is not None and self._root is not None:
190  raise RuntimeError("Explicity clear root (set to None) before changing the value of root.")
191  self._root = root
192 

◆ v1Constructor()

def lsst.daf.persistence.repositoryCfg.RepositoryCfg.v1Constructor (   loader,
  node 
)
static
Constructor for 'version 1' of the serlized RepositoryCfg.

If new parameters are added to RepositoryCfg they will have to be checked for in d; if they are there
then their value should be used and if they are not there a default value must be used in place.

In case the structure of the serialzed file must be changed in a way that invalidates some of the
keys:
1. Increment the version number (after _v1) in the yaml_tag of this class.
2. Add a new constructor (similar to this one) to deserialze new serializations of this class.
3. Registered the new constructor for the new version with yaml, the same way it is done at the bottom
   of this file.
4. All constructors for the older version(s) of persisted RepositoryCfg must be changed to adapt
   the old keys to their new uses and create the current (new) version of a repository cfg, or raise a
   RuntimeError in the case that older versions of serialized RepositoryCfgs can not be adapted.
There is an example of migrating from a fictitious v0 to v1 in tests/repositoryCfg.py

Definition at line 64 of file repositoryCfg.py.

64  def v1Constructor(loader, node):
65  """Constructor for 'version 1' of the serlized RepositoryCfg.
66 
67  If new parameters are added to RepositoryCfg they will have to be checked for in d; if they are there
68  then their value should be used and if they are not there a default value must be used in place.
69 
70  In case the structure of the serialzed file must be changed in a way that invalidates some of the
71  keys:
72  1. Increment the version number (after _v1) in the yaml_tag of this class.
73  2. Add a new constructor (similar to this one) to deserialze new serializations of this class.
74  3. Registered the new constructor for the new version with yaml, the same way it is done at the bottom
75  of this file.
76  4. All constructors for the older version(s) of persisted RepositoryCfg must be changed to adapt
77  the old keys to their new uses and create the current (new) version of a repository cfg, or raise a
78  RuntimeError in the case that older versions of serialized RepositoryCfgs can not be adapted.
79  There is an example of migrating from a fictitious v0 to v1 in tests/repositoryCfg.py
80  """
81  d = loader.construct_mapping(node)
82  cfg = RepositoryCfg(root=d['_root'], mapper=d['_mapper'], mapperArgs=d['_mapperArgs'],
83  parents=[], policy=d.get('_policy', None))
84  # Where possible we mangle the parents so that they are relative to root, for example if the root and
85  # the parents are both in the same PosixStorage. The parents are serialized in mangled form; when
86  # deserializing the parents we do not re-mangle them.
87  cfg._parents = d['_parents']
88  if cfg._parents is None:
89  cfg._parents = []
90  cfg.dirty = False
91  return cfg
92 

Member Data Documentation

◆ dirty

lsst.daf.persistence.repositoryCfg.RepositoryCfg.dirty

Definition at line 61 of file repositoryCfg.py.

◆ mapper

lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapper

Definition at line 97 of file repositoryCfg.py.

◆ mapperArgs

lsst.daf.persistence.repositoryCfg.RepositoryCfg.mapperArgs

Definition at line 98 of file repositoryCfg.py.

◆ parents

lsst.daf.persistence.repositoryCfg.RepositoryCfg.parents

Definition at line 99 of file repositoryCfg.py.

◆ policy

lsst.daf.persistence.repositoryCfg.RepositoryCfg.policy

Definition at line 100 of file repositoryCfg.py.

◆ root

lsst.daf.persistence.repositoryCfg.RepositoryCfg.root

Definition at line 96 of file repositoryCfg.py.

◆ yaml_tag

string lsst.daf.persistence.repositoryCfg.RepositoryCfg.yaml_tag = u"!RepositoryCfg_v1"
static

Definition at line 52 of file repositoryCfg.py.


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