def output(self, extraConstraint='1'): dom = db.queryCol('fwid', pp.AND([extraConstraint, self.detail1constraint])) pairs = db.query(['id0', 'id1'], self.detail2constraint, 'pairs') if self.detail1constraint == '1' and extraConstraint == '1': return pairs return [(x, y) for (x, y) in pairs if (x in dom) and (y in dom)]
def vary(constraint, param, rang, check=True): # verify that constraint uniquely picks out a job readJobs.readJobs() defaults = RELAXORLAT output = dbase.queryCol('params_json', AND([defaults, constraint])) assert len( output ) == 1, 'Constraint %s is not specific enough, the following sets of params are returned: %s' % ( constraint, '\n\n'.join([abbreviateDict(z) for z in output])) params = json.loads(output[0]) assert param in params.keys(), 'param %s not in keys: %s' % ( abbreviateDict(param), params.keys()) print 'Param dict with %s being varied over the range %s: %s' % ( param, str(rang), abbreviateDict(params)) jbs = [] for v in rang: ps = copy.deepcopy(params) assert not (jobs.assignJob(ps).new() ), 'varying a job that isn\'t complete or doesn\'t exist' ps[param] = v job = jobs.assignJob(ps) if job.new(): jbs.append(job) if not check or ask('Do you want to launch %d new jobs?' % len(jbs)): for j in jbs: j.check() j.submit() if check: misc.launch()
def viewImg(col='sites',constraint=SURFACE,fast=False): # view 'sites' of a SURFACE or 'bulkmodimg' of a BULKMOD imgs = db.queryCol(col,constraint) for i,img in enumerate(imgs): if fast or i==0 or raw_input('Continue?') or True: imgroot = os.environ['IMG_PATH'] with open(imgroot+'/img.png','wb') as f: f.write(img.decode('base64')) os.system('display %s/img.png &'%imgroot)
def output(self, extraConstraint=NONE(1)): print 'entering OUTPUT' dom = queryCol('launchdir', self.domainConstraint ) # AND([self.domainConstraint]))#,extraConstraint])) #print 'in equiv output: len dom = ',len(dom) #print "queryTuple(2,self.querystrs) ",queryTuple(2,self.querystrs) return [(x, y) for (x, y) in sqlexecute('SELECT ld0,ld1 from detail1 where ' + self.detail2) if (x in dom) and (y in dom)]
def makeTriples(self, idgroups, labelName): args = [db.query(self.cols, FWIDS(x)) for x in idgroups] #[[(ARG1,ARG2,...)]] labels = [db.queryCol(labelName, FWIDS(x)) for x in idgroups] #[[STRING]] xy = [self.func(*zip(*arg)) for arg in args] #[[(FLOAT,FLOAT)) xy_l = [(zip(xy, l)) for xy, l in zip(xy, labels)] filtered = [[(xyl[0][0], xyl[0][1], xyl[1]) for xyl in xyls if not (xyl[0][0] is None or xyl[0][1] is None)] for xyls in xy_l] sortd = [sorted(x) for x in filtered if len(x) > 0] return [zip(*x) for x in sortd]
def varies(constraint, param, rang): readJobs.readJobs() jbs = [] defaults = RELAXORLAT cnst = AND([defaults, constraint]) output = dbase.queryCol('params_json', cnst) if ask('Do you want to vary %s over range %s for %d jobs?' % (param, str(rang), len(output))): for params in map(json.loads, output): for v in rang: ps = copy.deepcopy(params) assert not (jobs.assignJob(ps).new( )), 'varying a job that isn\'t complete or doesn\'t exist' ps[param] = v job = jobs.assignJob(ps) if job.new(): jbs.append(job) if ask('Do you want to launch %d new jobs?' % len(jbs)): for j in jbs: j.check() j.submit() misc.launch()
def rerun(cnstrt='1'): fwids = db.queryCol('fwid',AND([FIZZLED,cnstrt])) question='Do you want to rerun %d fizzled jobs selected by %s?'%(len(fwids),cnstrt) if ask(question): for f in fwids: lpad.rerun_fw(f) misc.launch()
def toDo(): params = db.queryCol('params_json',VIB,deleted=True) for p in params: j = jobs.assignJob(json.loads(p)) if j.new(): j.check();j.submit() misc.launch()