Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#------------------------------------------------------------------------------- # OFFLINE Reader #-------------------------------------------------------------------------------
""" Shortcut method to read all data in given external file. """
""" Derived class to read the local jobtree file outside ganga interactive session. """
""" Args: datpath (string): Path to jobtree file. If None, it'll try to locate the appropriate location by itself ( guessing jobs.metadata )
>>> OfflineJobtreeReader('tests/res/jobtree_test') <GangaCK.Jobtree.OfflineJobtreeReader.OfflineJobtreeReader object at ...>
""" datpath = os.path.join(ConfigUtils.dir_repository(), 'jobs.metadata/0xxx/0/data')
"""
>>> ojtr = OfflineJobtreeReader('tests/res/jobtree_test')
>>> pprint(ojtr.ls()) {'folders': ['002 Z+BJet Analysis[CLOSED]', '013_Tau_Identification'], 'jobs': []}
>>> pprint(ojtr.ls('013_Tau_Identification')) {'folders': ['00_samples', '02_ditau_passthrough_v2', '03_Stripping23'], 'jobs': []}
>>> ojtr.ls('BADDIR') Traceback (most recent call last): ... KeyError: 'Missing key: BADDIR'
>>> pprint(ojtr.ls('013_Tau_Identification/00_samples')) {'folders': [], 'jobs': [2543, 2811, 2812, 2861, 2862]}
## Ignore [CLOSED]
>>> pprint(ojtr.ls('013_Tau_Identification/00_samples [CLOSED]')) {'folders': [], 'jobs': [2543, 2811, 2812, 2861, 2862]}
>>> pprint(ojtr.ls('013_Tau_Identification[CLOSED]/00_samples')) {'folders': [], 'jobs': [2543, 2811, 2812, 2861, 2862]}
>>> ojtr.jobs [197, 202, 232, 269, 892, 893, 894, 907, 2543, 2767, 2768, 2769, 2770, 2771, 2811, 2812, 2861, 2862]
""" else:
"""
>>> _ = getfixture('job197') >>> ojtr = OfflineJobtreeReader('tests/res/jobtree_test') >>> j = ojtr.job(197) >>> '[{0.id}] {0.name}'.format(j) '[197] Z02MuMuLine'
""" return None except IOError, e: logger.warning(e) return None # Corrupt job
def jobs_all(self): """ Use the combination of dirnames in repo+work. """ s1 = ConfigUtils.jids_repository() s2 = ConfigUtils.jids_workspace() return s1.union(s2)
# searchpath = os.path.join(self.gdir, 'repository/khurewat/LocalXML/6.0/jobs/*/*') # return [ int(re.findall(r'.*/(\d+)', s)[0]) for s in sorted(glob(searchpath)) ] |