Workflow class¶
Provides a Workflow
class and a @stage
decorator that allow to define workflows
in a declarative fashion.
A Stage
object is responsible for creating Hail Batch jobs and declaring outputs
(files or metamist analysis objects) that are expected to be produced. Each stage
acts on a Target
, which can be of the following:
* SequencingGroup - an individual Sequencing Group (e.g. the CRAM of a single sample)
* Dataset - a stratification of SGs in this analysis by Metamist Project (e.g. all SGs in acute-care)
* Cohort - a stratification of SGs in this analysis by Metamist CustomCohort
* MultiCohort - a union of all SGs in this analysis by Metamist CustomCohort
A Workflow
object plugs stages together by resolving dependencies between different levels accordingly. Stages are
defined in this package, and chained into Workflows by their inter-Stages dependencies. Workflow names are defined in
main.py, which provides a way to choose a workflow using a CLI argument.
cpg_flow.workflow.get_workflow
¶
get_workflow()
Source code in src/cpg_flow/workflow.py
149 150 151 152 153 154 |
|
cpg_flow.workflow.run_workflow
¶
run_workflow(name, stages=None, wait=False, dry_run=False)
Source code in src/cpg_flow/workflow.py
157 158 159 160 161 162 163 164 165 166 167 168 |
|
cpg_flow.workflow.Workflow
¶
Workflow(name, stages=None, dry_run=None)
Encapsulates a Hail Batch object, stages, and a cohort of datasets of sequencing groups. Responsible for orchestrating stages.
Source code in src/cpg_flow/workflow.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
show_workflow
instance-attribute
¶
show_workflow = config_retrieve(
["workflow", "show_workflow"], False
)
access_level
instance-attribute
¶
access_level = config_retrieve(
["workflow", "access_level"], "test"
)
run_timestamp
instance-attribute
¶
run_timestamp = config_retrieve(
["workflow", "run_timestamp"], timestamp()
)
cohort_prefix
¶
cohort_prefix(cohort, category=None)
Takes a cohort and category as an argument, calls through to the Workflow cohort_prefix method Result in the form PROJECT_BUCKET / WORKFLOW_NAME / COHORT_ID e.g. "gs://cpg-project-main/seqr_loader/COH123", or "gs://cpg-project-main-analysis/seqr_loader/COH123"
PARAMETER | DESCRIPTION |
---|---|
cohort
|
we pull the analysis dataset and id from this Cohort
TYPE:
|
category
|
sub-bucket for this project
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Path
|
Path |
Source code in src/cpg_flow/workflow.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
run
¶
run(stages=None, wait=False)
Resolve stages, add and submit Hail Batch jobs.
When run_all_implicit_stages
is set, all required stages that were not defined
explicitly would still be executed.
Source code in src/cpg_flow/workflow.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
set_stages
¶
set_stages(requested_stages)
Iterate over stages and call their queue_for_cohort(cohort) methods; through that, creates all Hail Batch jobs through Stage.queue_jobs().
Source code in src/cpg_flow/workflow.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
|
cpg_flow.workflow.Action
¶
Bases: Enum
Indicates what a stage should do with a specific target.
cpg_flow.workflow.skip
¶
skip(_fun=None, *, reason=None, assume_outputs_exist=False)
Decorator on top of @stage
that sets the self.skipped
field to True.
By default, expected outputs of a skipped stage will be checked,
unless assume_outputs_exist
is True.
@skip @stage class MyStage1(SequencingGroupStage): ...
@skip @stage(assume_outputs_exist=True) class MyStage2(SequencingGroupStage): ...
Source code in src/cpg_flow/workflow.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
cpg_flow.workflow.path_walk
¶
path_walk(expected, collected=None)
recursive walk of expected_out if the object is iterable, walk it this gets around the issue with nested lists and dicts mainly around the use of Array outputs from Cromwell
PARAMETER | DESCRIPTION |
---|---|
expected
|
any type of object containing Paths
TYPE:
|
collected
|
all collected paths so far
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
set[Path]
|
a set of all collected Path nodes |
Examples:
path_walk({'a': {'b': {'c': Path('d')}}}) {Path('d')} path_walk({'a': {'b': {'c': [Path('d'), Path('e')]}}}) {Path('d'), Path('e')} path_walk({'a': Path('b'),'c': {'d': 'e'}, {'f': Path('g')}})
Source code in src/cpg_flow/workflow.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|