Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions v03_pipeline/bin/pipeline_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
safe_post_to_slack_failure,
safe_post_to_slack_success,
)
from v03_pipeline.lib.paths import (
loading_pipeline_deadletter_queue_dir,
loading_pipeline_deadletter_queue_path,
)

logger = get_logger(__name__)

Expand Down Expand Up @@ -73,6 +77,9 @@ def process_queue(local_scheduler=False):
prr,
e,
)
os.makedirs(loading_pipeline_deadletter_queue_dir(), exist_ok=True)
with open(loading_pipeline_deadletter_queue_path(run_id), 'w') as f:
f.write(prr.model_dump_json())
finally:
if latest_queue_path is not None and os.path.exists(latest_queue_path):
os.remove(latest_queue_path)
Expand Down
12 changes: 11 additions & 1 deletion v03_pipeline/bin/pipeline_worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from v03_pipeline.bin.pipeline_worker import process_queue
from v03_pipeline.lib.core import DatasetType, ReferenceGenome, SampleType
from v03_pipeline.lib.paths import loading_pipeline_queue_dir
from v03_pipeline.lib.paths import (
loading_pipeline_deadletter_queue_dir,
loading_pipeline_queue_dir,
)
from v03_pipeline.lib.test.mock_complete_task import MockCompleteTask
from v03_pipeline.lib.test.mocked_dataroot_testcase import MockedDatarootTestCase

Expand Down Expand Up @@ -92,3 +95,10 @@ def test_process_failure(
mock_safe_post_to_slack.assert_called_once_with(
':failed: Pipeline Runner Request Failed :failed:\nRun ID: 20250918-200704-123456\n```{\n "callset_path": "v03_pipeline/var/test/callsets/1kg_30variants.vcf",\n "dataset_type": "SNV_INDEL",\n "project_guids": [\n "project_a"\n ],\n "reference_genome": "GRCh38",\n "request_type": "LoadingPipelineRequest",\n "sample_type": "WGS",\n "skip_check_sex_and_relatedness": false,\n "skip_expect_tdr_metrics": false,\n "skip_validation": false\n}```\nReason: there were failed tasks',
)
with open(
os.path.join(
loading_pipeline_deadletter_queue_dir(),
'request_20250918-200704-123456.json',
),
) as f:
self.assertEqual(json.load(f)['request_type'], 'LoadingPipelineRequest')
17 changes: 17 additions & 0 deletions v03_pipeline/lib/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ def loading_pipeline_queue_dir() -> str:
)


def loading_pipeline_deadletter_queue_dir() -> str:
return os.path.join(
Env.LOCAL_DISK_MOUNT_PATH,
'loading_pipeline_deadletter_queue',
)


def loading_pipeline_queue_path(run_id: str) -> str:
"""
Returns a new path for a loading pipeline queue request file.
Expand All @@ -421,6 +428,16 @@ def loading_pipeline_queue_path(run_id: str) -> str:
)


def loading_pipeline_deadletter_queue_path(run_id: str) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does deadletter mean? might be worth adding to the comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll add a comment. it is reasonably standard terminology: https://aws.amazon.com/what-is/dead-letter-queue/

"""
Returns a new path for a loading pipeline queue request file.
"""
return os.path.join(
loading_pipeline_deadletter_queue_dir(),
f'request_{run_id}.json',
)


def pipeline_run_success_file_path(
reference_genome: ReferenceGenome,
dataset_type: DatasetType,
Expand Down