Skip to content

Commit

Permalink
status: retrieve job status from Job table
Browse files Browse the repository at this point in the history
* Reads job status from Job table to get the running jobs
  as the `job_progress` in the Workflow table is not correctly
  updated, finished jobs are reported as running creating an exception
  while trying to delete a job which doesn't exist (for more see
  reanahub#299)
  (closes reanahub/reana#266).
  • Loading branch information
Diego Rodriguez committed Feb 11, 2020
1 parent 789454d commit 6d0dbf6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reana_workflow_controller/workflow_run_manager.py
Expand Up @@ -29,7 +29,7 @@
create_cvmfs_storage_class, format_cmd)
from reana_db.config import SQLALCHEMY_DATABASE_URI
from reana_db.database import Session
from reana_db.models import Job
from reana_db.models import Job, JobStatus

from reana_workflow_controller.errors import (REANAInteractiveSessionError,
REANAWorkflowControllerError)
Expand Down Expand Up @@ -221,9 +221,9 @@ def _workflow_engine_env_vars(self):
def get_workflow_running_jobs_as_backend_ids(self):
"""Get all running jobs of a workflow as backend job IDs."""
session = Session.object_session(self.workflow)
job_list = self.workflow.job_progress.get(
'running', {}).get('job_ids', [])
rows = session.query(Job).filter(Job.id_.in_(job_list))
rows = session.query(Job).filter_by(
workflow_uuid=str(self.workflow.id_),
status=JobStatus.running)
backend_ids = [j.backend_job_id for j in rows.all()]
return backend_ids

Expand Down

0 comments on commit 6d0dbf6

Please sign in to comment.