All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
manageDataRunDefinitions.SampleBrowser Class Reference

Public Member Functions

def __init__
 
def iterateProjectVersions
 
def iterateStreams
 
def iterateStages
 
def iterate
 
def __call__
 

Public Attributes

 samweb
 

Private Member Functions

def _discoverProjectVersions
 

Detailed Description

Definition at line 160 of file manageDataRunDefinitions.py.

Constructor & Destructor Documentation

def manageDataRunDefinitions.SampleBrowser.__init__ (   self,
  samweb 
)

Definition at line 162 of file manageDataRunDefinitions.py.

163  def __init__(self, samweb):
164  self.samweb = samweb if samweb else SAMWebClient()
165 

Member Function Documentation

def manageDataRunDefinitions.SampleBrowser.__call__ (   self,
  info 
)

Definition at line 213 of file manageDataRunDefinitions.py.

214  def __call__(self, info): return self.iterate(info)
215 
def manageDataRunDefinitions.SampleBrowser._discoverProjectVersions (   self,
  dims 
)
private
Returns the project versions from the all files matching `dims`.

Definition at line 216 of file manageDataRunDefinitions.py.

217  def _discoverProjectVersions(self, dims):
218  """Returns the project versions from the all files matching `dims`."""
219  logging.debug("Discovering project versions for %s", dims)
220 
221  try:
222  files = self.samweb.listFiles(dims, fileinfo=True)
223  except samexcpt.Error:
224  logging.error(f"SAM exception while translating query: '{dims}'")
225  raise
226 
227  logging.debug(f" => querying metadata for {len(files)} files")
228 
229  versions = set(
230  meta['icarus_project.version']
231  for meta in self.samweb.getMetadataIterator(fInfo.file_id for fInfo in files)
232  )
233  logging.debug(f" => extracted {len(versions)} versions: %s", versions)
return list(versions)
list
Definition: file_to_url.sh:28
def manageDataRunDefinitions.SampleBrowser.iterate (   self,
  info 
)

Definition at line 206 of file manageDataRunDefinitions.py.

207  def iterate(self, info: "SampleInfo object defining iteration ranges"):
208  """Iterates through all elements in `info`."""
209  for run in SampleInfo.makeOptionList(info.run):
210  runInfo = info.copy(run=run)
211  yield from self.iterateStages(runInfo)
# for
def manageDataRunDefinitions.SampleBrowser.iterateProjectVersions (   self,
  info 
)

Definition at line 166 of file manageDataRunDefinitions.py.

167  def iterateProjectVersions(self, info: "SampleInfo object defining iteration ranges"):
168  assert self.samweb, "SAM web client not initialized. We do not go anywhere."
169 
170  # expand the project versions: each version will be treated separately
171  if info.projectVersion is None:
172  if info.stage != 'raw':
173  versionQuery = DimensionQueryMaker()(info, minimum=2)
174  projectVersions = self._discoverProjectVersions(versionQuery)
175  else: projectVersions = [ None ] # no version constraint is ok for raw files
176  else:
177  projectVersions = SampleInfo.makeOptionList(info.projectVersion)
178  # if ... else
179 
180  for prjVer in projectVersions:
181  prjInfo = info.copy(projectVersion=prjVer)
182  yield prjInfo
# for
def manageDataRunDefinitions.SampleBrowser.iterateStages (   self,
  info 
)

Definition at line 195 of file manageDataRunDefinitions.py.

196  def iterateStages(self, info: "SampleInfo object defining iteration ranges"):
197  assert info.stage is not None, "Stages needs to be explicitly specified."
198  for stage in SampleInfo.makeOptionList(info.stage):
199  assert stage, "Stage must be specified."
200  stageInfo = info.copy(stage=stage)
201  logging.debug(f"Processing {stageInfo}")
202  yield from self.iterateStreams(stageInfo)
# for
def manageDataRunDefinitions.SampleBrowser.iterateStreams (   self,
  info 
)

Definition at line 186 of file manageDataRunDefinitions.py.

187  def iterateStreams(self, info: "SampleInfo object defining iteration ranges"):
188  assert info.isStageComplete(), "Stage must be set."
189  for stream in SampleInfo.makeOptionList(info.stream):
190  streamInfo = info.copy(stream=stream)
191  yield from self.iterateProjectVersions(streamInfo)
# for streams

Member Data Documentation

manageDataRunDefinitions.SampleBrowser.samweb

Definition at line 163 of file manageDataRunDefinitions.py.


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