Skip to content

Commit 02b2a8b

Browse files
Add disabled flag to MockNodeExecution (#3339)
* Add disabled flag to MockNodeExecution - Add disabled: bool = False field to MockNodeExecution class - Update runner to skip disabled mocks during evaluation - Add disabled field to TypeScript types and serializers - Update codegen to generate disabled parameter when true Co-Authored-By: [email protected] <[email protected]> * Fix serialization to exclude disabled=False from output Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
1 parent f5034f3 commit 02b2a8b

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

ee/codegen/src/generators/workflow-sandbox-file.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ if __name__ == "__main__":
290290
})
291291
);
292292

293+
// Generate disabled parameter if it's true
294+
if (mock.disabled === true) {
295+
arguments_.push(
296+
new MethodArgument({
297+
name: "disabled",
298+
value: python.TypeInstantiation.bool(true),
299+
})
300+
);
301+
}
302+
293303
return new ClassInstantiation({
294304
classReference: new Reference({
295305
name: "MockNodeExecution",

ee/codegen/src/serializers/vellum.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,6 +2601,7 @@ export declare namespace WorkflowSandboxDatasetRowMockSerializer {
26012601
node_id: string;
26022602
when_condition?: WorkflowValueDescriptorSerializer.Raw | null;
26032603
then_outputs?: Record<string, unknown> | null;
2604+
disabled?: boolean | null;
26042605
}
26052606
}
26062607

@@ -2611,6 +2612,7 @@ export const WorkflowSandboxDatasetRowMockSerializer: ObjectSchema<
26112612
node_id: stringSchema(),
26122613
when_condition: WorkflowValueDescriptorSerializer.optional(),
26132614
then_outputs: recordSchema(stringSchema(), unknownSchema()).optional(),
2615+
disabled: booleanSchema().optional(),
26142616
});
26152617

26162618
const WorkflowSandboxDatasetRowSerializer = undiscriminatedUnionSchema([

ee/codegen/src/types/vellum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ export interface WorkflowSandboxDatasetRowMock {
886886
node_id: string;
887887
when_condition?: WorkflowValueDescriptor;
888888
then_outputs?: Record<string, unknown>;
889+
disabled?: boolean;
889890
}
890891

891892
export type WorkflowSandboxDatasetRow =

src/vellum/workflows/nodes/mocks.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class _RawMockWorkflowNodeConfig(UniversalBaseModel):
103103
class MockNodeExecution(UniversalBaseModel):
104104
when_condition: BaseDescriptor
105105
then_outputs: BaseOutputs
106+
disabled: bool = False
106107

107108
model_config = ConfigDict(arbitrary_types_allowed=True)
108109

@@ -112,6 +113,8 @@ def serialize_full_model(self, handler: Callable[[Any], Any], info: Serializatio
112113
serialized = handler(self)
113114
serialized["node_id"] = str(self.then_outputs.__class__.__parent_class__.__id__)
114115
serialized["type"] = "NODE_EXECUTION"
116+
if not self.disabled:
117+
del serialized["disabled"]
115118
return serialized
116119

117120
@field_serializer("then_outputs")

src/vellum/workflows/runner/runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ def run_node(
510510
was_mocked: Optional[bool] = None
511511
mock_candidates = node_output_mocks_map.get(node.Outputs) or []
512512
for mock_candidate in mock_candidates:
513+
if mock_candidate.disabled:
514+
continue
513515
if mock_candidate.when_condition.resolve(node.state):
514516
node_run_response = mock_candidate.then_outputs
515517
was_mocked = True

0 commit comments

Comments
 (0)