def rest_som_start(host,params,callback=None): params = json.loads(params) maskid = params.get('maskid',None) stackid = params.get('stackid') projectid = params.get('projectid') xdim = int(params.get('xdim',10)) ydim = int(params.get('ydim',2)) radius = int(params.get('radius',1)) levels = int(params.get('levels',3)) iters = int(params.get('iters',5000)) alpha = float(params.get('alpha',0.01)) hed,img = rest_queryStackPath(projectid,stackid) mask = pathFromId(maskid,ext='.png') print 'parent group process id:',os.getpgrp() jobid = hashargs([hed,img,mask,xdim,ydim,radius,levels,iters,alpha]) job = mp.Process(target=som_start,args=[host,hed,img,mask,xdim,ydim,radius,levels,iters,alpha]) job.start() callback({ 'id' : jobid, 'url' : rest_urlForJobId(host,jobid), })
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)