-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add edge-merge-mode property in node
- Loading branch information
Showing
12 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
- step: | ||
name: step1 | ||
command: echo "i will buzz" | ||
image: alpine/alpine | ||
inputs: | ||
- name: dataset | ||
default: /step1 | ||
|
||
- pipeline: | ||
name: check-edge-merge-mode | ||
nodes: | ||
- name: node-with-default-edge-merge | ||
type: execution | ||
step: step1 | ||
- name: node-with-edge-merge-replace | ||
type: execution | ||
step: step1 | ||
edge-merge-mode: replace | ||
- name: node-with-edge-merge-append | ||
type: execution | ||
step: step1 | ||
edge-merge-mode: append | ||
|
||
edges: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- step: | ||
name: buzz | ||
command: echo "i will buzz" | ||
image: alpine/alpine | ||
inputs: | ||
- name: dataset | ||
default: /data | ||
|
||
- pipeline: | ||
name: bad-pp | ||
nodes: | ||
- name: bad-pn | ||
type: execution | ||
step: buzz | ||
edge-merge-mode: boo-boo | ||
edges: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from valohai_yaml.objs.pipelines.edge_merge_mode import EdgeMergeMode | ||
from valohai_yaml.pipelines.conversion import PipelineConverter | ||
|
||
|
||
def test_edge_override_mode(edge_merge_mode_config): | ||
config = edge_merge_mode_config | ||
pipeline = config.pipelines["check-edge-merge-mode"] | ||
assert len(pipeline.nodes) == 3 | ||
converted_pipeline = PipelineConverter(config=config, commit_identifier="latest").convert_pipeline(pipeline) | ||
node0 = converted_pipeline["nodes"][0] | ||
node1 = converted_pipeline["nodes"][1] | ||
node2 = converted_pipeline["nodes"][2] | ||
|
||
# override-mode not defined | ||
assert node0["edge-merge-mode"] == EdgeMergeMode.REPLACE.value | ||
|
||
# override-mode = replace | ||
assert node1["edge-merge-mode"] == EdgeMergeMode.REPLACE.value | ||
|
||
# override-mode = append | ||
assert node2["edge-merge-mode"] == EdgeMergeMode.APPEND.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
- step: | ||
name: buzz | ||
command: echo "i will buzz" | ||
image: alpine/alpine | ||
inputs: | ||
- name: dataset | ||
default: /data | ||
|
||
- pipeline: | ||
name: good | ||
nodes: | ||
- name: good_node | ||
step: buzz | ||
type: execution | ||
edge-merge-mode: replace | ||
edges: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from enum import Enum | ||
from typing import Union | ||
|
||
EdgeMergeModeValue = Union[str, "EdgeMergeMode"] | ||
|
||
|
||
class EdgeMergeMode(Enum): | ||
"""Input override mode.""" | ||
|
||
REPLACE = "replace" | ||
APPEND = "append" | ||
|
||
@classmethod | ||
def cast(cls, value: EdgeMergeModeValue) -> "EdgeMergeMode": | ||
if isinstance(value, EdgeMergeMode): | ||
return value | ||
if not value: | ||
return EdgeMergeMode.REPLACE | ||
return EdgeMergeMode(str(value).lower()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
type: string | ||
enum: | ||
- "replace" | ||
- "append" | ||
default: "replace" | ||
description: Whether to replace the values set for this input, or to append to them when overridden by e.g. a pipeline edge. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters