Skip to content

Commit

Permalink
Merge pull request #2 from speee/fix/parallel-max-submit
Browse files Browse the repository at this point in the history
apply reformat with ruff0.8.2
  • Loading branch information
kazuhisa-wada authored Dec 16, 2024
2 parents 843bcde + afc98a7 commit 0e60072
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/configs/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ class WorkflowNodeExecutionConfig(BaseSettings):
"""
Configuration for workflow node execution
"""

MAX_SUBMIT_COUNT: PositiveInt = Field(
description="Maximum number of submitted thread count in a ThreadPool for parallel node execution",
default=100,
Expand Down
10 changes: 5 additions & 5 deletions api/core/workflow/graph_engine/graph_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@

class GraphEngineThreadPool(ThreadPoolExecutor):
def __init__(
self,
max_workers=None,
self,
max_workers=None,
thread_name_prefix="",
initializer=None,
initargs=(),
max_submit_count=dify_config.MAX_SUBMIT_COUNT
initializer=None,
initargs=(),
max_submit_count=dify_config.MAX_SUBMIT_COUNT,
) -> None:
super().__init__(max_workers, thread_name_prefix, initializer, initargs)
self.max_submit_count = max_submit_count
Expand Down
5 changes: 3 additions & 2 deletions api/core/workflow/nodes/iteration/iteration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ def _run(self) -> Generator[NodeEvent | InNodeEvent, None, None]:
if self.node_data.is_parallel:
futures: list[Future] = []
q: Queue = Queue()
thread_pool = GraphEngineThreadPool(max_workers=self.node_data.parallel_nums,
max_submit_count=dify_config.MAX_SUBMIT_COUNT)
thread_pool = GraphEngineThreadPool(
max_workers=self.node_data.parallel_nums, max_submit_count=dify_config.MAX_SUBMIT_COUNT
)
for index, item in enumerate(iterator_list_value):
future: Future = thread_pool.submit(
self._run_single_iter_parallel,
Expand Down

0 comments on commit 0e60072

Please sign in to comment.