diff --git a/server/api/models.py b/server/api/models.py index cbea0e4b227bcd40e965bf92f990e247447eaf9d..71e9d3176a92afdc627400a8e9e7a777931f9a5b 100644 --- a/server/api/models.py +++ b/server/api/models.py @@ -30,7 +30,7 @@ from .managers import ( PhenotypeCategoryManager, ) -from .galaxy import GalaxyRunner, get_history_status +from .galaxy import GalaxyRunner, get_history_status, get_workflow_invocation_status from .exceptions import RessourceAlreadyExists # Create your models here. @@ -161,7 +161,9 @@ class Experiment(models.Model): Line_F=models.F("experiment_cc_line__cc_line_f__id_cc"), Sex=models.F("experiment_cc_line__sex"), ) - .values("id", "CC_ID", "value", "phenotype_type", "Line_M", "Line_F", "Sex",) + .values( + "id", "CC_ID", "value", "phenotype_type", "Line_M", "Line_F", "Sex", + ) ) df_phenotypes = pd.DataFrame(data=phenotypes) @@ -639,14 +641,29 @@ class Analysis(models.Model): @property def history_status(self): - try: - history_status = get_history_status(self.galaxy_history_id) - return history_status - except ConnectionError: + if self.galaxy_history_id: + try: + history_status = get_history_status(self.galaxy_history_id) + return history_status + except ConnectionError: + return None + else: return None - def get_workflow_job_params(self): + @property + def workflow_invocation_status(self): + if self.galaxy_workflow_invocation_id: + try: + status = get_workflow_invocation_status( + self.galaxy_workflow_id, self.galaxy_workflow_invocation_id + ) + return status + except ConnectionError: + return None + else: + return None + def get_workflow_job_params(self): runner = GalaxyRunner() gi = runner.galaxy_instance invocation = gi.workflows.show_invocation(