class SolveJob (object): def __init__ (self,label,name,*active_parmgroups): self.label = label; self.name = name; self.tdloption_namespace = label.replace(":","_").replace(" ","_"); self.active_parmgroups = active_parmgroups; # menu is only made on-demand self._jobmenu = None; # add to global list _all_solvejobs.append(self); def runtime_options (self): if self._jobmenu is None: opts = [ TDLOption('tile_size',"Tile size, in timeslots",[1,10,100], doc="""Input data is normally sliced by time, and processed in chunks of the indicated size. This will also be the effective parameter solution interval (in time), unless you specify a different (smaller) value for the "Solution subinterval (time)" option below.""", more=int,namespace=self), TDLOption('time_step',"Time stepping, in timeslots",[1,2,5,10], doc="""Enter a step size N>1 to only process every Nth timeslot.""", more=int,namespace=self) ]; # add options from parmgroups global _all_parmgroups; self.pg_controllers = []; other_opts = []; for pg in _all_parmgroups: solvable = pg in self.active_parmgroups; controller = pg.make_controller(self.label,solvable=solvable); if solvable: opts += controller.runtime_options(); else: other_opts += controller.runtime_options(); self.pg_controllers.append(controller); if other_opts: opts.append(TDLMenu("Simultaneously solve for other parameters",*other_opts)); # add solver control self.solver_control = SolverControl(self.label); opts.append(TDLMenu("Solver options (for the brave)",*self.solver_control.runtime_options())); # add solve job opts.append(TDLJob(self._run_solve_job,self.name or "Run solution",job_id=self.label)); # now make a runtime menu self._jobmenu = TDLMenu(self.name or "Solve for %s"%self.label,*opts); return [ self._jobmenu ]; def run_solution (self,mqs,mssel=None,vdm=None,tiling=None,time_step=1,wait=False): """Helper function to put together TDL jobs. Starts a solution, setting the group to solvable"""; mssel = mssel or Context.mssel; # make command lists for our parameters cmdlist = []; for pgc in self.pg_controllers: cmdlist += pgc.make_cmdlist(); self.solver_control.update_state(mqs,cmdlist=cmdlist); # run the VisDataMux vdm = namify(vdm or Context.vdm or 'VisDataMux') return mqs.execute(vdm,mssel.create_io_request(tiling,time_step=time_step),wait=wait); def _run_solve_job (self,mqs,parent,wait=False,**kw): return self.run_solution(mqs,tiling=self.tile_size,time_step=self.time_step,wait=wait);
def runtime_options(self): if self._jobmenu is None: opts = [ TDLOption( 'tile_size', "Tile size, in timeslots", [1, 10, 100], doc= """Input data is normally sliced by time, and processed in chunks of the indicated size. This will also be the effective parameter solution interval (in time), unless you specify a different (smaller) value for the "Solution subinterval (time)" option below.""", more=int, namespace=self), TDLOption( 'time_step', "Time stepping, in timeslots", [1, 2, 5, 10], doc= """Enter a step size N>1 to only process every Nth timeslot.""", more=int, namespace=self) ] # add options from parmgroups global _all_parmgroups self.pg_controllers = [] other_opts = [] for pg in _all_parmgroups: solvable = pg in self.active_parmgroups controller = pg.make_controller(self.label, solvable=solvable) if solvable: opts += controller.runtime_options() else: other_opts += controller.runtime_options() self.pg_controllers.append(controller) if other_opts: opts.append( TDLMenu("Simultaneously solve for other parameters", *other_opts)) # add solver control self.solver_control = SolverControl(self.label) opts.append( TDLMenu("Solver options (for the brave)", *self.solver_control.runtime_options())) # add solve job opts.append( TDLJob(self._run_solve_job, self.name or "Run solution", job_id=self.label)) # now make a runtime menu self._jobmenu = TDLMenu(self.name or "Solve for %s" % self.label, *opts) return [self._jobmenu]
def runtime_options (self): if self._jobmenu is None: opts = [ TDLOption('tile_size',"Tile size, in timeslots",[1,10,100], doc="""Input data is normally sliced by time, and processed in chunks of the indicated size. This will also be the effective parameter solution interval (in time), unless you specify a different (smaller) value for the "Solution subinterval (time)" option below.""", more=int,namespace=self), TDLOption('time_step',"Time stepping, in timeslots",[1,2,5,10], doc="""Enter a step size N>1 to only process every Nth timeslot.""", more=int,namespace=self) ]; # add options from parmgroups global _all_parmgroups; self.pg_controllers = []; other_opts = []; for pg in _all_parmgroups: solvable = pg in self.active_parmgroups; controller = pg.make_controller(self.label,solvable=solvable); if solvable: opts += controller.runtime_options(); else: other_opts += controller.runtime_options(); self.pg_controllers.append(controller); if other_opts: opts.append(TDLMenu("Simultaneously solve for other parameters",*other_opts)); # add solver control self.solver_control = SolverControl(self.label); opts.append(TDLMenu("Solver options (for the brave)",*self.solver_control.runtime_options())); # add solve job opts.append(TDLJob(self._run_solve_job,self.name or "Run solution",job_id=self.label)); # now make a runtime menu self._jobmenu = TDLMenu(self.name or "Solve for %s"%self.label,*opts); return [ self._jobmenu ];
class SolveJob(object): def __init__(self, label, name, *active_parmgroups): self.label = label self.name = name self.tdloption_namespace = label.replace(":", "_").replace(" ", "_") self.active_parmgroups = active_parmgroups # menu is only made on-demand self._jobmenu = None # add to global list _all_solvejobs.append(self) def runtime_options(self): if self._jobmenu is None: opts = [ TDLOption( 'tile_size', "Tile size, in timeslots", [1, 10, 100], doc= """Input data is normally sliced by time, and processed in chunks of the indicated size. This will also be the effective parameter solution interval (in time), unless you specify a different (smaller) value for the "Solution subinterval (time)" option below.""", more=int, namespace=self), TDLOption( 'time_step', "Time stepping, in timeslots", [1, 2, 5, 10], doc= """Enter a step size N>1 to only process every Nth timeslot.""", more=int, namespace=self) ] # add options from parmgroups global _all_parmgroups self.pg_controllers = [] other_opts = [] for pg in _all_parmgroups: solvable = pg in self.active_parmgroups controller = pg.make_controller(self.label, solvable=solvable) if solvable: opts += controller.runtime_options() else: other_opts += controller.runtime_options() self.pg_controllers.append(controller) if other_opts: opts.append( TDLMenu("Simultaneously solve for other parameters", *other_opts)) # add solver control self.solver_control = SolverControl(self.label) opts.append( TDLMenu("Solver options (for the brave)", *self.solver_control.runtime_options())) # add solve job opts.append( TDLJob(self._run_solve_job, self.name or "Run solution", job_id=self.label)) # now make a runtime menu self._jobmenu = TDLMenu(self.name or "Solve for %s" % self.label, *opts) return [self._jobmenu] def run_solution(self, mqs, mssel=None, vdm=None, tiling=None, time_step=1, wait=False): """Helper function to put together TDL jobs. Starts a solution, setting the group to solvable""" mssel = mssel or Context.mssel # make command lists for our parameters cmdlist = [] for pgc in self.pg_controllers: cmdlist += pgc.make_cmdlist() self.solver_control.update_state(mqs, cmdlist=cmdlist) # run the VisDataMux vdm = namify(vdm or Context.vdm or 'VisDataMux') return mqs.execute(vdm, mssel.create_io_request(tiling, time_step=time_step), wait=wait) def _run_solve_job(self, mqs, parent, wait=False, **kw): return self.run_solution(mqs, tiling=self.tile_size, time_step=self.time_step, wait=wait)