-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add execution order controls #424
base: develop
Are you sure you want to change the base?
Changes from all commits
4b0e301
e8be21f
1513ef1
11e09dc
4a6e500
b8dd9a7
80d0ac5
3c80dd1
96774ba
5620133
bf010f8
517e5d7
a73c345
525d5bb
ea59e5d
79c92a3
2b14dae
20aa543
e07618e
a703008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ components: | |
[`description`](#description) | Yes | General information about a study and its high-level purpose | | ||
[`batch`](#batch) | No | Settings for submission to batch systems | | ||
[`env`](#environment) | No | Fixed constants and other values that are globally set and referenced | | ||
[`execution`](#execution) | No | Controls for step execution order | | ||
[`study`](#workflow) | Yes | Tasks that the study is composed of and are executed in a defined order | | ||
[`global.parameters`](#parameters)| No | Parameters that are user varied and applied to the workflow | | ||
|
||
|
@@ -363,6 +364,272 @@ The `batch` block is an optional block that enables specification of HPC schedul | |
|
||
<br/> | ||
|
||
## Execution: `execution` | ||
---- | ||
|
||
The `execution` block is an optional block that enables control of the study execution. The current version allows selection between depth first and breadth first order of execution of the study steps. Breadth first order is the default mode. | ||
|
||
| **Key** | **Required** | **Type** | **Description** | | ||
| :- | :-: | :-: | :- | | ||
| `step_order` | No | str | Type of scheduler managing execution. One of: {`depth-first`, `breadth-first`}. Default: `breadth-first`. | | ||
|
||
``` yaml | ||
execution: | ||
step_order: depth-first | ||
``` | ||
|
||
!!! warning | ||
|
||
For [throttle](cli.md#run) > 1 the ``depth-first`` option will not behave as a pure | ||
depth-first traversal, but rather a mix of breadth/depth-first ordering. The step | ||
dependencies limit what can be put into the queue: ``say-bye`` steps | ||
cannot enter the queue until their dependencies are met, e.g. the | ||
corresponding ``say-hello`` steps. Thus for throttle settings > 1, you may | ||
have multiple ``say-hello`` steps run before any ``say-bye`` steps. The | ||
two modes diagrammed below assume throttle = 1 to make things more | ||
clear. | ||
|
||
|
||
These execution orders can be shown with the sample hello-bye world specification as shown in the tutorials: | ||
|
||
=== "Example specification" | ||
|
||
``` yaml | ||
description: | ||
name: hello_bye_parameterized_funnel | ||
description: A study that says hello and bye to multiple people, and a final good bye to all. | ||
|
||
execution: | ||
step_order: depth-first | ||
|
||
env: | ||
variables: | ||
OUTPUT_PATH: ./samples/hello_bye_parameterized_funnel | ||
labels: | ||
HELLO_FORMAT: $(GREETING)_$(NAME).txt | ||
BYE_FORMAT: $(FAREWELL)_$(NAME).txt | ||
|
||
study: | ||
- name: say-hello | ||
description: Say hello to someone! | ||
run: | ||
cmd: | | ||
echo "$(GREETING), $(NAME)!" > $(HELLO_FORMAT) | ||
|
||
- name: say-bye | ||
description: Say bye to someone! | ||
run: | ||
cmd: | | ||
echo "$(FAREWELL), $(NAME)!" > $(BYE_FORMAT) | ||
depends: [say-hello] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this depends statement is changed to |
||
|
||
- name: bye-all | ||
description: Say bye to everyone! | ||
run: | ||
cmd: | | ||
echo "Good-bye, World!" > good_bye_all.txt | ||
depends: [say-bye_*] | ||
|
||
global.parameters: | ||
NAME: | ||
values: [Pam, Jim, Michael, Dwight] | ||
label: NAME.%% | ||
GREETING: | ||
values: [Hello, Ciao, Hey, Hi] | ||
label: GREETING.%% | ||
FAREWELL: | ||
values: [Goodbye, Farewell, So long, See you later] | ||
label: FAREWELL.%% | ||
``` | ||
|
||
=== "Breadth-first order, throttle=1" | ||
|
||
Breadth first, order of excution marked by colors with lighter colors executing first: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo here, should be: "order of execution". This same typo is in the DFO tab below as well |
||
|
||
``` mermaid | ||
flowchart TD; | ||
A(study root) --> COMBO1; | ||
subgraph COMBO1 [Combo #1] | ||
subgraph say_hello1 [say-hello] | ||
B(Hello, Pam) | ||
|
||
end | ||
subgraph say_bye1 [say-bye] | ||
C(Goodbye, Pam) | ||
|
||
end | ||
say_hello1 --> say_bye1 | ||
end | ||
A --> COMBO2 | ||
subgraph COMBO2 [Combo #2] | ||
direction TB | ||
subgraph say_hello2 [say-hello] | ||
D(Ciao, Jim) | ||
|
||
end | ||
subgraph say_bye2 [say-bye] | ||
E(Farewell, Jim) | ||
|
||
end | ||
say_hello2 --> say_bye2 | ||
end | ||
A --> COMBO3 | ||
subgraph COMBO3 [Combo #3] | ||
subgraph say_hello3 [say-hello] | ||
F(Hey, Michael) | ||
|
||
end | ||
subgraph say_bye3 [say-bye] | ||
G(So long, Michael) | ||
|
||
end | ||
say_hello3 --> say_bye3 | ||
end | ||
A --> COMBO4 | ||
subgraph COMBO4 [Combo #4] | ||
subgraph say_hello4 [say-hello] | ||
H(Hi, Dwight) | ||
|
||
end | ||
subgraph say_bye4 [say-bye] | ||
I(See you later, Dwight) | ||
|
||
end | ||
say_hello4 --> say_bye4; | ||
end | ||
|
||
COMBO1 --> J{{bye-all}} | ||
COMBO2 --> J{{bye-all}} | ||
COMBO3 --> J{{bye-all}} | ||
COMBO4 --> J{{bye-all}} | ||
|
||
|
||
style B fill:#f7fbff,color:#000000; | ||
style C fill:#6baed6,color:#000000; | ||
style D fill:#deebf7,color:#000000; | ||
style E fill:#4292c6,color:#FFFFFF; | ||
style F fill:#c6dbef,color:#000000; | ||
style G fill:#2171b5,color:#FFFFFF; | ||
style H fill:#9ecae1,color:#000000; | ||
style I fill:#08519c,color:#FFFFFF; | ||
style J fill:#08306b,color:#FFFFFF; | ||
|
||
subgraph LEGEND [Legend: Execution order] | ||
direction LR | ||
BL[1]---> DL[2] | ||
DL ---> FL[3] | ||
FL ---> HL[4] | ||
HL ---> CL[5] | ||
CL ---> EL[6] | ||
EL ---> GL[7] | ||
GL ---> IL[8] | ||
IL ---> JL[9] | ||
style BL fill:#f7fbff,color:#000000; | ||
style CL fill:#6baed6,color:#000000; | ||
style DL fill:#deebf7,color:#000000; | ||
style EL fill:#4292c6,color:#FFFFFF; | ||
style FL fill:#c6dbef,color:#000000; | ||
style GL fill:#2171b5,color:#FFFFFF; | ||
style HL fill:#9ecae1,color:#000000; | ||
style IL fill:#08519c,color:#FFFFFF; | ||
style JL fill:#08306b,color:#FFFFFF; | ||
end | ||
|
||
J --- LEGEND | ||
linkStyle 20 stroke-width:0px; | ||
``` | ||
|
||
=== "Depth-first order, throttle=1" | ||
|
||
Depth-first, order of excution marked by colors with lighter colors executing first: | ||
|
||
|
||
``` mermaid | ||
flowchart TD; | ||
A(study root) --> COMBO1; | ||
subgraph COMBO1 [Combo #1] | ||
subgraph say_hello1 [say-hello] | ||
B(Hello, Pam) | ||
end | ||
subgraph say_bye1 [say-bye] | ||
C(Goodbye, Pam) | ||
end | ||
say_hello1 --> say_bye1 | ||
end | ||
A --> COMBO2 | ||
subgraph COMBO2 [Combo #2] | ||
direction TB | ||
subgraph say_hello2 [say-hello] | ||
D(Ciao, Jim) | ||
end | ||
subgraph say_bye2 [say-bye] | ||
E(Farewell, Jim) | ||
end | ||
say_hello2 --> say_bye2 | ||
end | ||
A --> COMBO3 | ||
subgraph COMBO3 [Combo #3] | ||
subgraph say_hello3 [say-hello] | ||
F(Hey, Michael) | ||
end | ||
subgraph say_bye3 [say-bye] | ||
G(So long, Michael) | ||
end | ||
say_hello3 --> say_bye3 | ||
end | ||
A --> COMBO4 | ||
subgraph COMBO4 [Combo #4] | ||
subgraph say_hello4 [say-hello] | ||
H(Hi, Dwight) | ||
end | ||
subgraph say_bye4 [say-bye] | ||
I(See you later, Dwight) | ||
end | ||
say_hello4 --> say_bye4; | ||
end | ||
|
||
COMBO1 --> J{{bye-all}} | ||
COMBO2 --> J{{bye-all}} | ||
COMBO3 --> J{{bye-all}} | ||
COMBO4 --> J{{bye-all}} | ||
|
||
style B fill:#f7fbff,color:#000000; | ||
style C fill:#deebf7,color:#000000; | ||
style D fill:#c6dbef,color:#000000; | ||
style E fill:#9ecae1,color:#000000; | ||
style F fill:#6baed6,color:#000000; | ||
style G fill:#4292c6,color:#FFFFFF; | ||
style H fill:#2171b5,color:#FFFFFF; | ||
style I fill:#08519c,color:#FFFFFF; | ||
style J fill:#08306b,color:#FFFFFF; | ||
subgraph LEGEND [Legend: Execution order] | ||
direction LR | ||
BL[1]---> CL[2] | ||
CL ---> DL[3] | ||
DL ---> EL[4] | ||
EL ---> FL[5] | ||
FL ---> GL[6] | ||
GL ---> HL[7] | ||
HL ---> IL[8] | ||
IL ---> JL[9] | ||
style BL fill:#f7fbff,color:#000000; | ||
style CL fill:#deebf7,color:#000000; | ||
style DL fill:#c6dbef,color:#000000; | ||
style EL fill:#9ecae1,color:#000000; | ||
style FL fill:#6baed6,color:#000000; | ||
style GL fill:#4292c6,color:#FFFFFF; | ||
style HL fill:#2171b5,color:#FFFFFF; | ||
style IL fill:#08519c,color:#FFFFFF; | ||
style JL fill:#08306b,color:#FFFFFF; | ||
|
||
end | ||
J --- LEGEND | ||
linkStyle 20 stroke-width:0px; | ||
``` | ||
|
||
See the [batch processing](how_to_guides/parameter_batches.md#inline-data-management-option) for another example of where you might want to use these options. | ||
|
||
|
||
## Study: `study` | ||
---- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
if sys.version_info < (3, 8): | ||
from typing_extensions import Protocol | ||
else: | ||
from typing import Protocol | ||
|
||
# TODO: fix circular imports so we can use type hint | ||
# from maestrowf.datastructures.core.study import StudyStep | ||
|
||
|
||
class PriorityExpr(Protocol): | ||
""" | ||
Defines api for Priority Expressions for study steps. | ||
""" | ||
def __call__(self, study_step): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For now the type hint could be |
||
""" | ||
Compute priority for a study step | ||
|
||
:param study_step: StudyStep instance to compute priority for | ||
:returns: any type implementing __lt__ and __eq__. Must be consistent | ||
type for all parameterized instances of this step | ||
""" | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to Tutorials page here would be helpful