def som_start(host,hed,img,mask,xdim,ydim,radius,levels,iters,alpha): jobid = hashargs([hed,img,mask,xdim,ydim,radius,levels,iters,alpha]) cache = FSCache(hed_som,hed,img,mask,xdim,ydim,radius,levels,iters,alpha) print 'starting som job, cached:',cache.cached,'running:',cache.locked,'pgid:',os.getpgrp() if not cache.cached and not cache.locked: with FSDict(rest_pathForJobId(jobid)) as status: status['mask'] = rest_saveImagePath(mask) status['stat'] = cache.stat.path status['pid'] = os.getpid() hed_som(cache,hed,img,mask,xdim,ydim,radius,levels,iters,alpha) with FSDict(rest_pathForJobId(jobid)) as status: status['pid'] = None
def rest_average_status(projectid, stackid, callback): hed, img = rest_queryStackPath(projectid, stackid) cache = FSCache(hed_average, hed, img) print "starting avg job, cached:", cache.cached, "running:", cache.locked print " hed:", hed print " img:", img if not cache.cached and not cache.locked: mp.Process(target=rest_average, args=[hed, img]).start() status = cache.stat status = { "total": status.get("total", None), "done": status.get("done", None), "url": rest_saveImagePath(status.get("avg.spi", None)), } callback(status)
def rest_som_status(jobid,callback): try: job_status = FSDict(rest_pathForJobId(jobid)) processing_status = FSDict(job_status['stat']) avgs = processing_status['avgs'] avgs = [[rest_saveImagePath(avg) for avg in row] for row in avgs] callback({ 'id' : jobid, 'done' : processing_status.get('done',None), 'total' : processing_status.get('total',None), 'mask' : job_status.get('mask',None), 'tar' : rest_TarFiles(jobid,avgs), 'avgs' : avgs, }) except Exception as error: print '[exception]', error callback({ 'id' : None, 'done' : None, 'total' : None, 'avgs' : None, })