commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7c2c5f45c34f/ Changeset: 7c2c5f45c34f User: natefoo Date: 2014-11-18 14:10:36+00:00 Summary: Add a table for tracking the history of job states. Affected #: 4 files diff -r 7c6c900abf1f2968dab4552b9e589b0ffe94cb69 -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -982,7 +982,9 @@ self.sa_session.flush() if info: job.info = info - job.state = state + # FIXME: + #job.state = state + job.set_state( state ) self.sa_session.add( job ) self.sa_session.flush() @@ -1071,7 +1073,7 @@ log.warning( "finish(): %s not found, but %s is not empty, so it will be used instead" % ( dataset_path.false_path, dataset_path.real_path ) ) else: # Prior to fail we need to set job.state - job.state = final_job_state + job.set_state( final_job_state ) return self.fail( "Job %s's output dataset(s) could not be read" % job.id ) job_context = ExpressionContext( dict( stdout=job.stdout, stderr=job.stderr ) ) diff -r 7c6c900abf1f2968dab4552b9e589b0ffe94cb69 -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -334,6 +334,7 @@ self.handler = None self.exit_code = None self._init_metrics() + self.state_history.append( JobStateHistory( self ) ) @property def finished( self ): @@ -476,9 +477,11 @@ state is propagated down to datasets. """ self.state = state + self.state_history.append( JobStateHistory( self ) ) # For historical reasons state propogates down to datasets - for da in self.output_datasets: - da.dataset.state = state + # FIXME: is this used anywhere? + #for da in self.output_datasets: + # da.dataset.state = state def get_param_values( self, app, ignore_errors=False ): """ Read encoded parameter values from the database and turn back into a @@ -738,6 +741,13 @@ self.dataset = dataset +class JobStateHistory( object ): + def __init__( self, job ): + self.job = job + self.state = job.state + self.info = job.info + + class ImplicitlyCreatedDatasetCollectionInput( object ): def __init__( self, name, input_dataset_collection ): self.name = name diff -r 7c6c900abf1f2968dab4552b9e589b0ffe94cb69 -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 lib/galaxy/model/mapping.py --- a/lib/galaxy/model/mapping.py +++ b/lib/galaxy/model/mapping.py @@ -411,6 +411,14 @@ Column( "params", TrimmedString(255), index=True ), Column( "handler", TrimmedString( 255 ), index=True ) ) +model.JobStateHistory.table = Table( "job_state_history", metadata, + Column( "id", Integer, primary_key=True ), + Column( "create_time", DateTime, default=now ), + Column( "update_time", DateTime, default=now, onupdate=now ), + Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ), + Column( "state", String( 64 ), index=True ), + Column( "info", TrimmedString( 255 ) ) ) + model.JobParameter.table = Table( "job_parameter", metadata, Column( "id", Integer, primary_key=True ), Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ), @@ -1805,6 +1813,11 @@ model.LibraryDatasetDatasetAssociation, lazy=False ) ) ) simple_mapping( + model.JobStateHistory, + job=relation( model.Job, backref="state_history" ), +) + +simple_mapping( model.JobMetricText, job=relation( model.Job, backref="text_metrics" ), ) diff -r 7c6c900abf1f2968dab4552b9e589b0ffe94cb69 -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 lib/galaxy/model/migrate/versions/0124_job_state_history.py --- /dev/null +++ b/lib/galaxy/model/migrate/versions/0124_job_state_history.py @@ -0,0 +1,48 @@ +""" +Migration script for the job state history table +""" + +from sqlalchemy import * +from sqlalchemy.orm import * +from migrate import * +from migrate.changeset import * +from galaxy.model.custom_types import * + +import datetime +now = datetime.datetime.utcnow + +import logging +log = logging.getLogger( __name__ ) + +metadata = MetaData() + +JobStateHistory_table = Table( "job_state_history", metadata, + Column( "id", Integer, primary_key=True ), + Column( "create_time", DateTime, default=now ), + Column( "update_time", DateTime, default=now, onupdate=now ), + Column( "job_id", Integer, ForeignKey( "job.id" ), index=True ), + Column( "state", String( 64 ), index=True ), + Column( "info", TrimmedString( 255 ) ) +) + +def upgrade(migrate_engine): + metadata.bind = migrate_engine + print __doc__ + metadata.reflect() + + try: + JobStateHistory_table.create() + except Exception as e: + print str(e) + log.exception("Creating %s table failed: %s" % (JobStateHistory_table.name, str( e ) ) ) + + +def downgrade(migrate_engine): + metadata.bind = migrate_engine + metadata.reflect() + + try: + JobStateHistory_table.drop() + except Exception as e: + print str(e) + log.exception("Dropping %s table failed: %s" % (JobStateHistory_table.name, str( e ) ) ) https://bitbucket.org/galaxy/galaxy-central/commits/e47c67efeda7/ Changeset: e47c67efeda7 User: natefoo Date: 2014-11-18 15:07:37+00:00 Summary: Ensure all job state changes will be added to the history state table. Affected #: 6 files diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -956,7 +956,7 @@ dataset_assoc.dataset.dataset.state = dataset_assoc.dataset.dataset.states.PAUSED dataset_assoc.dataset.info = message self.sa_session.add( dataset_assoc.dataset ) - job.state = job.states.PAUSED + job.set_state( job.states.PAUSED ) self.sa_session.add( job ) def mark_as_resubmitted( self ): @@ -965,7 +965,7 @@ for dataset in [ dataset_assoc.dataset for dataset_assoc in job.output_datasets + job.output_library_datasets ]: dataset._state = model.Dataset.states.RESUBMITTED self.sa_session.add( dataset ) - job.state = model.Job.states.RESUBMITTED + job.set_state( model.Job.states.RESUBMITTED ) self.sa_session.add( job ) self.sa_session.flush() @@ -982,8 +982,6 @@ self.sa_session.flush() if info: job.info = info - # FIXME: - #job.state = state job.set_state( state ) self.sa_session.add( job ) self.sa_session.flush() diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/jobs/handler.py --- a/lib/galaxy/jobs/handler.py +++ b/lib/galaxy/jobs/handler.py @@ -127,7 +127,7 @@ log.debug( "(%s) Job runner assigned but no external ID recorded, adding to the job handler queue" % job.id ) job.job_runner_name = None if self.track_jobs_in_database: - job.state = model.Job.states.NEW + job.set_state( model.Job.states.NEW ) else: self.queue.put( ( job.id, job.tool_id ) ) elif job.job_runner_name is not None and job.job_runner_external_id is not None and job.destination_id is None: @@ -143,7 +143,7 @@ # Never (fully) dispatched log.debug( "(%s) No job runner assigned and job still in '%s' state, adding to the job handler queue" % ( job.id, job.state ) ) if self.track_jobs_in_database: - job.state = model.Job.states.NEW + job.set_state( model.Job.states.NEW ) else: self.queue.put( ( job.id, job.tool_id ) ) else: @@ -286,7 +286,7 @@ log.info( "(%d) Job deleted by admin while still queued" % job.id ) elif job_state == JOB_USER_OVER_QUOTA: log.info( "(%d) User (%s) is over quota: job paused" % ( job.id, job.user_id ) ) - job.state = model.Job.states.PAUSED + job.set_state( model.Job.states.PAUSED ) for dataset_assoc in job.output_datasets + job.output_library_datasets: dataset_assoc.dataset.dataset.state = model.Dataset.states.PAUSED dataset_assoc.dataset.info = "Execution of this dataset's job is paused because you were over your disk quota at the time it was ready to run" diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -473,15 +473,10 @@ self.post_job_actions.append( PostJobActionAssociation( pja, self ) ) def set_state( self, state ): """ - This is the only set method that performs extra work. In this case, the - state is propagated down to datasets. + Save state history """ self.state = state self.state_history.append( JobStateHistory( self ) ) - # For historical reasons state propogates down to datasets - # FIXME: is this used anywhere? - #for da in self.output_datasets: - # da.dataset.state = state def get_param_values( self, app, ignore_errors=False ): """ Read encoded parameter values from the database and turn back into a @@ -556,7 +551,7 @@ return rval def set_final_state( self, final_state ): - self.state = final_state + self.set_state( final_state ) if self.workflow_invocation_step: self.workflow_invocation_step.update() diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/tools/actions/__init__.py --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -377,7 +377,7 @@ assert GALAXY_URL is not None, "GALAXY_URL parameter missing in tool config." redirect_url += "&GALAXY_URL=%s" % GALAXY_URL # Job should not be queued, so set state to ok - job.state = trans.app.model.Job.states.OK + job.set_state( trans.app.model.Job.states.OK ) job.info = "Redirected to: %s" % redirect_url trans.sa_session.add( job ) trans.sa_session.flush() diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/tools/actions/upload_common.py --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -367,7 +367,7 @@ job.history_id = history.id job.tool_id = tool.id job.tool_version = tool.version - job.state = job.states.UPLOAD + job.set_state( job.states.UPLOAD ) trans.sa_session.add( job ) trans.sa_session.flush() log.info( 'tool %s created job id %d' % ( tool.id, job.id ) ) @@ -393,7 +393,7 @@ trans.sa_session.add( dataset ) # open( dataset.file_name, "w" ).close() job.object_store_id = object_store_id - job.state = job.states.NEW + job.set_state( job.states.NEW ) job.set_handler(tool.get_job_handler(None)) trans.sa_session.add( job ) trans.sa_session.flush() diff -r 7c2c5f45c34f3c92e51e154c30472f2982a40271 -r e47c67efeda7fa66f9782aae5e2c62ab640310bc lib/galaxy/web/base/controllers/admin.py --- a/lib/galaxy/web/base/controllers/admin.py +++ b/lib/galaxy/web/base/controllers/admin.py @@ -1084,7 +1084,7 @@ if trans.app.config.track_jobs_in_database: job = trans.sa_session.query( trans.app.model.Job ).get( job_id ) job.stderr = error_msg - job.state = trans.app.model.Job.states.DELETED_NEW + job.set_state( trans.app.model.Job.states.DELETED_NEW ) trans.sa_session.add( job ) else: trans.app.job_manager.job_stop_queue.put( job_id, error_msg=error_msg ) 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)
-
commits-noreply@bitbucket.org