Verified Commit 35765495 authored by Peter Stanko's avatar Peter Stanko
Browse files

Submission service added to submission processor

parent 7560f739
Pipeline #32275 failed with stage
in 2 minutes and 16 seconds
...@@ -8,6 +8,7 @@ from portal.database import Project, Submission, SubmissionState, Worker ...@@ -8,6 +8,7 @@ from portal.database import Project, Submission, SubmissionState, Worker
from portal.database.enums import WorkerState from portal.database.enums import WorkerState
from portal.service import errors from portal.service import errors
from portal.storage import UploadedEntity, entities from portal.storage import UploadedEntity, entities
from portal.service.submissions import SubmissionsService
log = logger.get_logger(__name__) log = logger.get_logger(__name__)
...@@ -18,6 +19,10 @@ class SubmissionProcessor: ...@@ -18,6 +19,10 @@ class SubmissionProcessor:
from portal.service.services_collection import ServicesCollection from portal.service.services_collection import ServicesCollection
self._services = ServicesCollection() self._services = ServicesCollection()
@property
def submission_service(self) -> SubmissionsService:
return self._services.submissions(self.submission)
@property @property
def submission(self) -> Submission: def submission(self) -> Submission:
return self._submission return self._submission
...@@ -42,7 +47,7 @@ class SubmissionProcessor: ...@@ -42,7 +47,7 @@ class SubmissionProcessor:
def reset_task_id(self, state=None, message: str = None): def reset_task_id(self, state=None, message: str = None):
if state is not None: if state is not None:
self._services.submissions.set_state(state, message=message) self.submission_service.set_state(state, message=message)
self.submission.async_task_id = None self.submission.async_task_id = None
self._save_submission() self._save_submission()
...@@ -144,8 +149,7 @@ class SubmissionProcessor: ...@@ -144,8 +149,7 @@ class SubmissionProcessor:
def execute_submission(self, worker: Worker): def execute_submission(self, worker: Worker):
worker_client = self._services.workers(worker).worker_client worker_client = self._services.workers(worker).worker_client
message = "Executing submission using worker" message = "Executing submission using worker"
self._services.submissions(self.submission).set_state(SubmissionState.IN_PROGRESS, self.submission_service.set_state(SubmissionState.IN_PROGRESS, message=message)
message=message)
self._save_submission() self._save_submission()
worker_client.execute_submission(self.submission) worker_client.execute_submission(self.submission)
...@@ -175,8 +179,7 @@ class SubmissionProcessor: ...@@ -175,8 +179,7 @@ class SubmissionProcessor:
return self.submission return self.submission
def abort_submission(self, message: str = 'Unknown error!'): def abort_submission(self, message: str = 'Unknown error!'):
self._services.submissions(self.submission).set_state(SubmissionState.ABORTED, self.submission_service.set_state(SubmissionState.ABORTED, message=message)
message=message)
def _save_submission(self): def _save_submission(self):
self._services.submissions.write_entity(self.submission) self._services.submissions.write_entity(self.submission)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment