Skip to content

Commit

Permalink
Transfer report to remote server | Refactor logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
glrs committed Nov 14, 2024
1 parent 8536a79 commit 3ef6f0d
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions lib/realms/smartseq3/ss3_sample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from lib.base.abstract_sample import AbstractSample
from lib.core_utils.logging_utils import custom_logger
from lib.module_utils.report_transfer import transfer_report
from lib.module_utils.sjob_manager import SlurmJobManager
from lib.module_utils.slurm_utils import generate_slurm_script
from lib.realms.smartseq3.report.report_generator import Smartseq3ReportGenerator
Expand Down Expand Up @@ -78,7 +79,8 @@ def status(self, value):

async def pre_process(self):
"""Pre-process the sample by collecting metadata and creating YAML files."""
logging.info(f"Pre-processing sample {self.id}")
logging.info("\n")
logging.info(f"[{self.id}] Pre-processing...")
yaml_metadata = self._collect_yaml_metadata()
if not yaml_metadata:
logging.warning(f"Metadata missing for sample {self.id}")
Expand Down Expand Up @@ -109,7 +111,9 @@ async def pre_process(self):

async def process(self):
"""Process the sample by submitting its job."""
logging.debug("Submitting job for sample {self.id}")
logging.info("\n")
logging.info(f"[{self.id}] Processing...")
logging.debug(f"[{self.id}] Submitting job...")
self.job_id = await self.sjob_manager.submit_job(
self.file_handler.slurm_script_path
)
Expand Down Expand Up @@ -317,7 +321,8 @@ def post_process(self):
"""
Post-process the sample after job completion.
"""
logging.info(f"Post-processing sample {self.id}...")
logging.info("\n")
logging.info(f"[{self.id}] Post-processing...")

# Check if sample output is valid
if not self.file_handler.is_output_valid():
Expand All @@ -331,9 +336,11 @@ def post_process(self):

# Create symlinks for the fastq files
if not self.file_handler.symlink_fastq_files():
logging.error("Failed to manage symlinks and auxiliary files.")
logging.error(f"[{self.id}] Failed to manage symlinks and auxiliary files.")
else:
logging.info("Successfully managed symlinks and auxiliary files.")
logging.info(
f"[{self.id}] Successfully managed symlinks and auxiliary files."
)

# Instantiate report generator
report_generator = Smartseq3ReportGenerator(self)
Expand All @@ -354,3 +361,19 @@ def post_process(self):

# Generate Report
report_generator.render(format="PDF")

# Transfer the Report
if not self.file_handler.report_fpath.exists():
logging.error(
f"[{self.id}] Report not found at {self.file_handler.report_fpath}"
)
return

if transfer_report(
report_path=self.file_handler.report_fpath,
project_id=self.file_handler.project_id,
sample_id=self.id,
):
logging.info(f"[{self.id}] Report transferred successfully.")
else:
logging.error(f"[{self.id}] Failed to transfer report.")

0 comments on commit 3ef6f0d

Please sign in to comment.