Skip to content

Commit 17c969d

Browse files
committed
fix(workflows): allow larger parallel batch sizes
1 parent d8da1e2 commit 17c969d

8 files changed

Lines changed: 18 additions & 11 deletions

File tree

apps/sim/executor/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export const DEFAULTS = {
174174
BLOCK_TITLE: 'Untitled Block',
175175
WORKFLOW_NAME: 'Workflow',
176176
DEFAULT_LOOP_ITERATIONS: 1000,
177-
MAX_PARALLEL_BRANCHES: 20,
177+
MAX_PARALLEL_BRANCHES: 100,
178178
MAX_NESTING_DEPTH: 10,
179179
/** Maximum child workflow depth for propagating SSE callbacks (block:started, block:completed). */
180180
MAX_SSE_CHILD_DEPTH: 3,

apps/sim/executor/orchestrators/parallel.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,15 @@ describe('ParallelOrchestrator', () => {
253253
'parallel-1'
254254
)
255255

256+
expect(oversizedBatchScope.batchSize).toBe(50)
256257
expect(oversizedBatchScope.currentBatchSize).toBe(9)
257258
})
258259

259260
it.each([
260261
['oversized numeric batch size', 999, DEFAULTS.MAX_PARALLEL_BRANCHES],
261262
['negative batch size', -1, 1],
262-
['undefined batch size', undefined, DEFAULTS.MAX_PARALLEL_BRANCHES],
263-
['nonnumeric batch size', 'not-a-number', DEFAULTS.MAX_PARALLEL_BRANCHES],
263+
['undefined batch size', undefined, 20],
264+
['nonnumeric batch size', 'not-a-number', 20],
264265
])('normalizes %s', async (_name, batchSize, expectedBatchSize) => {
265266
const dag = createDag()
266267
const parallelConfig = dag.parallelConfigs.get('parallel-1')!

apps/sim/hooks/use-collaborative-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ export function useCollaborativeWorkflow() {
19061906
const currentCount = currentBlock.data?.count || 5
19071907
const currentDistribution = currentBlock.data?.collection || ''
19081908
const currentParallelType = currentBlock.data?.parallelType || 'count'
1909-
const clampedBatchSize = Math.max(1, Math.min(20, batchSize))
1909+
const clampedBatchSize = Math.max(1, Math.min(100, batchSize))
19101910

19111911
const config = {
19121912
id: parallelId,

apps/sim/lib/workflows/search-replace/replacements.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,14 +1658,14 @@ describe('buildWorkflowSearchReplacePlan', () => {
16581658
blocks: workflow.blocks,
16591659
matches,
16601660
selectedMatchIds: new Set(matches.map((match) => match.id)),
1661-
defaultReplacement: '25',
1661+
defaultReplacement: '101',
16621662
})
16631663

16641664
expect(plan.subflowUpdates).toEqual([])
16651665
expect(plan.conflicts).toEqual([
16661666
{
16671667
matchId: 'subflow-text:parallel-1:subflowBatchSize:0:0',
1668-
reason: 'Parallel batch size must be between 1 and 20',
1668+
reason: 'Parallel batch size must be between 1 and 100',
16691669
},
16701670
])
16711671
})

apps/sim/lib/workflows/search-replace/subflow-fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function parseWorkflowSearchSubflowReplacement({
169169
}
170170

171171
const count = Number.parseInt(trimmed, 10)
172-
const maxBatchSize = 20
172+
const maxBatchSize = 100
173173
if (
174174
count < 1 ||
175175
(fieldId === WORKFLOW_SEARCH_SUBFLOW_FIELD_IDS.batchSize && count > maxBatchSize)

apps/sim/stores/workflows/workflow/store.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ describe('workflow store', () => {
603603
expect(state.blocks.parallel1?.data?.count).toBe(1)
604604
})
605605

606-
it('should clamp parallel batch size between 1 and 20', () => {
606+
it('should clamp parallel batch size between 1 and 100', () => {
607607
const { updateParallelBatchSize } = useWorkflowStore.getState()
608608

609609
addBlock(
@@ -625,7 +625,13 @@ describe('workflow store', () => {
625625

626626
updateParallelBatchSize('parallel1', 50)
627627
state = useWorkflowStore.getState()
628-
expect(state.blocks.parallel1?.data?.batchSize).toBe(20)
628+
expect(state.blocks.parallel1?.data?.batchSize).toBe(50)
629+
expect(state.parallels.parallel1.batchSize).toBe(50)
630+
631+
updateParallelBatchSize('parallel1', 101)
632+
state = useWorkflowStore.getState()
633+
expect(state.blocks.parallel1?.data?.batchSize).toBe(100)
634+
expect(state.parallels.parallel1.batchSize).toBe(100)
629635

630636
updateParallelBatchSize('parallel1', 0)
631637
state = useWorkflowStore.getState()

apps/sim/stores/workflows/workflow/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { BlockState, Loop, Parallel } from '@/stores/workflows/workflow/typ
77

88
const DEFAULT_LOOP_ITERATIONS = 5
99
const DEFAULT_PARALLEL_BATCH_SIZE = 20
10-
const MAX_PARALLEL_BATCH_SIZE = 20
10+
const MAX_PARALLEL_BATCH_SIZE = 100
1111

1212
export function clampParallelBatchSize(batchSize: unknown): number {
1313
const parsed = typeof batchSize === 'number' ? batchSize : Number.parseInt(String(batchSize), 10)

packages/workflow-persistence/src/subflow-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { BlockState, Loop, Parallel } from '@sim/workflow-types/workflow'
22

33
const DEFAULT_LOOP_ITERATIONS = 5
44
const DEFAULT_PARALLEL_BATCH_SIZE = 20
5-
const MAX_PARALLEL_BATCH_SIZE = 20
5+
const MAX_PARALLEL_BATCH_SIZE = 100
66

77
export function clampParallelBatchSize(batchSize: unknown): number {
88
const parsed = typeof batchSize === 'number' ? batchSize : Number.parseInt(String(batchSize), 10)

0 commit comments

Comments
 (0)