Skip to content

Commit ec1af90

Browse files
authored
feat: UI
* chore: bump packages * fix(type): mypy issue * feat: visualisation mock of UI * feat: working graph visualisation with parallel nodes * feat: getting the data from the backend * feat: modal added to show metadata * feat: zoom on workflow * feat: Getting graph data from the actual graph and nodes * feat: Getting the source and function from the UI * feat: Uploading the source file via browser * feat: Failure paths are clearly shown * feat: parallel graph rendering works * feat: stub image added along with alias nodes * feat: Richer python task modal * feat: map node data * feat: bounding boxes around branches * feat: bounding boxes around branches * feat: cli entry point to see the graph * feat: dark mode * feat: dark mode
1 parent 269c02d commit ec1af90

33 files changed

+2317
-25
lines changed

examples/02-sequential/conditional.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from runnable import Conditional, Pipeline, PythonTask
1+
from runnable import Conditional, Pipeline, PythonTask, Stub
22

33

44
def when_heads_function():
@@ -50,7 +50,9 @@ def main():
5050
function=toss_function,
5151
returns=["toss"],
5252
)
53-
pipeline = Pipeline(steps=[toss_task, conditional])
53+
54+
continue_to = Stub(name="continue to")
55+
pipeline = Pipeline(steps=[toss_task, conditional, continue_to])
5456

5557
pipeline.execute()
5658

examples/06-parallel/parallel.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ def traversal():
4545
def main():
4646
parallel_step = Parallel(
4747
name="parallel_step",
48-
terminate_with_success=True,
4948
branches={
5049
"branch1": traversal(),
5150
"branch2": traversal(),
5251
},
5352
)
5453

55-
pipeline = Pipeline(steps=[parallel_step])
54+
continue_to = Stub(name="continue to")
55+
56+
pipeline = Pipeline(steps=[parallel_step, continue_to])
5657

5758
pipeline.execute()
5859
return pipeline

examples/06-parallel/parallel.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ dag:
3939
steps:
4040
parallel_step:
4141
type: parallel
42-
next: success
42+
next: continue_to
4343
branches:
4444
branch1: *branch
4545
branch2: *branch
46+
continue_to:
47+
type: stub
48+
next: success

examples/07-map/map.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
process_chunk,
1010
read_processed_chunk,
1111
)
12-
from runnable import Map, NotebookTask, Pipeline, PythonTask, ShellTask
12+
from runnable import Map, NotebookTask, Pipeline, PythonTask, ShellTask, Stub
1313

1414

1515
def iterable_branch(execute: bool = True):
@@ -101,9 +101,10 @@ def main():
101101
collect = PythonTask(
102102
name="collect",
103103
function=assert_default_reducer,
104-
terminate_with_success=True,
105104
)
106105

106+
continue_to = Stub(name="continue to")
107+
107108
pipeline = Pipeline(steps=[map_state, collect])
108109

109110
pipeline.execute(parameters_file="examples/common/initial_parameters.yaml")

extensions/nodes/conditional.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from runnable import console, defaults
88
from runnable.datastore import Parameter
99
from runnable.graph import Graph, create_graph
10-
from runnable.nodes import CompositeNode, MapVariableType
10+
from runnable.nodes import CompositeNode, MapVariableType, NodeInD3
1111

1212
logger = logging.getLogger(defaults.LOGGER_NAME)
1313

@@ -241,3 +241,21 @@ def fan_in(self, map_variable: MapVariableType = None):
241241
step_log.status = defaults.FAIL
242242

243243
self._context.run_log_store.add_step_log(step_log, self._context.run_id)
244+
245+
def to_d3_node(self) -> NodeInD3:
246+
def get_display_string() -> str:
247+
display = f"match {self.parameter}:\n"
248+
for case in self.branches.keys():
249+
display += f' case "{case}":\n ...\n'
250+
if self.default:
251+
display += " case _:\n ...\n"
252+
return display
253+
254+
return NodeInD3(
255+
id=self.internal_name,
256+
label="conditional",
257+
metadata={
258+
"conditioned on": self.parameter,
259+
"display": get_display_string(),
260+
},
261+
)

extensions/nodes/fail.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from runnable import datastore, defaults
77
from runnable.datastore import StepLog
88
from runnable.defaults import MapVariableType
9-
from runnable.nodes import TerminalNode
9+
from runnable.nodes import NodeInD3, TerminalNode
1010

1111

1212
class FailNode(TerminalNode):
@@ -70,3 +70,9 @@ def execute(
7070
step_log.attempts.append(attempt_log)
7171

7272
return step_log
73+
74+
def to_d3_node(self) -> NodeInD3:
75+
return NodeInD3(
76+
id=self.internal_name,
77+
label="fail",
78+
)

extensions/nodes/map.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
)
1919
from runnable.defaults import MapVariableType
2020
from runnable.graph import Graph, create_graph
21-
from runnable.nodes import CompositeNode
21+
from runnable.nodes import CompositeNode, NodeInD3
2222

2323
logger = logging.getLogger(defaults.LOGGER_NAME)
2424

@@ -348,3 +348,18 @@ def update_param(
348348
self._context.run_log_store.set_parameters(
349349
parameters=params, run_id=self._context.run_id
350350
)
351+
352+
def to_d3_node(self) -> NodeInD3:
353+
return NodeInD3(
354+
id=self.internal_name,
355+
label="map",
356+
metadata={
357+
"node_type": "map",
358+
"iterate_on": self.iterate_on, # Parameter name containing the iterable
359+
"iterate_as": self.iterate_as, # Name used for each iteration
360+
"map_branch_id": self.internal_name
361+
+ "."
362+
+ defaults.MAP_PLACEHOLDER, # The branch identifier pattern
363+
"is_composite": True, # Flag indicating this is a composite node
364+
},
365+
)

extensions/nodes/parallel.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from runnable import defaults
77
from runnable.defaults import MapVariableType
88
from runnable.graph import Graph, create_graph
9-
from runnable.nodes import CompositeNode
9+
from runnable.nodes import CompositeNode, NodeInD3
1010

1111

1212
class ParallelNode(CompositeNode):
@@ -157,3 +157,9 @@ def fan_in(self, map_variable: MapVariableType = None):
157157
step_log.status = defaults.FAIL
158158

159159
self._context.run_log_store.add_step_log(step_log, self._context.run_id)
160+
161+
def to_d3_node(self) -> NodeInD3:
162+
return NodeInD3(
163+
id=self.internal_name,
164+
label="parallel",
165+
)

extensions/nodes/stub.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from runnable import datastore, defaults
88
from runnable.datastore import StepLog
99
from runnable.defaults import MapVariableType
10-
from runnable.nodes import ExecutableNode
10+
from runnable.nodes import ExecutableNode, NodeInD3
1111

1212
logger = logging.getLogger(defaults.LOGGER_NAME)
1313

@@ -87,3 +87,9 @@ def execute(
8787
step_log.attempts.append(attempt_log)
8888

8989
return step_log
90+
91+
def to_d3_node(self) -> NodeInD3:
92+
return NodeInD3(
93+
id=self.internal_name,
94+
label="stub",
95+
)

extensions/nodes/success.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from runnable import datastore, defaults
77
from runnable.datastore import StepLog
88
from runnable.defaults import MapVariableType
9-
from runnable.nodes import TerminalNode
9+
from runnable.nodes import NodeInD3, TerminalNode
1010

1111

1212
class SuccessNode(TerminalNode):
@@ -70,3 +70,9 @@ def execute(
7070
step_log.attempts.append(attempt_log)
7171

7272
return step_log
73+
74+
def to_d3_node(self) -> NodeInD3:
75+
return NodeInD3(
76+
id=self.internal_name,
77+
label="success",
78+
)

0 commit comments

Comments
 (0)