From 22a2e99608a27c1c5d4c974e0662e517e1bd520d Mon Sep 17 00:00:00 2001 From: Bryan Brancotte <bryan.brancotte@pasteur.fr> Date: Mon, 30 Oct 2023 17:42:41 +0100 Subject: [PATCH] transmit initTable name when creating project --- client/pages/phenotypes.vue | 7 ++++++- jass/models/phenotype.py | 2 +- jass/server.py | 2 +- jass/tasks.py | 12 ++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/client/pages/phenotypes.vue b/client/pages/phenotypes.vue index c64e3c4d..16f0475c 100644 --- a/client/pages/phenotypes.vue +++ b/client/pages/phenotypes.vue @@ -87,7 +87,12 @@ export default { }, runAnalysis(){ const { selectedRows, $axios } = this; - const phenotypeIds = {phenotypeID: selectedRows.map(function(phenotype){return phenotype.id})}; + const phenotypeIds = { + phenotypeID: selectedRows.map(function(phenotype){return phenotype.id}), + initTableName: "initTable.hdf5" + // phenotypeID: ["z_MAGIC_FAST-GLUCOSE", "z_MAGIC_FAST-INSULIN"], + // initTableName: "initTableTest.hdf5" + }; console.log("REQUEST POST") console.log(phenotypeIds) diff --git a/jass/models/phenotype.py b/jass/models/phenotype.py index c99b7d4b..5abe2ec6 100644 --- a/jass/models/phenotype.py +++ b/jass/models/phenotype.py @@ -85,5 +85,5 @@ class ProjectNameModel(BaseModel): raise ValueError(f"Prohibited char, only \"{_initTableNamePattern.pattern}\" allowed.") return value -class PhenotypeIdList(BaseModel): +class PhenotypeIdList(ProjectNameModel, BaseModel): phenotypeID: List[str] = [] diff --git a/jass/server.py b/jass/server.py index da2feb99..9314435d 100644 --- a/jass/server.py +++ b/jass/server.py @@ -70,7 +70,7 @@ def inittable_meta(): def project_create(phenotype_id_list: PhenotypeIdList): return create_project( phenotype_id_list.phenotypeID, - get_available_phenotypes(os.path.join(config["DATA_DIR"], "initTable.hdf5")), + init_table_name=phenotype_id_list.initTableName, ) diff --git a/jass/tasks.py b/jass/tasks.py index 25c96082..82e9b9d9 100644 --- a/jass/tasks.py +++ b/jass/tasks.py @@ -10,7 +10,7 @@ from flask import Flask import jass.models.project from jass.models.project import GlobalProject, Project, ensure_space_in_project_dir -from jass.models.phenotype import Phenotype +from jass.models.phenotype import Phenotype, get_available_phenotypes from jass.config import config @@ -155,22 +155,22 @@ def run_project_analysis_if_needed(project): def create_project( phenotype_ids: List[str], - available_phenotypes: List[Phenotype], chromosome: str = None, start: str = None, end: str = None, + init_table_name: str = None, ): - - available_phenotype_ids = [phenotype.id for phenotype in available_phenotypes] + init_table_path = os.path.join(config["DATA_DIR"], init_table_name) + available_phenotypes=get_available_phenotypes(init_table_path) unavailable_requested_ids = set(phenotype_ids).difference( - set(available_phenotype_ids) + set(phenotype.id for phenotype in available_phenotypes) ) if len(unavailable_requested_ids) > 0: raise HTTPException(status_code=404, detail=f"Phenotype IDs not found: {','.join(unavailable_requested_ids)}") phenotypes = [ phenotype for phenotype in available_phenotypes if phenotype.id in phenotype_ids ] - project = GlobalProject(phenotypes=phenotypes) + project = GlobalProject(phenotypes=phenotypes, init_table_path=init_table_path) project.create(fail_if_exists=False) ensure_space_in_project_dir(except_project_id=project.id) -- GitLab