Skip to content

Commit

Permalink
Fix missing microsalt jobs (#2813)(patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard authored Jan 9, 2024
1 parent 8322d2e commit 2b87168
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
16 changes: 8 additions & 8 deletions cg/meta/workflow/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def get_case_config_path(self, case_id) -> Path:
"""Path to case config file"""
raise NotImplementedError

def get_trailblazer_config_path(self, case_id: str) -> Path:
"""Path to Trailblazer job id file"""
def get_job_ids_path(self, case_id: str) -> Path:
"""Path to file containing slurm/tower job ids for the case."""
raise NotImplementedError

def get_sample_name_from_lims_id(self, lims_id: str) -> str:
Expand Down Expand Up @@ -206,17 +206,17 @@ def get_analysis_finish_path(self, case_id: str) -> Path:
raise NotImplementedError

def add_pending_trailblazer_analysis(self, case_id: str) -> None:
self.check_analysis_ongoing(case_id=case_id)
self.trailblazer_api.mark_analyses_deleted(case_id=case_id)
self.check_analysis_ongoing(case_id)
self.trailblazer_api.mark_analyses_deleted(case_id)
self.trailblazer_api.add_pending_analysis(
case_id=case_id,
email=environ_email(),
analysis_type=self.get_application_type(
self.status_db.get_case_by_internal_id(internal_id=case_id).links[0].sample
self.status_db.get_case_by_internal_id(case_id).links[0].sample
),
out_dir=self.get_trailblazer_config_path(case_id=case_id).parent.as_posix(),
config_path=self.get_trailblazer_config_path(case_id=case_id).as_posix(),
slurm_quality_of_service=self.get_slurm_qos_for_case(case_id=case_id),
out_dir=self.get_job_ids_path(case_id).parent.as_posix(),
config_path=self.get_job_ids_path(case_id).as_posix(),
slurm_quality_of_service=self.get_slurm_qos_for_case(case_id),
data_analysis=str(self.pipeline),
ticket=self.status_db.get_latest_ticket_from_case(case_id),
workflow_manager=self.get_workflow_manager(),
Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/balsamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_case_config_path(self, case_id: str) -> Path:
"""
return Path(self.root_dir, case_id, case_id + ".json")

def get_trailblazer_config_path(self, case_id: str) -> Path:
def get_job_ids_path(self, case_id: str) -> Path:
return Path(self.root_dir, case_id, "analysis", "slurm_jobids.yaml")

def get_bundle_deliverables_type(self, case_id: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/fluffy.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_deliverables_file_path(self, case_id: str) -> Path:
"""
return Path(self.get_output_path(case_id), "deliverables.yaml")

def get_trailblazer_config_path(self, case_id: str) -> Path:
def get_job_ids_path(self, case_id: str) -> Path:
"""
Location in working directory where SLURM job id file is to be stored.
This file contains SLURM ID of jobs associated with current analysis ,
Expand Down
32 changes: 18 additions & 14 deletions cg/meta/workflow/microsalt/microsalt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import glob
import logging
import os
import re
Expand Down Expand Up @@ -88,14 +87,19 @@ def get_case_fastq_path(self, case_id: str) -> Path:
def get_config_path(self, filename: str) -> Path:
return Path(self.queries_path, filename).with_suffix(".json")

def get_trailblazer_config_path(self, case_id: str) -> Path:
"""Get trailblazer config path."""
case_obj: Case = self.status_db.get_case_by_internal_id(internal_id=case_id)
sample_obj: Sample = case_obj.links[0].sample
project_id: str = self.get_project(sample_obj.internal_id)
return Path(
self.root_dir, "results", "reports", "trailblazer", f"{project_id}_slurm_ids.yaml"
)
def get_job_ids_path(self, case_id: str) -> Path:
case_path: Path = self.get_case_path(case_id)
job_ids_file_name: str = self.get_job_ids_file_name(case_id)
return Path(case_path, job_ids_file_name)

def get_job_ids_file_name(self, case_id: str) -> str:
project_id: str = self.get_lims_project_id(case_id)
return f"{project_id}_slurm_ids.yaml"

def get_lims_project_id(self, case_id: str):
case: Case = self.status_db.get_case_by_internal_id(case_id)
sample: Sample = case.links[0].sample
return self.get_project(sample.internal_id)

def get_deliverables_file_path(self, case_id: str) -> Path:
"""Returns a path where the microSALT deliverables file for the order_id should be
Expand Down Expand Up @@ -221,7 +225,7 @@ def get_case_id_from_ticket(self, unique_id: str) -> tuple[str, None]:
Since sample_id is not specified, nothing is returned as sample_id"""
case: Case = self.status_db.get_case_by_name(name=unique_id)
if not case:
LOG.error("No case found for ticket number: %s", unique_id)
LOG.error(f"No case found for ticket number: {unique_id}")
raise click.Abort
case_id = case.internal_id
return case_id, None
Expand All @@ -230,19 +234,19 @@ def get_case_id_from_sample(self, unique_id: str) -> tuple[str, str]:
"""If sample is specified, finds the corresponding case_id to which this sample belongs.
The case_id is to be used for identifying the appropriate path to link fastq files and store the analysis output
"""
sample: Sample = self.status_db.get_sample_by_internal_id(internal_id=unique_id)
sample: Sample = self.status_db.get_sample_by_internal_id(unique_id)
if not sample:
LOG.error("No sample found with id: %s", unique_id)
LOG.error(f"No sample found with id: {unique_id}")
raise click.Abort
case_id = sample.links[0].case.internal_id
sample_id = sample.internal_id
return case_id, sample_id

def get_case_id_from_case(self, unique_id: str) -> tuple[str, None]:
"""If case_id is specified, validates the presence of case_id in database and returns it"""
case_obj: Case = self.status_db.get_case_by_internal_id(internal_id=unique_id)
case_obj: Case = self.status_db.get_case_by_internal_id(unique_id)
if not case_obj:
LOG.error("No case found with the id: %s", unique_id)
LOG.error(f"No case found with the id: {unique_id}")
raise click.Abort
case_id = case_obj.internal_id
return case_id, None
Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/mip.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def run_analysis(self, case_id: str, command_args: dict, dry_run: bool) -> None:
def get_case_path(self, case_id: str) -> Path:
return Path(self.root, case_id)

def get_trailblazer_config_path(self, case_id: str) -> Path:
def get_job_ids_path(self, case_id: str) -> Path:
return Path(self.get_case_path(case_id=case_id), "analysis", "slurm_job_ids.yaml")

def config_sample(self, link_obj: CaseSample, panel_bed: str) -> dict:
Expand Down
2 changes: 1 addition & 1 deletion cg/meta/workflow/mutant.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_case_output_path(self, case_id: str) -> Path:
def get_case_fastq_dir(self, case_id: str) -> Path:
return Path(self.get_case_path(case_id=case_id), "fastq")

def get_trailblazer_config_path(self, case_id: str) -> Path:
def get_job_ids_path(self, case_id: str) -> Path:
return Path(self.get_case_output_path(case_id=case_id), "trailblazer_config.yaml")

def _is_nanopore(self, application: Application) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions cg/meta/workflow/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_nextflow_config_path(nextflow_config: str | None = None) -> Path | None:
if nextflow_config:
return Path(nextflow_config).absolute()

def get_trailblazer_config_path(self, case_id: str) -> Path:
def get_job_ids_path(self, case_id: str) -> Path:
"""Return the path to a Trailblazer config file containing Tower IDs."""
return Path(self.root_dir, case_id, "tower_ids").with_suffix(FileExtensions.YAML)

Expand Down Expand Up @@ -197,7 +197,7 @@ def write_deliverables_file(

def write_trailblazer_config(self, case_id: str, tower_id: str) -> None:
"""Write Tower IDs to a file used as the Trailblazer config."""
config_path: Path = self.get_trailblazer_config_path(case_id=case_id)
config_path: Path = self.get_job_ids_path(case_id=case_id)
LOG.info(f"Writing Tower ID to {config_path.as_posix()}")
WriteFile.write_file_from_content(
content={case_id: [tower_id]},
Expand Down Expand Up @@ -246,7 +246,7 @@ def _run_analysis_with_tower(
if command_args.resume:
from_tower_id: int = command_args.id or NfTowerHandler.get_last_tower_id(
case_id=case_id,
trailblazer_config=self.get_trailblazer_config_path(case_id=case_id),
trailblazer_config=self.get_job_ids_path(case_id=case_id),
)
LOG.info(f"Pipeline will be resumed from run with Tower id: {from_tower_id}.")
parameters: list[str] = NfTowerHandler.get_tower_relaunch_parameters(
Expand Down

0 comments on commit 2b87168

Please sign in to comment.