def _jobId(self, table): "Displays id of the current job" jobs = self._director.clerk.getQEJobs(where="taskid='%s'" % self._task.id) if not jobs: table.addRow(("Job:", "None", "")) return self._job = latestJob(jobs) link = lc.link(label=self._job.id, onclick=load(actor='jobs/jobs-view', id=self._simid, taskid=self._task.id, jobid=self._job.id, type=self._type, package="Quantum Espresso")) action = lc.link( label="All Jobs", Class="qe-all-jobs", # Class = "qe-task-action" onclick=load(actor='jobs/jobs-view-all', id=self._simid, taskid=self._task.id, type=self._type, linkorder=self._linkorder, package="Quantum Espresso")) table.addRow(("Job:", link, action))
def _jobId(self, table): "Displays id of the current job" jobs = self._director.clerk.getQEJobs(where="taskid='%s'" % self._task.id) if not jobs: table.addRow(("Job:", "None", "")) return self._job = latestJob(jobs) link = lc.link(label = self._job.id, onclick = load(actor = 'jobs/jobs-view', id = self._simid, taskid = self._task.id, jobid = self._job.id, type = self._type, package = "Quantum Espresso")) action = lc.link(label = "All Jobs", Class = "qe-all-jobs", # Class = "qe-task-action" onclick = load(actor = 'jobs/jobs-view-all', id = self._simid, taskid = self._task.id, type = self._type, linkorder = self._linkorder, package = "Quantum Espresso")) table.addRow(("Job:", link, action))
def configLink(director, id, taskid, type, structureid): "Returns link to configuration" if not type in FILETYPE: # Extra protection :) return "None" inputs = director.clerk.getQEConfigurations(where="taskid='%s' and type='%s'" % (taskid, type)) actorName = "material_simulations/epsc/%s-create" % type # Default link link = lc.link(label="Create", Class="epsc-action-create", onclick=load(actor = actorName, id = id, taskid = taskid, type = type, structureid = structureid)) if not inputs: # No inputs created, return "Add" link return link input = latestInput(inputs) if not input: # No input, return default link return link # Link to configuration view return lc.link(label = input.filename, onclick = load(actor = "material_simulations/epsc/config-view", id = id, taskid = taskid, type = type, configid = input.id))
def configLink(director, id, taskid, type, structureid): "Returns link to configuration" if not type in FILETYPE: # Extra protection :) return "None" inputs = director.clerk.getQEConfigurations( where="taskid='%s' and type='%s'" % (taskid, type)) actorName = "material_simulations/epsc/%s-create" % type # Default link link = lc.link(label="Create", Class="epsc-action-create", onclick=load(actor=actorName, id=id, taskid=taskid, type=type, structureid=structureid)) if not inputs: # No inputs created, return "Add" link return link input = latestInput(inputs) if not input: # No input, return default link return link # Link to configuration view return lc.link(label=input.filename, onclick=load(actor="material_simulations/epsc/config-view", id=id, taskid=taskid, type=type, configid=input.id))
def _refreshAction(self, section): section.add( lc.link(label="Refresh", Class="qe-action-back", onclick=load( actor='material_simulations/espresso-convergence/view', id=self.id)))
def _pwInputAction(self, section): "Shows PW input action button" if not self._input: # No input created section.add(lc.link(label="Create PW Input", Class="qe-action-new", onclick = load(actor = 'material_simulations/espresso/sim-view', id = self.id)) ) return # Otherwise show PW link section.add(lc.link(label="PW", Class="qe-action-default", onclick = load(actor = 'material_simulations/espresso-convergence/input-view', inputid = self._input.id, id = self.id)) )
def _backAction(self, section): "Back button" section.add( lc.link(label="Back", Class="qe-action-back", onclick=load( actor='material_simulations/espresso/sim-view', id=self.id)))
def header(self): "Shows the header for the simulation task" # Because "tip" attribute is not implemented for any text widget (luban limitation) # I will choose link widget instead type = lc.link(Class="link-text-hack text-blue text-bold") type.label = "Step %s: %s" % (self._linkorder+1 , self._taskLabel()) type.tip = self._taskTip() return type
def header(self): "Shows the header for the simulation task" # Because "tip" attribute is not implemented for any text widget (luban limitation) # I will choose link widget instead type = lc.link(Class="link-text-hack text-blue text-bold") type.label = "Step %s: %s" % (self._linkorder + 1, self._taskLabel()) type.tip = self._taskTip() return type
def link(self): link = lc.link(label=self._text) if self._onload: link.onload = self._onload if self._class: link.Class = self._class return link
def _newTestAction(self, section): section.add( lc.link( label="Create New Test", Class="qe-action-new", onclick=load( actor= 'material_simulations/espresso-convergence/conv-create', id=self.id)))
def _refreshAction(self, section): "Refresh button" section.add( lc.link( label="Refresh", Class="qe-action-edit", onclick=load( actor=analyseActor(self.simtype), simtype=self.simtype, # pass simtype id=self.id)))
def visual_inline(path): # path is a list of (label, action) and one label as the last item doc = lc.document(id='view-indicator') doc1 = doc for (label, action) in path[:-1]: doc1.add(lc.link(label=label, onclick=action)) doc1.paragraph(text=['/ '], Class='splitter') continue last = path[-1] if isinstance(last, basestring): doc1.paragraph(text=path[-1]) else: label, action = last doc1.add(lc.link(label=label, onclick=action)) return doc
def allJobsLink(director, id, taskid): "Returns link to all jobs" return lc.link(label = "All Jobs", Class = "qe-all-jobs", # Class = "qe-task-action" onclick = load(actor = 'jobs/jobs-view-all', id = id, taskid = taskid, type = "epsc", linkorder = 0, package = "EPSC"))
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label = 'Output', onclick = select(element=content).append(dialog))
def runLink(director, id, taskid): "Returns run link" return lc.link(label = "Run Simulation", Class = "epsc-run-task", onclick = load(actor ='jobs/submit', routine = 'submit', id = id, taskid = taskid, subtype = "epsc", # Used to identify job type! package = "epsc"))
def _createLinkForOrigin(self, id, origin, director): '''id: id of the phonons record origin: data object of the original computation for the phonons ''' link = lc.link(label='computed from %s %s' % (origin.getTableName(), origin.id), onclick=load(actor='computation', routine='view', type=origin.getTableName(), id=origin.id)) return link
def _taskId(self, table): tid = self._task.id link = lc.link(label=tid, onclick=load( actor='material_simulations/espresso/task-view', id=self._simid, taskid=tid, type=self._type, linkorder=self._linkorder)) table.addRow(("Task:", link, ""))
def allJobsLink(director, id, taskid): "Returns link to all jobs" return lc.link( label="All Jobs", Class="qe-all-jobs", # Class = "qe-task-action" onclick=load(actor='jobs/jobs-view-all', id=id, taskid=taskid, type="epsc", linkorder=0, package="EPSC"))
def _pwInputAction(self, section): "Shows PW input action button" if not self._input: # No input created section.add( lc.link(label="Create PW Input", Class="qe-action-new", onclick=load( actor='material_simulations/espresso/sim-view', id=self.id))) return # Otherwise show PW link section.add( lc.link(label="PW", Class="qe-action-default", onclick=load( actor= 'material_simulations/espresso-convergence/input-view', inputid=self._input.id, id=self.id)))
def _fileLink(self, filename, content): "Returns file link" assert filename != None # Contruct dialog title = 'Output for %s task. %s bytes' % (self._task.id, os.path.getsize(filename)) text = lc.htmldocument(text="<pre>%s<pre>" % open(filename).read()) dialog = qedialog(title, text) # dialog to pop up return lc.link(label='Output', onclick=select(element=content).append(dialog))
def _cancelLink(self): "Returns 'Cancel' link" link = lc.link(label = "Cancel", Class = "qe-cancel-task", onclick = load(actor ='jobs/cancel', routine = 'cancel', simid = self._simid, jobid = self._job.id, taskid = self._task.id) ) return link
def _taskId(self, table): tid = self._task.id link = lc.link(label = tid, onclick = load(actor = 'material_simulations/espresso/task-view', id = self._simid, taskid = tid, type = self._type, linkorder = self._linkorder) ) table.addRow(("Task:", link, ""))
def runLink(director, id, taskid): "Returns run link" return lc.link( label="Run Simulation", Class="epsc-run-task", onclick=load( actor='jobs/submit', routine='submit', id=id, taskid=taskid, subtype="epsc", # Used to identify job type! package="epsc"))
def settingsLink(director, id): "Returns link to settings of simulation" settings = director.clerk.getQESettings(where="simulationid='%s'" % id ) # Default link link = lc.link(label="Create", Class="epsc-action-create", tip = "Set simulation environment", onclick=load(actor = "material_simulations/epsc/settings-add", id = id)) if settings: s = settings[0] if s: link = lc.link(label = s.sname, Class = "action-link", onclick = load(actor = "material_simulations/epsc/settings-view", id = id, configid = s.id)) return link
def action(self): "Returns link to action that refreshes the status of results" if not self._job: #or not self._task: return "" # Default value return lc.link(label = "Check", id = "qe-check-results", onclick=load(actor = "jobs/getresults", routine = "retrieveStatus", id = self._simid, taskid = self._task.id, jobid = self._job.id) )
def settingsLink(director, id): "Returns link to settings of simulation" settings = director.clerk.getQESettings(where="simulationid='%s'" % id) # Default link link = lc.link(label="Create", Class="epsc-action-create", tip="Set simulation environment", onclick=load(actor="material_simulations/epsc/settings-add", id=id)) if settings: s = settings[0] if s: link = lc.link(label=s.sname, Class="action-link", onclick=load( actor="material_simulations/epsc/settings-view", id=id, configid=s.id)) return link
def _action(self, routine): "General action that calls specific routine" if not self._job or not self._task: return "" return lc.link(label="Refresh", Class="qe-task-action", onclick=load(actor='jobs/status', routine=routine, id=self._simid, taskid=self._task.id, jobid=self._job.id, linkorder=self._linkorder))
def _exportAction(self, section): "Export button" link = lc.link( label="Export", Class="qe-action-edit", onclick=load( actor=analyseActor( self.simtype ), #'material_simulations/espresso-analysis/exports', routine="export", id=self.id, simtype=self.simtype), tip="Export Parameters of the Simulation") section.add(link)
def _action(self, routine): "General action that calls specific routine" if not self._job or not self._task: return "" return lc.link(label ="Refresh", Class = "qe-task-action", onclick = load(actor = 'jobs/status', routine = routine, id = self._simid, taskid = self._task.id, jobid = self._job.id, linkorder = self._linkorder) )
def _runLink(self): "Returns 'Run Task' link" # If not job created or is not running link = lc.link(label = "Run Task", Class = "qe-run-task", onclick = load(actor ='jobs/submit', # 'jobs/checksubmit' routine = 'submit', id = self._simid, taskid = self._task.id, subtype = self._task.subtype, optlevel = self._optlevel(), package = "espresso") ) return link
def _(self, director): # target frame to change body_frame = select(id='body-frame') # new body skeleton body_skeleton = director.retrieveVisual('body-skeleton', context='atomicstructure', director=director) main_display_area = body_skeleton.find(id='main-display-area') # put stuff into the main display area doc = func(self, director) main_display_area.add(doc) # set portlet body_skeleton.find(id='main-portlet-%s' % portlet).selected = 1 # set page title setpagetitle = select(id='').setAttr(title=title) # help window helpwindow = director.redirect( actor='help', routine='createHelpWindow', nextpagetoshow='UserGuide-atomicstructures', include_credential=False) addhelpwindow = select(id='').append(helpwindow) # news ticker newsticker = director.redirect(actor='news', routine='createTicker', include_credential=False) addnewsticker = select(id='header-news-container').append(newsticker) # logout link logout = load(actor='logout') link = lc.link(label='logout', onclick=logout) addlogout = select(id='header-userinfo').append(link) # show dock showdock = select(id='dock').show() # return [ setpagetitle, showdock, body_frame.replaceContent(body_skeleton), addhelpwindow, addnewsticker, addlogout, ]
def jobLink(director, id, taskid): "Returns link to job" jobs = director.clerk.getQEJobs(where="taskid='%s'" % taskid) if not jobs: return "None" job = latestJob(jobs) return lc.link(label=job.id, onclick=load(actor='jobs/jobs-view', id=id, taskid=taskid, jobid=job.id, type="epsc", package="EPSC"))
def jobLink(director, id, taskid): "Returns link to job" jobs = director.clerk.getQEJobs(where="taskid='%s'" % taskid) if not jobs: return "None" job = latestJob(jobs) return lc.link(label = job.id, onclick = load(actor = 'jobs/jobs-view', id = id, taskid = taskid, jobid = job.id, type = "epsc", package = "EPSC"))
def _(self, director): # target frame to change body_frame = select(id='body-frame') # new body skeleton body_skeleton = director.retrieveVisual( 'body-skeleton', context='atomicstructure', director=director) main_display_area = body_skeleton.find(id='main-display-area') # put stuff into the main display area doc = func(self, director) main_display_area.add(doc) # set portlet body_skeleton.find(id='main-portlet-%s' % portlet).selected = 1 # set page title setpagetitle = select(id='').setAttr(title=title) # help window helpwindow = director.redirect( actor='help', routine='createHelpWindow', nextpagetoshow = 'UserGuide-atomicstructures', include_credential=False) addhelpwindow = select(id='').append(helpwindow) # news ticker newsticker = director.redirect( actor='news', routine = 'createTicker', include_credential = False) addnewsticker = select(id='header-news-container').append(newsticker) # logout link logout = load(actor='logout') link = lc.link(label='logout', onclick=logout) addlogout = select(id='header-userinfo').append(link) # show dock showdock = select(id='dock').show() # return [ setpagetitle, showdock, body_frame.replaceContent(body_skeleton), addhelpwindow, addnewsticker, addlogout, ]
def taskInfo(self): table = QEGrid(lc.grid(Class="qe-tasks-info")) if self._task: # If task exists self._setTaskInfo(table) # Main scenario return table.grid() # No task created, show link "Create New Task" link = lc.link(label="Create New Task", onclick=load( actor='material_simulations/espresso/task-create', routine='createRecord', simid=self._simid, tasktype=self._type, linkorder=self._linkorder)) table.addRow((link, )) #table.addRow(("or", )) # Keep #table.addRow(("Use Existing Task", )) # Keep return table.grid()
def taskInfo(self): table = QEGrid(lc.grid(Class="qe-tasks-info")) if self._task: # If task exists self._setTaskInfo(table) # Main scenario return table.grid() # No task created, show link "Create New Task" link = lc.link(label="Create New Task", onclick = load(actor = 'material_simulations/espresso/task-create', routine = 'createRecord', simid = self._simid, tasktype = self._type, linkorder = self._linkorder) ) table.addRow((link, )) #table.addRow(("or", )) # Keep #table.addRow(("Use Existing Task", )) # Keep return table.grid()
def serverLink(director, id): "Returns link to server information" server = None link = "None" settings = director.clerk.getQESettings(where="simulationid='%s'" % id) if not settings: # or not settings[0]: return link setting = settings[0] server = director.clerk.getServers(id=setting.serverid) if not server: return link link = lc.link(label=server.address, Class="action-link", tip="Show details of computational cluster", onclick=select(id='').append( load(actor='server/load', routine='createDialog'))) return link
def serverLink(director, id): "Returns link to server information" server = None link = "None" settings = director.clerk.getQESettings(where="simulationid='%s'" % id ) if not settings:# or not settings[0]: return link setting = settings[0] server = director.clerk.getServers(id = setting.serverid ) if not server: return link link = lc.link(label = server.address, Class = "action-link", tip = "Show details of computational cluster", onclick = select(id='').append(load(actor='server/load', routine='createDialog')) ) return link
def _outputLinks(self, director): "Output links" doc = lc.document() # Container for links simrecord = SimulationRecord(director, self.id) typelist = simrecord.typeList( ) # simulation tasks type list, populated from SIMCHAINS chainsize = len(typelist) classes = self._typeClasses(director, self.linkorder, chainsize) for i in range(chainsize): doc.add( lc.link( label=typelist[i], Class=classes[i], onclick=load( actor=analyseActor(self.simtype), # XXX routine="outputs", type=typelist[i], simtype=self.simtype, id=self.id, linkorder=i))) return doc
def create(self): # computation = self.computation actor = self.actor director = self.director on_all_results_retrieved = self.on_all_results_retrieved # utilities domaccess = director.retrieveDOMAccessor('computation') orm = domaccess.orm db = orm.db # id = computation.id type = computation.getTableName() # the job job = computation.getJob(db) # always good to check the job from vnf.utils.job import check check(job, director) # the document to build doc = lc.document(Class='container', id='computation-results-container') # depending on retrieval status, we need to add some extra things to the document result_retrieval_status = computation.getResultRetrievalStatus(db) if result_retrieval_status is None: from vnf.utils.computation import start_results_retrieval start_results_retrieval(computation, director) result_retrieval_status = 'retrieving' refresh = select(element=doc).replaceBy( load(actor='loadvisual', visual='computation-results', id=id, type=type, on_all_results_retrieved = on_all_results_retrieved, ) ) if result_retrieval_status == 'retrieving': p = doc.paragraph(text=['Still retrieving results...']) from vnf.utils.computation import get_results_retrieval_task task = get_results_retrieval_task(computation, db) if not task: raise RuntimeError, 'there should be an itask working at retrieving '+\ 'results for computation %s, but we found none' % computation.id pbar = lc.progressbar( id = 'itask-%s-pbar' % task.id, status = 'Retrieving results...', percentage = 0, skip = 1000, ) pbar.onchecking = load( actor='itask', routine='checkProgress', id = task.id, ) if on_all_results_retrieved: from vnf.content import safe_eval_action onfinished = safe_eval_action(on_all_results_retrieved) else: onfinished = refresh pbar.onfinished = onfinished pbar.oncanceled = refresh doc.add(pbar) elif result_retrieval_status.find('failed') != -1: p = doc.paragraph(text=['failed to retrieve results']) # the action to load this visual (type: string) refresh_action_in_str = 'select(id="computation-results-container").replaceBy(load(actor="loadvisual", visual="computation-results", id="%s", type="%s", on_all_results_retrieved = "%s"))' % (id, type, on_all_results_retrieved or '') # link to restart retrieval l = lc.link( label = 'restart results retrieval', onclick = [ load(actor='computation', routine='restartResultsRetrieval', type = type, id = id, posterior_action = refresh_action_in_str, ) ], ) doc.add(l) elif result_retrieval_status == 'retrieved': pass else: raise NotImplementedError, 'computation: %s, retrieval status: %s' % ( type, result_retrieval_status) # display results results = computation.results.dereference(db) for k, r in results: ## alertdoc = doc.paragraph( ## text=['loading computation result %s %s. please wait...' % ( ## r.getTableName(), r.id)] ## ) title = '%s %s: expand for details' % (r.__class__.__name__, r.id) doc1 = doc.document( id = 'resultdoc-%s' % r.id, Class='container', title=title, collapsable=True, collapsed=True) doc1.onexpand = [ #select(element=alertdoc).hide(), select(element=doc1).replaceBy( load(actor='orm/%s' % r.getTableName(), routine='createGraphicalView', id = r.id) ) ] continue return doc
def _newTestAction(self, section): section.add(lc.link(label="Create New Test", Class="qe-action-new", onclick = load(actor = 'material_simulations/espresso-convergence/conv-create', id = self.id)) )
def _refreshAction(self, section): section.add(lc.link(label="Refresh", Class="qe-action-back", onclick = load(actor = 'material_simulations/espresso-convergence/view', id = self.id)) )