Skip to content

Commit

Permalink
refactor: Rename GraphTask to SubGraphWorker in graph_task.py and tes…
Browse files Browse the repository at this point in the history
…t_graph_task.py
  • Loading branch information
provos committed Oct 7, 2024
1 parent 482c9c9 commit 3843cee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/planai/graph_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
PRIVATE_STATE_KEY = "_graph_task_private_state"


class GraphTask(TaskWorker):
class SubGraphWorker(TaskWorker):
graph: Graph = Field(
..., description="The graph that will be run as part of this TaskWorker"
)
Expand Down Expand Up @@ -164,7 +164,7 @@ def consume_work(self, task: Task3WorkItem):
sub_graph.set_dependency(task1, task2)

# Create the graph task
graph_task = GraphTask(graph=sub_graph, entry_worker=task1, exit_worker=task2)
graph_task = SubGraphWorker(graph=sub_graph, entry_worker=task1, exit_worker=task2)

# Create the final consumer
task3 = Task3Worker()
Expand Down
12 changes: 6 additions & 6 deletions tests/planai/test_graph_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Type

from planai.graph import Graph
from planai.graph_task import GraphTask
from planai.graph_task import SubGraphWorker
from planai.joined_task import JoinedTaskWorker
from planai.task import Task, TaskWorker

Expand Down Expand Up @@ -31,7 +31,7 @@ def consume_work(self, task: InputTask):
self.publish_work(sub_task, input_task=task)


class SubGraphWorker(TaskWorker):
class SubGraphHandler(TaskWorker):
output_types: List[Type[Task]] = [SubGraphTask]

def consume_work(self, task: SubGraphTask):
Expand All @@ -54,7 +54,7 @@ def consume_work(self, task: SubGraphTask):
expected_provenance = [
("InitialTaskWorker", 1),
("MainWorker", 1),
("GraphTask", 1),
("SubGraphWorker", 1),
]
self.verify_provenance(task, expected_provenance)

Expand All @@ -70,13 +70,13 @@ class TestGraphTask(unittest.TestCase):
def test_graph_task_provenance(self):
# Create subgraph
subgraph = Graph(name="SubGraph")
subgraph_worker = SubGraphWorker()
subgraph_worker = SubGraphHandler()
subgraph_entry = subgraph_worker # Entry point
subgraph_exit = subgraph_worker # Exit point
subgraph.add_workers(subgraph_worker)

# Create GraphTask
graph_task = GraphTask(
graph_task = SubGraphWorker(
graph=subgraph, entry_worker=subgraph_entry, exit_worker=subgraph_exit
)

Expand Down Expand Up @@ -168,7 +168,7 @@ def consume_work_joined(self, tasks: List[SubInputTask]):
subgraph.set_dependency(sub_init_worker, sub_worker).next(sub_join_worker)

# Create GraphTask
graph_task = GraphTask(
graph_task = SubGraphWorker(
graph=subgraph, entry_worker=subgraph_entry, exit_worker=subgraph_exit
)

Expand Down

0 comments on commit 3843cee

Please sign in to comment.