LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Functions
lsst.pex.harness.Utils Namespace Reference

Functions

def createAdditionalData
 
def propertySetToDict
 

Function Documentation

def lsst.pex.harness.Utils.createAdditionalData (   stage,
  stagePolicy,
  clipboard 
)
Extract additionalData values, as specified by policy, from the clipboard.
Also create predefined keys for runId, sliceId, and universeSize.
This routine no longer performs slice-to-CCD mappings as of DC3a.
Instead, they are now performed in the SliceInfoStage.

Definition at line 31 of file Utils.py.

31 
32 def createAdditionalData(stage, stagePolicy, clipboard):
33  """
34  Extract additionalData values, as specified by policy, from the clipboard.
35  Also create predefined keys for runId, sliceId, and universeSize.
36  This routine no longer performs slice-to-CCD mappings as of DC3a.
37  Instead, they are now performed in the SliceInfoStage.
38  """
39 
40  additionalData = lsst.daf.base.PropertySet()
41  # Parse array of "key=clipboard-key" or
42  # "key=clipboard-key.dataproperty-key" mappings
43  if stagePolicy.exists('parameters.additionalData'):
44  dataPairs = stagePolicy.getStringArray('parameters.additionalData')
45  for pair in dataPairs:
46  (rename, name) = pair.split("=")
47  if name.find(".") != -1:
48  (clipKey, psKey) = name.split(".", 1)
49  cprops = clipboard.get(clipKey)
50  if cprops is None:
51  raise RuntimeError, \
52  "Expected data not found on clipboard: "+ clipKey
53  if isinstance(cprops, dict):
54  additionalData.set(rename, cprops[psKey])
55  elif isinstance(cprops, lsst.daf.base.PropertySet):
56  additionalData.copy(rename, cprops, psKey)
57  else:
58  raise RuntimeError, \
59  "Unknown data type (not dict or PropertySet) found on clipboard: "+ clipKey
60  else:
61  cprops = clipboard.get(name)
62  if cprops is None:
63  raise RuntimeError, \
64  "Expected data not found on clipboard: "+ name
65  additionalData.set(rename, clipboard.get(name))
66  lsst.pex.logging.Trace("pex.harness.Utils.createAdditionalData", 3, \
67  "AdditionalData item: " + pair)
68 
69  # Add the predefined runId, sliceId, and universeSize keys
70 
71  additionalData.set('runId', stage.getRun())
72  additionalData.setInt('sliceId', stage.getRank())
73  additionalData.setInt('universeSize', stage.getUniverseSize())
74 
75  lsst.pex.logging.Trace("pex.harness.Utils.createAdditionalData", 3, \
76  "additionalData:\n" + additionalData.toString(False))
77 
78  return additionalData
limited backward compatibility to the DC2 run-time trace facilities
Definition: Trace.h:93
Class for storing generic metadata.
Definition: PropertySet.h:82
def lsst.pex.harness.Utils.propertySetToDict (   propertySet)
Convert a PropertySet to a Python dictionary.

Definition at line 79 of file Utils.py.

79 
80 def propertySetToDict(propertySet):
81  """
82  Convert a PropertySet to a Python dictionary.
83  """
84  dict = {}
85  for i in propertySet.names():
86  dict[i] = propertySet.get(i)
87  return dict