Skip to content

Commit

Permalink
more flattening
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshKarpel committed Jun 26, 2024
1 parent 0e5b03d commit c1cf3ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 deletions.
18 changes: 6 additions & 12 deletions examples/dag.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
flows:
default:
1:
target:
id: sleep-and-echo
target: sleep-and-echo
2:
target:
id: sleep-and-echo
target: sleep-and-echo
3:
target:
id: sleep-and-echo
target: sleep-and-echo
4:
target:
id: sleep-and-echo
target: sleep-and-echo
trigger:
after: ["1", "2"]
5:
target:
id: sleep-and-echo
target: sleep-and-echo
trigger:
after: ["3"]
6:
target:
id: sleep-and-echo
target: sleep-and-echo
trigger:
after: ["4", "5"]

Expand Down
15 changes: 5 additions & 10 deletions synth.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
flows:
default:
tests:
target:
id: tests
trigger:
id: code-changes
target: tests
trigger: code-changes
types:
target:
id: types
trigger:
id: code-changes
target: types
trigger: code-changes
docs:
target:
id: docs
target: docs
trigger:
type: restart

Expand Down
18 changes: 4 additions & 14 deletions synthesize/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,12 @@ def write_script(self, tmp_dir: Path) -> Path:
return path


class TargetRef(Model):
id: str


class TriggerRef(Model):
id: str


class UnresolvedFlowNode(Model):
target: Target | TargetRef
target: Target | str
args: Args
envs: Envs

trigger: AnyTrigger | TriggerRef = Once()
trigger: AnyTrigger | str = Once()

color: Annotated[str, Field(default_factory=random_color)]

Expand All @@ -178,12 +170,10 @@ def resolve(
) -> FlowNode:
return FlowNode(
id=id,
target=targets[self.target.id] if isinstance(self.target, TargetRef) else self.target,
target=targets[self.target] if isinstance(self.target, str) else self.target,
args=self.args,
envs=self.envs,
trigger=(
triggers[self.trigger.id] if isinstance(self.trigger, TriggerRef) else self.trigger
),
trigger=(triggers[self.trigger] if isinstance(self.trigger, str) else self.trigger),
color=self.color,
)

Expand Down

0 comments on commit c1cf3ea

Please sign in to comment.