mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
Fix loop/parallel yaml
This commit is contained in:
@@ -41,8 +41,13 @@ function extractBlockInputs(
|
||||
if (blockState.data) {
|
||||
Object.entries(blockState.data).forEach(([key, value]) => {
|
||||
// Include relevant configuration properties
|
||||
if (key === 'count' || key === 'loopType' || key === 'collection' ||
|
||||
key === 'parallelType' || key === 'distribution') {
|
||||
if (
|
||||
key === 'count' ||
|
||||
key === 'loopType' ||
|
||||
key === 'collection' ||
|
||||
key === 'parallelType' ||
|
||||
key === 'distribution'
|
||||
) {
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
inputs[key] = value
|
||||
}
|
||||
@@ -54,14 +59,14 @@ function extractBlockInputs(
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Include any additional values from subBlockValues that might not be in data
|
||||
Object.entries(blockSubBlockValues).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== '' && !inputs.hasOwnProperty(key)) {
|
||||
if (value !== undefined && value !== null && value !== '' && !Object.hasOwn(inputs, key)) {
|
||||
inputs[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return inputs
|
||||
}
|
||||
|
||||
|
||||
@@ -266,17 +266,17 @@ function sortBlocksByParentChildOrder(blocks: ImportedBlock[]): ImportedBlock[]
|
||||
const sorted: ImportedBlock[] = []
|
||||
const processed = new Set<string>()
|
||||
const visiting = new Set<string>() // Track blocks currently being processed to detect cycles
|
||||
|
||||
|
||||
// Create a map for quick lookup
|
||||
const blockMap = new Map<string, ImportedBlock>()
|
||||
blocks.forEach(block => blockMap.set(block.id, block))
|
||||
|
||||
blocks.forEach((block) => blockMap.set(block.id, block))
|
||||
|
||||
// Process blocks recursively, ensuring parents are added first
|
||||
function processBlock(block: ImportedBlock) {
|
||||
if (processed.has(block.id)) {
|
||||
return // Already processed
|
||||
}
|
||||
|
||||
|
||||
if (visiting.has(block.id)) {
|
||||
// Circular dependency detected - break the cycle by processing this block without its parent
|
||||
logger.warn(`Circular parent-child dependency detected for block ${block.id}, breaking cycle`)
|
||||
@@ -284,9 +284,9 @@ function sortBlocksByParentChildOrder(blocks: ImportedBlock[]): ImportedBlock[]
|
||||
processed.add(block.id)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
visiting.add(block.id)
|
||||
|
||||
|
||||
// If this block has a parent, ensure the parent is processed first
|
||||
if (block.parentId) {
|
||||
const parentBlock = blockMap.get(block.parentId)
|
||||
@@ -294,16 +294,16 @@ function sortBlocksByParentChildOrder(blocks: ImportedBlock[]): ImportedBlock[]
|
||||
processBlock(parentBlock)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now process this block
|
||||
visiting.delete(block.id)
|
||||
sorted.push(block)
|
||||
processed.add(block.id)
|
||||
}
|
||||
|
||||
|
||||
// Process all blocks
|
||||
blocks.forEach(block => processBlock(block))
|
||||
|
||||
blocks.forEach((block) => processBlock(block))
|
||||
|
||||
return sorted
|
||||
}
|
||||
|
||||
@@ -623,8 +623,8 @@ export async function importWorkflowFromYaml(
|
||||
} else {
|
||||
logger.warn(`Parent block not found for mapping: ${blockData.data.parentId}`)
|
||||
// Remove invalid parent reference
|
||||
delete blockData.data.parentId
|
||||
delete blockData.data.extent
|
||||
blockData.data.parentId = undefined
|
||||
blockData.data.extent = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user