From 4ccb37b25c62500f18cfae2cb48ae79745b331bc Mon Sep 17 00:00:00 2001 From: Vincent Janvid Date: Mon, 7 Oct 2024 08:41:58 +0200 Subject: [PATCH 1/3] Reduce log-level for compress related commands --- cg/apps/crunchy/crunchy.py | 2 -- cg/apps/housekeeper/hk.py | 8 ++++++-- cg/cli/compress/fastq.py | 2 +- cg/cli/compress/helpers.py | 10 +++++----- cg/meta/compress/compress.py | 4 ++-- cg/meta/compress/files.py | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cg/apps/crunchy/crunchy.py b/cg/apps/crunchy/crunchy.py index d0c2c10e04..adb2db33ed 100644 --- a/cg/apps/crunchy/crunchy.py +++ b/cg/apps/crunchy/crunchy.py @@ -45,8 +45,6 @@ def __init__(self, config: dict): def set_dry_run(self, dry_run: bool) -> None: """Update dry run.""" - LOG.info("Updating compress api") - LOG.info(f"Set dry run to {dry_run}") self.dry_run = dry_run self.slurm_api.set_dry_run(dry_run=dry_run) diff --git a/cg/apps/housekeeper/hk.py b/cg/apps/housekeeper/hk.py index cb60e078ed..2a2dd179aa 100644 --- a/cg/apps/housekeeper/hk.py +++ b/cg/apps/housekeeper/hk.py @@ -7,7 +7,11 @@ from housekeeper.include import checksum as hk_checksum from housekeeper.include import include_version -from housekeeper.store.database import create_all_tables, drop_all_tables, initialize_database +from housekeeper.store.database import ( + create_all_tables, + drop_all_tables, + initialize_database, +) from housekeeper.store.models import Archive, Bundle, File, Tag, Version from housekeeper.store.store import Store from sqlalchemy.orm import Query @@ -273,7 +277,7 @@ def get_latest_bundle_version(self, bundle_name: str) -> Version | None: """Get the latest version of a Housekeeper bundle.""" last_version: Version = self.last_version(bundle_name) if not last_version: - LOG.warning(f"No bundle found for {bundle_name} in Housekeeper") + LOG.debug(f"No bundle found for {bundle_name} in Housekeeper") return None LOG.debug(f"Found Housekeeper version object for {bundle_name}: {repr(last_version)}") return last_version diff --git a/cg/cli/compress/fastq.py b/cg/cli/compress/fastq.py index 8c49e1c226..7ce779c8e8 100644 --- a/cg/cli/compress/fastq.py +++ b/cg/cli/compress/fastq.py @@ -97,7 +97,7 @@ def clean_fastq(context: CGConfig, case_id: str | None, days_back: int, dry_run: sample_id=sample_id, archive_location=archive_location ) if not was_cleaned: - LOG.info(f"Skipping individual {sample_id}") + LOG.debug(f"Skipping individual {sample_id}") continue cleaned_inds += 1 diff --git a/cg/cli/compress/helpers.py b/cg/cli/compress/helpers.py index 4ad1019591..91445e19bd 100644 --- a/cg/cli/compress/helpers.py +++ b/cg/cli/compress/helpers.py @@ -73,13 +73,13 @@ def update_compress_api( compress_api.set_dry_run(dry_run=dry_run) if mem: - LOG.info(f"Set Crunchy API SLURM mem to {mem}") + LOG.debug(f"Set Crunchy API SLURM mem to {mem}") compress_api.crunchy_api.slurm_memory = mem if hours: - LOG.info(f"Set Crunchy API SLURM hours to {hours}") + LOG.debug(f"Set Crunchy API SLURM hours to {hours}") compress_api.crunchy_api.slurm_hours = hours if ntasks: - LOG.info(f"Set Crunchy API SLURM number of tasks to {ntasks}") + LOG.debug(f"Set Crunchy API SLURM number of tasks to {ntasks}") compress_api.crunchy_api.slurm_number_tasks = ntasks @@ -139,7 +139,7 @@ def compress_sample_fastqs_in_cases( if case_conversion_count >= number_of_conversions: break - LOG.info(f"Searching for FASTQ files in case {case.internal_id}") + LOG.debug(f"Searching for FASTQ files in case {case.internal_id}") if not case.links: continue for case_link in case.links: @@ -159,7 +159,7 @@ def compress_sample_fastqs_in_cases( sample_id=case_link.sample.internal_id ) if not case_converted: - LOG.info(f"skipping individual {case_link.sample.internal_id}") + LOG.debug(f"skipping individual {case_link.sample.internal_id}") continue individuals_conversion_count += 1 if case_converted: diff --git a/cg/meta/compress/compress.py b/cg/meta/compress/compress.py index a948bf75f9..52ade61fcc 100644 --- a/cg/meta/compress/compress.py +++ b/cg/meta/compress/compress.py @@ -58,7 +58,7 @@ def get_flow_cell_id(self, fastq_path: Path) -> str: def compress_fastq(self, sample_id: str) -> bool: """Compress the FASTQ files for an individual.""" - LOG.info(f"Check if FASTQ compression is possible for {sample_id}") + LOG.debug(f"Check if FASTQ compression is possible for {sample_id}") version: Version = self.hk_api.get_latest_bundle_version(bundle_name=sample_id) if not version: return False @@ -152,7 +152,7 @@ def clean_fastq(self, sample_id: str, archive_location: str) -> bool: This means removing compressed FASTQ files and update housekeeper to point to the new SPRING file and its metadata file. """ - LOG.info(f"Clean FASTQ files for {sample_id}") + LOG.debug(f"Clean FASTQ files for {sample_id}") version: Version = self.hk_api.get_latest_bundle_version(bundle_name=sample_id) if not version: return False diff --git a/cg/meta/compress/files.py b/cg/meta/compress/files.py index 36bf67379b..7f45d7f6a2 100644 --- a/cg/meta/compress/files.py +++ b/cg/meta/compress/files.py @@ -27,7 +27,7 @@ def get_hk_files_dict(tags: list[str], version_obj: Version) -> dict[Path, File] file_tags: set[str] = {tag.name for tag in version_file.tags} if not file_tags.intersection(tags): continue - LOG.info(f"Found file {version_file.path}") + LOG.debug(f"Found file {version_file.path}") path_obj: Path = Path(version_file.full_path) hk_file[path_obj] = version_file return hk_file From 990a321cf55249481c548feb5941935150d881b0 Mon Sep 17 00:00:00 2001 From: Vincent Janvid Date: Mon, 7 Oct 2024 08:50:47 +0200 Subject: [PATCH 2/3] Remove log check --- tests/apps/hk/test_version.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/apps/hk/test_version.py b/tests/apps/hk/test_version.py index f9dc577a11..8b2e97bd40 100644 --- a/tests/apps/hk/test_version.py +++ b/tests/apps/hk/test_version.py @@ -117,9 +117,6 @@ def test_get_latest_bundle_version_no_housekeeper_bundle( # THEN assert that None was returned since there is no such case bundle in Housekeeper assert res is None - # THEN assert that no bundle is found - assert f"No bundle found for {case_id} in Housekeeper" in caplog.text - def test_get_create_version( another_case_id: str, From bbe4c220349dabe495bb9634aa3cadf2d2adf187 Mon Sep 17 00:00:00 2001 From: Vincent Janvid Date: Mon, 7 Oct 2024 10:43:28 +0200 Subject: [PATCH 3/3] Missed one --- cg/meta/compress/files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cg/meta/compress/files.py b/cg/meta/compress/files.py index 7f45d7f6a2..57c38120c5 100644 --- a/cg/meta/compress/files.py +++ b/cg/meta/compress/files.py @@ -99,7 +99,7 @@ def get_fastq_files(sample_id: str, version_obj: Version) -> dict[str, dict]: fastq_dict = {} compression_objects: list[CompressionData] = get_compression_data(list(hk_files_dict.keys())) if not compression_objects: - LOG.info(f"Could not find FASTQ files for {sample_id}") + LOG.debug(f"Could not find FASTQ files for {sample_id}") return None for compression_obj in compression_objects: