Skip to content
Snippets Groups Projects
Commit 1d64718b authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

dump metadata in a celery task, backend serve the content of the metadata file

parent cb1e05e5
No related branches found
No related tags found
1 merge request!71dump metadata in a celery task, backend serve the content of the metadata file
......@@ -598,7 +598,7 @@ methods:{
this.sharedUrl = "http://"+window.location.host + "/projects/" + this.project.id;
console.log(this.project.id);
this.status=result.status;
if(result.status.worktable ==="READY" && ! this.isready){
if(result.status.metadata ==="READY" && ! this.isready){
await this.$axios.$get('/projects/'+this.project.id+"/gencov").then((async function (result2) {
this.gencov = result2;
......
......@@ -218,6 +218,12 @@ class Project(BaseModel, abc.ABC):
def get_project_summary_statistics(self):
return get_worktable_summary(self.get_worktable_path())
def get_metadata_file_path(self):
"""
Get the path of the metadata json file
"""
return os.path.join(self.get_folder_path(), "metadata.json")
def get_project_nsnps(self):
return get_inittable_meta(self.get_worktable_path())
......@@ -270,6 +276,11 @@ class Project(BaseModel, abc.ABC):
if filename.endswith(".png"):
os.remove(os.path.join(self.get_folder_path(), filename))
have_removed_file = True
try:
os.remove(self.get_metadata_file_path())
have_removed_file = True
except FileNotFoundError:
pass
return have_removed_file
@call_with_tb('global_manhattan')
......@@ -296,6 +307,12 @@ class Project(BaseModel, abc.ABC):
def create_csv_file(self):
return create_genome_full_csv(self.get_worktable_path(), self.get_csv_path())
@call_with_tb('metadata')
def create_project_metadata_file(self):
with open(self.get_metadata_file_path(), 'w') as f:
f.write(json.dumps(self.get_project_nsnps()))
print("------ metadata -----")
class GlobalProject(Project):
@call_with_tb('worktable')
......
......@@ -106,7 +106,7 @@ def project_gencov_view(project_id: str):
@app.get("/api/projects/{project_id}/metadata")
def project_metadata(project_id: str):
return load_project(project_id=project_id).get_project_nsnps()
return FileResponse(load_project(project_id=project_id).get_metadata_file_path())
@app.get("/api/projects/{project_id}/globalmanhattan")
......
......@@ -79,6 +79,12 @@ def create_project_csv_file(project_id):
return project.create_csv_file()
@celery.task
def create_project_metadata_file(project_id):
project = GlobalProject.load(project_id)
return project.create_project_metadata_file()
@celery.task
def dummy_task():
print("This task to nothing, but help the chain to have a valid status")
......@@ -124,6 +130,9 @@ def run_project_analysis_if_needed(project):
if project.get_csv_path() and not os.path.exists(project.get_csv_path()):
post_worktable_tasks.append(create_project_csv_file.si(project.id))
if project.get_metadata_file_path() and not os.path.exists(project.get_metadata_file_path()):
post_worktable_tasks.append(create_project_metadata_file.si(project.id))
if len(tasks) + len(post_worktable_tasks) == 0:
return
main_wf = chain(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment