def getjobs(self, path=None): """Gives list of all jobs (objects) referenced in current folder or folder in the path if the latter is provided. """ # jobslice ##res = [] res = JobRegistrySlice("") registry = self._getRegistry() do_clean = False if registry is not None: try: registry = registry._parent except: Ganga.Utility.logging.log_unknown_exception() pass path = os.path.join(*self.__get_path(path)) res.name = "jobs found in %s" % path cont = self.ls(path) for i in cont['jobs']: try: try: id = int(i) j = registry[id] except ValueError: j = registry[int(i.split('.')[0])].subjobs[int(i.split('.')[1])] except RegistryKeyError, ObjectNotInRegistryError: do_clean = True else: res.objects[j.id] = j
def getjobs(self, path=None): """Gives list of all jobs (objects) referenced in current folder or folder in the path if the latter is provided. """ # jobslice ##res = [] res = JobRegistrySlice("") registry = self._getRegistry() do_clean = False if registry is not None: try: registry = registry._parent except: Ganga.Utility.logging.log_unknown_exception() pass path = os.path.join(*self.__get_path(path)) res.name = "jobs found in %s" % path cont = self.ls(path) for i in cont['jobs']: try: try: id = int(i) j = registry[id] except ValueError: j = registry[int(i.split('.')[0])].subjobs[int( i.split('.')[1])] except RegistryKeyError, ObjectNotInRegistryError: do_clean = True else: res.objects[j.id] = j
def getjobs(self, path = None): """Gives list of all jobs (objects) referenced in current folder or folder in the path if the latter is provided. """ #jobslice ##res = [] res = JobRegistrySlice("") registry = self._getRegistry() do_clean = False if registry is not None: registry = registry._parent path = os.path.join(*self.__get_path(path)) res.name = "jobs found in %s" % path cont = self.ls(path) for i in cont['jobs']: try: try: id = int(i) j = registry[id] except ValueError: j = registry[int(i.split('.')[0])].subjobs[int(i.split('.')[1])] except RegistryKeyError: do_clean = True else: res.objects[j.id] = j if do_clean: self.cleanlinks() return _wrap(res)
def getPartitionJobs(self, partition): """ Get the job slice that processed the given partition. Iterates over the job list. """ task = self._getParent() id = task.transforms.index(self) if partition is None: sname = "tasks(%i).transforms[%i].getJobs()" % (task.id, id) else: sname = "tasks(%i).transforms[%i].getPartitionJobs(%s)" % ( task.id, id, partition) jobslice = JobRegistrySlice(sname) def addjob(j): if partition is None or self._app_partition[ j.application.id] == partition: jobslice.objects[j.fqid] = stripProxy(j) for j in GPI.jobs: try: stid = j.application.tasks_id.split(":") if int(stid[-2]) == task.id and int(stid[-1]) == id: if j.subjobs: for sj in j.subjobs: addjob(sj) else: addjob(j) except Exception as err: logger.debug("getPartitionJobs Exception:\n%s" % str(err)) pass return JobRegistrySliceProxy(jobslice)
def getJobs(self, transform=None, partition=None, only_master_jobs=True): """ Get the job slice of all jobs that process this task """ if not partition is None: only_master_jobs = False jobslice = JobRegistrySlice( "tasks(%i).getJobs(transform=%s, partition=%s, only_master_jobs=%s)" % (self.id, transform, partition, only_master_jobs)) def addjob(j): if transform is None or partition is None or self.transforms[int( transform)]._app_partition[j.application.id] == partition: jobslice.objects[j.fqid] = stripProxy(j) for j in GPI.jobs: try: stid = j.application.tasks_id.split(":") if int(stid[-2]) == self.id and (transform is None or stid[-1] == str(transform)): if j.subjobs and not only_master_jobs: for sj in j.subjobs: addjob(sj) else: addjob(j) except Exception as err: logger.debug("getJobs Error!!") logger.debug("Error:\n%s" % str(err)) # print x pass return JobRegistrySliceProxy(jobslice)
def getJobs(self): """ Get the job slice of all jobs that process this task """ jobslice = JobRegistrySlice("tasks(%i).getJobs()" % (self.id)) for trf in self.transforms: for jid in trf.getJobs(): jobslice.objects[getJobByID(jid).fqid] = stripProxy( getJobByID(jid)) return JobRegistrySliceProxy(jobslice)