Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(progress): correctly handle running and stopped jobs (#258) #258

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The list of contributors in alphabetical order:
- `Dinos Kousidis <https://orcid.org/0000-0002-4914-4289>`_
- `Jan Okraska <https://orcid.org/0000-0002-1416-3244>`_
- `Lukas Heinrich <https://orcid.org/0000-0002-4048-7584>`_
- `Marco Donadoni <https://orcid.org/0000-0003-2922-5505>`_
- `Marco Vidal <https://orcid.org/0000-0002-9363-4971>`_
- `Rokas Maciulaitis <https://orcid.org/0000-0003-1064-6967>`_
- `Sinclert Pérez <https://www.linkedin.com/in/sinclert>`_
Expand Down
4 changes: 4 additions & 0 deletions reana_workflow_engine_yadage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ class JobStatus(str, Enum):
failed = "failed"
stopped = "stopped"
queued = "queued"


JOB_TERMINAL_STATUSES = [JobStatus.finished, JobStatus.failed, JobStatus.stopped]
"""Statuses that a job can be in at the end of its execution."""
17 changes: 10 additions & 7 deletions reana_workflow_engine_yadage/externalbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
from packtivity.syncbackends import build_job, finalize_inputs, packconfig, publish
from reana_commons.api_client import JobControllerAPIClient as RJC_API_Client

from .config import LOGGING_MODULE, MOUNT_CVMFS, JobStatus, WORKFLOW_KERBEROS
from .config import (
JOB_TERMINAL_STATUSES,
LOGGING_MODULE,
MOUNT_CVMFS,
JobStatus,
WORKFLOW_KERBEROS,
)

log = logging.getLogger(LOGGING_MODULE)

Expand Down Expand Up @@ -156,11 +162,8 @@
self.jobs_statuses[job_id] = self._get_job_status_from_controller(job_id)

def _should_refresh_job_status(self, job_id: str) -> bool:
if job_id in self.jobs_statuses:
status = self.jobs_statuses[job_id]
return status == JobStatus.started
else:
return True
status = self.jobs_statuses.get(job_id)
return status not in JOB_TERMINAL_STATUSES

Check warning on line 166 in reana_workflow_engine_yadage/externalbackend.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_yadage/externalbackend.py#L165-L166

Added lines #L165 - L166 were not covered by tests

def _get_state(self, resultproxy: ReanaExternalProxy) -> str:
"""Get the packtivity state."""
Expand All @@ -171,7 +174,7 @@

def ready(self, resultproxy: ReanaExternalProxy) -> bool:
"""Check if a packtivity is finished."""
return self._get_state(resultproxy) != JobStatus.started
return self._get_state(resultproxy) in JOB_TERMINAL_STATUSES

Check warning on line 177 in reana_workflow_engine_yadage/externalbackend.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_yadage/externalbackend.py#L177

Added line #L177 was not covered by tests

def successful(self, resultproxy: ReanaExternalProxy) -> bool:
"""Check if the packtivity was successful."""
Expand Down