Skip to content

Commit

Permalink
Prevent Overwriting of Existing Sample Sheets (#4012) (patch)
Browse files Browse the repository at this point in the history
## Description

### Fixed

- Added a `samefile` check to ensure the sample sheet from Housekeeper is not copied if it already matches the existing sample sheet in the sequencing run directory.
  • Loading branch information
ahdamin authored Dec 11, 2024
1 parent 74905d5 commit f0d62a0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cg/apps/demultiplex/sample_sheet/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from cg.apps.demultiplex.sample_sheet.sample_sheet_creator import SampleSheetCreator
from cg.apps.demultiplex.sample_sheet.sample_sheet_validator import SampleSheetValidator
from cg.apps.demultiplex.sample_sheet.utils import (
delete_sample_sheet_from_housekeeper,
add_and_include_sample_sheet_path_to_housekeeper,
delete_sample_sheet_from_housekeeper,
)
from cg.apps.housekeeper.hk import HousekeeperAPI
from cg.apps.lims import LimsAPI
Expand Down Expand Up @@ -160,6 +160,20 @@ def _use_sample_sheet_from_housekeeper(
"would have copied it to sequencing run directory"
)
return

try:
if sample_sheet_path.samefile(run_directory_data.sample_sheet_path):
LOG.info(
"Sample sheet from Housekeeper is the same as the sequencing directory sample sheet"
)
return
except FileNotFoundError:
LOG.info(
f"Sample sheet or target path does not exist. "
f"Housekeeper sample sheet path: {sample_sheet_path}, "
f"Target sample sheet path: {run_directory_data.sample_sheet_path}"
)

LOG.info("Sample sheet from Housekeeper is valid. Copying it to sequencing run directory")
link_or_overwrite_file(src=sample_sheet_path, dst=run_directory_data.sample_sheet_path)

Expand Down

0 comments on commit f0d62a0

Please sign in to comment.