|
@@ -5,21 +5,13 @@ from shutil import rmtree, copytree
|
|
|
from time import time
|
|
|
from uuid import uuid1
|
|
|
|
|
|
-from eventlet import spawn_after
|
|
|
-
|
|
|
from pycs import ApplicationStatus
|
|
|
from pycs.observable import ObservableDict
|
|
|
-from pycs.pipeline.PipelineManager import PipelineManager
|
|
|
from pycs.projects.Project import Project
|
|
|
|
|
|
|
|
|
class ProjectManager(ObservableDict):
|
|
|
- DEFAULT_PIPELINE_TIMEOUT = 120
|
|
|
-
|
|
|
def __init__(self, app_status: ApplicationStatus):
|
|
|
- self.pipeline_manager = None
|
|
|
- self.quit_pipeline_thread = None
|
|
|
-
|
|
|
# TODO create projects folder if it does not exist
|
|
|
self.app_status = app_status
|
|
|
|
|
@@ -96,27 +88,8 @@ class ProjectManager(ObservableDict):
|
|
|
|
|
|
project = self[uuid]
|
|
|
|
|
|
- # abort pipeline termination
|
|
|
- if self.quit_pipeline_thread is not None:
|
|
|
- self.quit_pipeline_thread.cancel()
|
|
|
- self.quit_pipeline_thread = None
|
|
|
-
|
|
|
- # create pipeline if it does not exist already
|
|
|
- if self.pipeline_manager is None:
|
|
|
- self.pipeline_manager = PipelineManager(project)
|
|
|
-
|
|
|
- # run jobs
|
|
|
- for file_id in identifiers:
|
|
|
- if file_id in project['data'].keys():
|
|
|
- self.pipeline_manager.run(project['data'][file_id])
|
|
|
-
|
|
|
- # quit timeout thread
|
|
|
- if self.quit_pipeline_thread is not None:
|
|
|
- self.quit_pipeline_thread.cancel()
|
|
|
- self.quit_pipeline_thread = None
|
|
|
-
|
|
|
- # schedule timeout thread
|
|
|
- self.quit_pipeline_thread = spawn_after(self.DEFAULT_PIPELINE_TIMEOUT, self.__quit_pipeline)
|
|
|
+ # run prediction
|
|
|
+ project.predict(identifiers)
|
|
|
|
|
|
def fit(self, uuid):
|
|
|
# abort if uuid is no valid key
|
|
@@ -125,28 +98,5 @@ class ProjectManager(ObservableDict):
|
|
|
|
|
|
project = self[uuid]
|
|
|
|
|
|
- # abort pipeline termination
|
|
|
- if self.quit_pipeline_thread is not None:
|
|
|
- self.quit_pipeline_thread.cancel()
|
|
|
- self.quit_pipeline_thread = None
|
|
|
-
|
|
|
- # create pipeline if it does not exist already
|
|
|
- if self.pipeline_manager is None:
|
|
|
- self.pipeline_manager = PipelineManager(project)
|
|
|
-
|
|
|
# run fit
|
|
|
- self.pipeline_manager.fit()
|
|
|
-
|
|
|
- # quit timeout thread
|
|
|
- if self.quit_pipeline_thread is not None:
|
|
|
- self.quit_pipeline_thread.cancel()
|
|
|
- self.quit_pipeline_thread = None
|
|
|
-
|
|
|
- # schedule timeout thread
|
|
|
- self.quit_pipeline_thread = spawn_after(self.DEFAULT_PIPELINE_TIMEOUT, self.__quit_pipeline)
|
|
|
-
|
|
|
- def __quit_pipeline(self):
|
|
|
- if self.pipeline_manager is not None:
|
|
|
- self.pipeline_manager.close()
|
|
|
- self.pipeline_manager = None
|
|
|
- self.quit_pipeline_thread = None
|
|
|
+ project.fit()
|