commit/galaxy-central: inithello: Improved display of genome download/index status.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b6f335d6986f/ changeset: b6f335d6986f user: inithello date: 2012-05-22 17:13:57 summary: Improved display of genome download/index status. affected #: 7 files diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 lib/galaxy/jobs/deferred/genome_transfer.py --- a/lib/galaxy/jobs/deferred/genome_transfer.py +++ b/lib/galaxy/jobs/deferred/genome_transfer.py @@ -202,7 +202,11 @@ os.chmod( destfilepath, 0644 ) fastaline = '\t'.join( [ dbkey, dbkey, params[ 'intname' ], os.path.abspath( destfilepath ) ] ) self._add_line( 'all_fasta', fastaline ) - job.state = self.app.model.DeferredJob.states.OK + if params[ 'indexes' ] is not None: + job.state = self.app.model.DeferredJob.states.WAITING + job.params[ 'indexjobs' ] = [] + else: + job.state = self.app.model.DeferredJob.states.OK job.params[ 'type' ] = 'finish_transfer' transfer.path = os.path.abspath(destfilepath) transfer.state = 'done' @@ -213,6 +217,7 @@ for indexer in params[ 'indexes' ]: incoming = dict(indexer=indexer, dbkey=params[ 'dbkey' ], intname=params[ 'intname' ], path=transfer.path, user=params['user'] ) deferred = self.tool.execute( self, set_output_hid=False, history=None, incoming=incoming, transfer=transfer, deferred=job ) + job.params[ 'indexjobs' ].append( deferred[0].id ) return self.app.model.DeferredJob.states.OK def _check_compress( self, filepath ): diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 lib/galaxy/tools/genome_index/__init__.py --- a/lib/galaxy/tools/genome_index/__init__.py +++ b/lib/galaxy/tools/genome_index/__init__.py @@ -63,6 +63,8 @@ if gitd: destination = None + alldone = True + indexjobs = gitd.deferred.params[ 'indexjobs' ] tdtman = ToolDataTableManager() xmltree = tdtman.load_from_config_file(app.config.tool_data_table_config_path) for node in xmltree: @@ -163,6 +165,14 @@ self._check_link( fasta, target ) for line in location: self._add_line( line[ 'file' ], line[ 'line' ] ) + for indexjob in indexjobs: + js = sa_session.query( model.Job ).filter_by( id=indexjob ).first() + if js.state not in [ 'ok', 'done', 'error' ]: + alldone = False + if alldone: + gitd.deferred.state = 'ok' + sa_session.add( gitd.deferred ) + sa_session.flush() def _check_link( self, targetfile, symlink ): target = os.path.relpath( targetfile, os.path.dirname( symlink ) ) diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 lib/galaxy/tools/genome_index/index_genome.py --- a/lib/galaxy/tools/genome_index/index_genome.py +++ b/lib/galaxy/tools/genome_index/index_genome.py @@ -58,7 +58,7 @@ def _do_rsync( self, idxpath ): self._log( 'Trying rsync at %s/%s%s' % ( self.rsync_url, self.genome, idxpath ) ) - result = subprocess.call( shlex.split( 'rsync %s %s/%s%s .' % ( self.rsync_opts, self.rsync_url, self.genome, idxpath ) ) ) + result = subprocess.call( shlex.split( 'rsync %s %s/%s%s .' % ( self.rsync_opts, self.rsync_url, self.genome, idxpath ) ), stderr=self.logfile ) if result != 0: self._log( 'Rsync failed or index not found. Generating.' ) else: diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 lib/galaxy/web/controllers/data_admin.py --- a/lib/galaxy/web/controllers/data_admin.py +++ b/lib/galaxy/web/controllers/data_admin.py @@ -143,34 +143,57 @@ def monitor_status( self, trans, **kwd ): params = util.Params( kwd ) jobid = params.get( 'job', '' ) - chains = params.get( 'chains', [] ) jobs = self._get_jobs( jobid, trans ) - return trans.fill_template( '/admin/data_admin/download_status.mako', mainjob=jobid, jobs=jobs ) + jsonjobs = json.dumps( jobs ) + return trans.fill_template( '/admin/data_admin/download_status.mako', mainjob=jobid, jobs=jobs, jsonjobs=jsonjobs ) @web.expose @web.require_admin - def ajax_statusupdate( self, trans, **kwd ): + def get_jobs( self, trans, **kwd ): sa_session = trans.app.model.context.current jobs = [] params = util.Params( kwd ) jobid = params.get( 'jobid', '' ) jobs = self._get_jobs( jobid, trans ) - return trans.fill_template( '/admin/data_admin/ajax_statusupdate.mako', mainjob=jobid, jobs=jobs ) + return trans.fill_template( '/admin/data_admin/ajax_status.mako', json=json.dumps( jobs ) ) + + @web.expose + @web.require_admin + def job_status( self, trans, **kwd ): + params = util.Params( kwd ) + jobid = params.get( 'jobid', None ) + jobtype = params.get( 'jobtype', None ) + fillvals = None + fillvals = self._get_job( jobid, jobtype, trans ) + return trans.fill_template( '/admin/data_admin/ajax_status.mako', json=json.dumps( fillvals ) ) + + def _get_job( self, jobid, jobtype, trans ): + sa = trans.app.model.context.current + if jobtype == 'liftover': + job = sa.query( model.TransferJob ).filter_by( id=jobid ).first() + joblabel = 'Download liftOver' + elif jobtype == 'transfer': + job = sa.query( model.TransferJob ).filter_by( id=jobid ).first() + joblabel = 'Download Genome' + elif jobtype == 'deferred': + job = sa.query( model.DeferredJob ).filter_by( id=jobid ).first() + joblabel = 'Main Controller' + elif jobtype == 'index': + job = sa.query( model.Job ).filter_by( id=jobid ).first() + joblabel = 'Index Genome' + return dict( status=job.state, jobid=job.id, style=self.jobstyles[job.state], type=jobtype, label=joblabel ) def _get_jobs( self, jobid, trans ): jobs = [] job = trans.app.job_manager.deferred_job_queue.plugins['GenomeTransferPlugin'].get_job_status( jobid ) sa_session = trans.app.model.context.current + jobs.append( self._get_job( job.id, 'deferred', trans ) ) + jobs.append( self._get_job( job.transfer_job.id, 'transfer', trans ) ) idxjobs = sa_session.query( model.GenomeIndexToolData ).filter_by( deferred_job_id=job.id, transfer_job_id=job.transfer_job.id ).all() - if job.params[ 'liftover' ] is not None: + if job.params.has_key( 'liftover' ): for jobid in job.params[ 'liftover' ]: - lo_job = trans.app.job_manager.deferred_job_queue.plugins['LiftOverTransferPlugin'].get_job_status( jobid ) - jobs.append( dict( jobid=lo_job.id, state=lo_job.state, type='Download liftOver' ) ) + jobs.append( self._get_job( jobid, 'liftover', trans ) ) for idxjob in idxjobs: - jobentry = sa_session.query( model.Job ).filter_by( id=idxjob.job_id ).first() - jobs.append( dict( jobid=jobentry.id, state=jobentry.state, type='Index Genome' ) ) - jobs.append( dict ( jobid=job.id, state=job.state, type='Main Job' ) ) - jobs.append( dict ( jobid=job.transfer_job.id, state=job.transfer_job.state, type='Download Genome' ) ) - for je in jobs: - je[ 'style' ] = self.jobstyles[ je[ 'state' ] ] + #print idxjob + jobs.append( self._get_job( idxjob.job_id, 'index', trans ) ) return jobs diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 templates/admin/data_admin/ajax_status.mako --- /dev/null +++ b/templates/admin/data_admin/ajax_status.mako @@ -0,0 +1,1 @@ +${json} \ No newline at end of file diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 templates/admin/data_admin/ajax_statusupdate.mako --- a/templates/admin/data_admin/ajax_statusupdate.mako +++ /dev/null @@ -1,5 +0,0 @@ -%for jobentry in jobs: - <div class="${jobentry['style']} dialog-box" id="job${jobentry['jobid']}" data-state="${jobentry['state']}" data-jobid="${jobentry['jobid']}" data-type="${jobentry['type']}"> - <span class="inline">${jobentry['type']}</span> - </div> -%endfor diff -r cfc6b7b246e72ffcfbf2b88569e426fd22d4839b -r b6f335d6986fee3732c01cd43afd82dad1cca273 templates/admin/data_admin/download_status.mako --- a/templates/admin/data_admin/download_status.mako +++ b/templates/admin/data_admin/download_status.mako @@ -34,32 +34,82 @@ </div></%def><p>The genome build and any selected indexers have been added to the job queue. Below you will see the status of each job.</p> -<div id="jobStatus" data-job="${mainjob}"> -%for jobentry in jobs: - <div class="${jobentry['style']} dialog-box" id="job${jobentry['jobid']}" data-state="${jobentry['state']}" data-jobid="${jobentry['jobid']}" data-type="${jobentry['type']}"> - <span class="inline">${jobentry['type']}</span> - </div> -%endfor -</div> +<table id="jobStatus"> +</table><a href="${h.url_for( controller='data_admin', action='manage_data' )}">Return to the download form</a><script type="text/javascript"> - function getNewHtml(jobid) { - $.get('${h.url_for( controller='data_admin', action='ajax_statusupdate' )}', { jobid: jobid }, function(data) { - $('#jobStatus').html(data); - }); - $('#jobStatus').children().each(function() { - state = $(this).attr('class'); - //alert(state); - if (state != 'panel-done-message dialog-box' && state != 'panel-error-message dialog-box') { - setJobRefreshers(); - return; + jobs = ${jsonjobs} + + function makeHTML(jobrow) { + jc = 'jobrow ' + jobrow['style']; + djid = jobrow['jobid']; + jt = jobrow['type']; + idval = jt + '-job-' + djid; + return '<tr id="' + idval + '" class="' + jc + '" data-status="' + jobrow['status'] + '" data-jobid="' + djid + '" data-jobtype="' + jt + '">' + + '<td style="padding: 0px 5px 0px 30px;">' + jobrow['label'] + '</td>' + + '<td style="padding: 0px 5px;">' + jobrow['status'] + '</td></tr>'; + } + + function getNewHtml(jobid, jobtype, elm) { + $.get('${h.url_for( controller='data_admin', action='job_status' )}', { jobid: jobid, jobtype: jobtype }, function(data) { + jsondata = JSON.parse(data); + status = jsondata['status']; + htmldata = makeHTML(jsondata); + idval = '#' + jobtype + '-job-' + jobid; + if (htmldata != undefined) { + $(elm).replaceWith(htmldata); } }); } - function setJobRefreshers() { - $('#jobStatus').delay(3000).queue(function(n) { getNewHtml($(this).attr('data-job')); n(); }).fadeIn(750); + + function checkJobs() { + var alldone = true; + var mainjob; + $('.jobrow').each(function() { + status = $(this).attr('data-status'); + if ($(this).attr('data-jobtype') == 'deferred') { + mainjob = $(this).attr('data-jobid'); + } + if (status != 'done' && status != 'error' && status != 'ok') { + alldone = false; + getNewHtml($(this).attr('data-jobid'), $(this).attr('data-jobtype'), $(this)); + } + }); + if (!alldone) { + checkForNewJobs(mainjob); + $('#jobStatus').delay(3000).queue(function(n) { + checkJobs(); + n(); + }); + } } + + function checkForNewJobs(mainjob) { + $.get('${h.url_for( controller='data_admin', action='get_jobs' )}', { jobid: mainjob }, function(data) { + jsondata = JSON.parse(data); + for (i in jsondata) { + if (jobs[i] == undefined) { + $('#jobStatus').append(makeHTML(jsondata[i])); + jobs.push(jsondata[i]); + } + } + }); + } + $(document).ready(function() { - setJobRefreshers(); + for (job in jobs) { + jobrow = jobs[job]; + $('#jobStatus').append(makeHTML(jobrow)); + if (jobrow['type'] == 'deferred') { + $('#jobStatus').delay(5000).queue(function(n) { + checkForNewJobs(jobrow['jobid']); + n(); + }).fadeIn(); + } + } + $('#jobStatus').delay(3000).queue(function(n) { + checkJobs(); + n(); + }).fadeIn(); }); </script> \ No newline at end of file Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket