commit/galaxy-central: natefoo: Better queries for the job queue, especially when checking the user job count.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/a638b139a241/ changeset: a638b139a241 user: natefoo date: 2011-12-13 05:26:59 summary: Better queries for the job queue, especially when checking the user job count. affected #: 1 file diff -r 55bb95ec5c2a3ce2ef7eaf0a79ec60365d7d1aec -r a638b139a24187786916bc9b5c5491f4fab744fc lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -2,7 +2,6 @@ import galaxy from galaxy import util, model -from galaxy.model.orm import lazyload from galaxy.datatypes.tabular import * from galaxy.datatypes.interval import * # tabular/interval imports appear to be unused. Clean up? @@ -114,7 +113,7 @@ else: log.debug( "no runner: %s is still in new state, adding to the jobs queue" %job.id ) self.queue.put( ( job.id, job.tool_id ) ) - for job in self.sa_session.query( model.Job ).options( lazyload( "external_output_metadata" ), lazyload( "parameters" ) ).filter( ( model.Job.state == model.Job.states.RUNNING ) | ( model.Job.state == model.Job.states.QUEUED ) ): + for job in self.sa_session.query( model.Job ).enable_eagerloads( False ).filter( ( model.Job.state == model.Job.states.RUNNING ) | ( model.Job.state == model.Job.states.QUEUED ) ): if job.tool_id not in self.app.toolbox.tools_by_id: log.warning( "Tool '%s' removed from tool config, unable to recover job: %s" % ( job.tool_id, job.id ) ) JobWrapper( job, self ).fail( 'This tool was disabled before the job completed. Please contact your Galaxy administrator, or' ) @@ -161,8 +160,7 @@ # Clear the session so we get fresh states for job and all datasets self.sa_session.expunge_all() # Fetch all new jobs - jobs_to_check = self.sa_session.query( model.Job ) \ - .options( lazyload( "external_output_metadata" ), lazyload( "parameters" ) ) \ + jobs_to_check = self.sa_session.query( model.Job ).enable_eagerloads( False ) \ .filter( model.Job.state == model.Job.states.NEW ).all() else: # Get job objects and append to watch queue for any which were @@ -264,21 +262,19 @@ if not self.app.config.user_job_limit: return JOB_READY if job.user: - user_jobs = self.sa_session.query( model.Job ) \ - .options( lazyload( "external_output_metadata" ), lazyload( "parameters" ) ) \ - .filter( and_( model.Job.user_id == job.user.id, - or_( model.Job.state == model.Job.states.RUNNING, - model.Job.state == model.Job.states.QUEUED ) ) ).all() + count = self.sa_session.query( model.Job ).enable_eagerloads( False ) \ + .filter( and_( model.Job.user_id == job.user.id, + or_( model.Job.state == model.Job.states.RUNNING, + model.Job.state == model.Job.states.QUEUED ) ) ).count() elif job.galaxy_session: - user_jobs = self.sa_session.query( model.Job ) \ - .options( lazyload( "external_output_metadata" ), lazyload( "parameters" ) ) \ - .filter( and_( model.Job.session_id == job.galaxy_session.id, - or_( model.Job.state == model.Job.states.RUNNING, - model.Job.state == model.Job.states.QUEUED ) ) ).all() + count = self.sa_session.query( model.Job ).enable_eagerloads( False ) \ + .filter( and_( model.Job.session_id == job.galaxy_session.id, + or_( model.Job.state == model.Job.states.RUNNING, + model.Job.state == model.Job.states.QUEUED ) ) ).count() else: log.warning( 'Job %s is not associated with a user or session so job concurrency limit cannot be checked.' % job.id ) return JOB_READY - if len( user_jobs ) >= self.app.config.user_job_limit: + if count >= self.app.config.user_job_limit: return JOB_WAIT return JOB_READY @@ -1245,8 +1241,7 @@ # Clear the session so we get fresh states for job and all datasets self.sa_session.expunge_all() # Fetch all new jobs - newly_deleted_jobs = self.sa_session.query( model.Job ) \ - .options( lazyload( "external_output_metadata" ), lazyload( "parameters" ) ) \ + newly_deleted_jobs = self.sa_session.query( model.Job ).enable_eagerloads( False ) \ .filter( model.Job.state == model.Job.states.DELETED_NEW ).all() for job in newly_deleted_jobs: jobs_to_check.append( ( job, None ) ) 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