vellum-ai 0.9.16rc2__py3-none-any.whl → 0.9.16rc4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- vellum/plugins/__init__.py +0 -0
- vellum/plugins/pydantic.py +74 -0
- vellum/plugins/utils.py +19 -0
- vellum/plugins/vellum_mypy.py +639 -3
- vellum/workflows/README.md +90 -0
- vellum/workflows/__init__.py +5 -0
- vellum/workflows/constants.py +43 -0
- vellum/workflows/descriptors/__init__.py +0 -0
- vellum/workflows/descriptors/base.py +339 -0
- vellum/workflows/descriptors/tests/test_utils.py +83 -0
- vellum/workflows/descriptors/utils.py +90 -0
- vellum/workflows/edges/__init__.py +5 -0
- vellum/workflows/edges/edge.py +23 -0
- vellum/workflows/emitters/__init__.py +5 -0
- vellum/workflows/emitters/base.py +14 -0
- vellum/workflows/environment/__init__.py +5 -0
- vellum/workflows/environment/environment.py +7 -0
- vellum/workflows/errors/__init__.py +6 -0
- vellum/workflows/errors/types.py +20 -0
- vellum/workflows/events/__init__.py +31 -0
- vellum/workflows/events/node.py +125 -0
- vellum/workflows/events/tests/__init__.py +0 -0
- vellum/workflows/events/tests/test_event.py +216 -0
- vellum/workflows/events/types.py +52 -0
- vellum/workflows/events/utils.py +5 -0
- vellum/workflows/events/workflow.py +139 -0
- vellum/workflows/exceptions.py +15 -0
- vellum/workflows/expressions/__init__.py +0 -0
- vellum/workflows/expressions/accessor.py +52 -0
- vellum/workflows/expressions/and_.py +32 -0
- vellum/workflows/expressions/begins_with.py +31 -0
- vellum/workflows/expressions/between.py +38 -0
- vellum/workflows/expressions/coalesce_expression.py +41 -0
- vellum/workflows/expressions/contains.py +30 -0
- vellum/workflows/expressions/does_not_begin_with.py +31 -0
- vellum/workflows/expressions/does_not_contain.py +30 -0
- vellum/workflows/expressions/does_not_end_with.py +31 -0
- vellum/workflows/expressions/does_not_equal.py +25 -0
- vellum/workflows/expressions/ends_with.py +31 -0
- vellum/workflows/expressions/equals.py +25 -0
- vellum/workflows/expressions/greater_than.py +33 -0
- vellum/workflows/expressions/greater_than_or_equal_to.py +33 -0
- vellum/workflows/expressions/in_.py +31 -0
- vellum/workflows/expressions/is_blank.py +24 -0
- vellum/workflows/expressions/is_not_blank.py +24 -0
- vellum/workflows/expressions/is_not_null.py +21 -0
- vellum/workflows/expressions/is_not_undefined.py +22 -0
- vellum/workflows/expressions/is_null.py +21 -0
- vellum/workflows/expressions/is_undefined.py +22 -0
- vellum/workflows/expressions/less_than.py +33 -0
- vellum/workflows/expressions/less_than_or_equal_to.py +33 -0
- vellum/workflows/expressions/not_between.py +38 -0
- vellum/workflows/expressions/not_in.py +31 -0
- vellum/workflows/expressions/or_.py +32 -0
- vellum/workflows/graph/__init__.py +3 -0
- vellum/workflows/graph/graph.py +131 -0
- vellum/workflows/graph/tests/__init__.py +0 -0
- vellum/workflows/graph/tests/test_graph.py +437 -0
- vellum/workflows/inputs/__init__.py +5 -0
- vellum/workflows/inputs/base.py +55 -0
- vellum/workflows/logging.py +14 -0
- vellum/workflows/nodes/__init__.py +46 -0
- vellum/workflows/nodes/bases/__init__.py +7 -0
- vellum/workflows/nodes/bases/base.py +332 -0
- vellum/workflows/nodes/bases/base_subworkflow_node/__init__.py +5 -0
- vellum/workflows/nodes/bases/base_subworkflow_node/node.py +10 -0
- vellum/workflows/nodes/bases/tests/__init__.py +0 -0
- vellum/workflows/nodes/bases/tests/test_base_node.py +125 -0
- vellum/workflows/nodes/core/__init__.py +16 -0
- vellum/workflows/nodes/core/error_node/__init__.py +5 -0
- vellum/workflows/nodes/core/error_node/node.py +26 -0
- vellum/workflows/nodes/core/inline_subworkflow_node/__init__.py +5 -0
- vellum/workflows/nodes/core/inline_subworkflow_node/node.py +73 -0
- vellum/workflows/nodes/core/map_node/__init__.py +5 -0
- vellum/workflows/nodes/core/map_node/node.py +147 -0
- vellum/workflows/nodes/core/map_node/tests/__init__.py +0 -0
- vellum/workflows/nodes/core/map_node/tests/test_node.py +65 -0
- vellum/workflows/nodes/core/retry_node/__init__.py +5 -0
- vellum/workflows/nodes/core/retry_node/node.py +106 -0
- vellum/workflows/nodes/core/retry_node/tests/__init__.py +0 -0
- vellum/workflows/nodes/core/retry_node/tests/test_node.py +93 -0
- vellum/workflows/nodes/core/templating_node/__init__.py +5 -0
- vellum/workflows/nodes/core/templating_node/custom_filters.py +12 -0
- vellum/workflows/nodes/core/templating_node/exceptions.py +2 -0
- vellum/workflows/nodes/core/templating_node/node.py +123 -0
- vellum/workflows/nodes/core/templating_node/render.py +55 -0
- vellum/workflows/nodes/core/templating_node/tests/test_templating_node.py +21 -0
- vellum/workflows/nodes/core/try_node/__init__.py +5 -0
- vellum/workflows/nodes/core/try_node/node.py +110 -0
- vellum/workflows/nodes/core/try_node/tests/__init__.py +0 -0
- vellum/workflows/nodes/core/try_node/tests/test_node.py +82 -0
- vellum/workflows/nodes/displayable/__init__.py +31 -0
- vellum/workflows/nodes/displayable/api_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/api_node/node.py +44 -0
- vellum/workflows/nodes/displayable/bases/__init__.py +11 -0
- vellum/workflows/nodes/displayable/bases/api_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/bases/api_node/node.py +70 -0
- vellum/workflows/nodes/displayable/bases/base_prompt_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/bases/base_prompt_node/node.py +60 -0
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/constants.py +13 -0
- vellum/workflows/nodes/displayable/bases/inline_prompt_node/node.py +118 -0
- vellum/workflows/nodes/displayable/bases/prompt_deployment_node.py +98 -0
- vellum/workflows/nodes/displayable/bases/search_node.py +90 -0
- vellum/workflows/nodes/displayable/code_execution_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/code_execution_node/node.py +197 -0
- vellum/workflows/nodes/displayable/code_execution_node/tests/__init__.py +0 -0
- vellum/workflows/nodes/displayable/code_execution_node/tests/fixtures/__init__.py +0 -0
- vellum/workflows/nodes/displayable/code_execution_node/tests/fixtures/main.py +3 -0
- vellum/workflows/nodes/displayable/code_execution_node/tests/test_code_execution_node.py +111 -0
- vellum/workflows/nodes/displayable/code_execution_node/utils.py +10 -0
- vellum/workflows/nodes/displayable/conditional_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/conditional_node/node.py +25 -0
- vellum/workflows/nodes/displayable/final_output_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/final_output_node/node.py +43 -0
- vellum/workflows/nodes/displayable/guardrail_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/guardrail_node/node.py +97 -0
- vellum/workflows/nodes/displayable/inline_prompt_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/inline_prompt_node/node.py +41 -0
- vellum/workflows/nodes/displayable/merge_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/merge_node/node.py +10 -0
- vellum/workflows/nodes/displayable/prompt_deployment_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/prompt_deployment_node/node.py +45 -0
- vellum/workflows/nodes/displayable/search_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/search_node/node.py +26 -0
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/__init__.py +5 -0
- vellum/workflows/nodes/displayable/subworkflow_deployment_node/node.py +156 -0
- vellum/workflows/nodes/displayable/tests/__init__.py +0 -0
- vellum/workflows/nodes/displayable/tests/test_inline_text_prompt_node.py +148 -0
- vellum/workflows/nodes/displayable/tests/test_search_node_wth_text_output.py +134 -0
- vellum/workflows/nodes/displayable/tests/test_text_prompt_deployment_node.py +80 -0
- vellum/workflows/nodes/utils.py +27 -0
- vellum/workflows/outputs/__init__.py +6 -0
- vellum/workflows/outputs/base.py +196 -0
- vellum/workflows/ports/__init__.py +7 -0
- vellum/workflows/ports/node_ports.py +75 -0
- vellum/workflows/ports/port.py +75 -0
- vellum/workflows/ports/utils.py +40 -0
- vellum/workflows/references/__init__.py +17 -0
- vellum/workflows/references/environment_variable.py +20 -0
- vellum/workflows/references/execution_count.py +20 -0
- vellum/workflows/references/external_input.py +49 -0
- vellum/workflows/references/input.py +7 -0
- vellum/workflows/references/lazy.py +55 -0
- vellum/workflows/references/node.py +43 -0
- vellum/workflows/references/output.py +78 -0
- vellum/workflows/references/state_value.py +23 -0
- vellum/workflows/references/vellum_secret.py +15 -0
- vellum/workflows/references/workflow_input.py +41 -0
- vellum/workflows/resolvers/__init__.py +5 -0
- vellum/workflows/resolvers/base.py +15 -0
- vellum/workflows/runner/__init__.py +5 -0
- vellum/workflows/runner/runner.py +588 -0
- vellum/workflows/runner/types.py +18 -0
- vellum/workflows/state/__init__.py +5 -0
- vellum/workflows/state/base.py +327 -0
- vellum/workflows/state/context.py +18 -0
- vellum/workflows/state/encoder.py +57 -0
- vellum/workflows/state/store.py +28 -0
- vellum/workflows/state/tests/__init__.py +0 -0
- vellum/workflows/state/tests/test_state.py +113 -0
- vellum/workflows/types/__init__.py +0 -0
- vellum/workflows/types/core.py +91 -0
- vellum/workflows/types/generics.py +14 -0
- vellum/workflows/types/stack.py +39 -0
- vellum/workflows/types/tests/__init__.py +0 -0
- vellum/workflows/types/tests/test_utils.py +76 -0
- vellum/workflows/types/utils.py +164 -0
- vellum/workflows/utils/__init__.py +0 -0
- vellum/workflows/utils/names.py +13 -0
- vellum/workflows/utils/tests/__init__.py +0 -0
- vellum/workflows/utils/tests/test_names.py +15 -0
- vellum/workflows/utils/tests/test_vellum_variables.py +25 -0
- vellum/workflows/utils/vellum_variables.py +81 -0
- vellum/workflows/vellum_client.py +18 -0
- vellum/workflows/workflows/__init__.py +5 -0
- vellum/workflows/workflows/base.py +365 -0
- {vellum_ai-0.9.16rc2.dist-info → vellum_ai-0.9.16rc4.dist-info}/METADATA +2 -1
- {vellum_ai-0.9.16rc2.dist-info → vellum_ai-0.9.16rc4.dist-info}/RECORD +245 -7
- vellum_cli/__init__.py +72 -0
- vellum_cli/aliased_group.py +103 -0
- vellum_cli/config.py +96 -0
- vellum_cli/image_push.py +112 -0
- vellum_cli/logger.py +36 -0
- vellum_cli/pull.py +73 -0
- vellum_cli/push.py +121 -0
- vellum_cli/tests/test_config.py +100 -0
- vellum_cli/tests/test_pull.py +152 -0
- vellum_ee/workflows/__init__.py +0 -0
- vellum_ee/workflows/display/__init__.py +0 -0
- vellum_ee/workflows/display/base.py +73 -0
- vellum_ee/workflows/display/nodes/__init__.py +4 -0
- vellum_ee/workflows/display/nodes/base_node_display.py +116 -0
- vellum_ee/workflows/display/nodes/base_node_vellum_display.py +36 -0
- vellum_ee/workflows/display/nodes/get_node_display_class.py +25 -0
- vellum_ee/workflows/display/nodes/tests/__init__.py +0 -0
- vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +47 -0
- vellum_ee/workflows/display/nodes/types.py +18 -0
- vellum_ee/workflows/display/nodes/utils.py +33 -0
- vellum_ee/workflows/display/nodes/vellum/__init__.py +32 -0
- vellum_ee/workflows/display/nodes/vellum/api_node.py +205 -0
- vellum_ee/workflows/display/nodes/vellum/code_execution_node.py +71 -0
- vellum_ee/workflows/display/nodes/vellum/conditional_node.py +217 -0
- vellum_ee/workflows/display/nodes/vellum/final_output_node.py +61 -0
- vellum_ee/workflows/display/nodes/vellum/guardrail_node.py +49 -0
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +170 -0
- vellum_ee/workflows/display/nodes/vellum/inline_subworkflow_node.py +99 -0
- vellum_ee/workflows/display/nodes/vellum/map_node.py +100 -0
- vellum_ee/workflows/display/nodes/vellum/merge_node.py +48 -0
- vellum_ee/workflows/display/nodes/vellum/prompt_deployment_node.py +68 -0
- vellum_ee/workflows/display/nodes/vellum/search_node.py +193 -0
- vellum_ee/workflows/display/nodes/vellum/subworkflow_deployment_node.py +58 -0
- vellum_ee/workflows/display/nodes/vellum/templating_node.py +67 -0
- vellum_ee/workflows/display/nodes/vellum/tests/__init__.py +0 -0
- vellum_ee/workflows/display/nodes/vellum/tests/test_utils.py +106 -0
- vellum_ee/workflows/display/nodes/vellum/try_node.py +38 -0
- vellum_ee/workflows/display/nodes/vellum/utils.py +76 -0
- vellum_ee/workflows/display/tests/__init__.py +0 -0
- vellum_ee/workflows/display/tests/workflow_serialization/__init__.py +0 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_api_node_serialization.py +426 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +607 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_conditional_node_serialization.py +1175 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_guardrail_node_serialization.py +235 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +511 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_map_node_serialization.py +372 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_merge_node_serialization.py +272 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_prompt_deployment_serialization.py +289 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_subworkflow_deployment_serialization.py +354 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_terminal_node_serialization.py +123 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_try_node_serialization.py +84 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_complex_terminal_node_serialization.py +233 -0
- vellum_ee/workflows/display/types.py +46 -0
- vellum_ee/workflows/display/utils/__init__.py +0 -0
- vellum_ee/workflows/display/utils/tests/__init__.py +0 -0
- vellum_ee/workflows/display/utils/tests/test_uuids.py +16 -0
- vellum_ee/workflows/display/utils/uuids.py +24 -0
- vellum_ee/workflows/display/utils/vellum.py +121 -0
- vellum_ee/workflows/display/vellum.py +357 -0
- vellum_ee/workflows/display/workflows/__init__.py +5 -0
- vellum_ee/workflows/display/workflows/base_workflow_display.py +302 -0
- vellum_ee/workflows/display/workflows/get_vellum_workflow_display_class.py +32 -0
- vellum_ee/workflows/display/workflows/vellum_workflow_display.py +386 -0
- {vellum_ai-0.9.16rc2.dist-info → vellum_ai-0.9.16rc4.dist-info}/LICENSE +0 -0
- {vellum_ai-0.9.16rc2.dist-info → vellum_ai-0.9.16rc4.dist-info}/WHEEL +0 -0
- {vellum_ai-0.9.16rc2.dist-info → vellum_ai-0.9.16rc4.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,607 @@
|
|
1
|
+
from deepdiff import DeepDiff
|
2
|
+
|
3
|
+
from tests.workflows.basic_code_execution_node.try_workflow import TrySimpleCodeExecutionWorkflow
|
4
|
+
from tests.workflows.basic_code_execution_node.workflow import SimpleCodeExecutionWorkflow
|
5
|
+
from vellum_ee.workflows.display.workflows import VellumWorkflowDisplay
|
6
|
+
from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
|
7
|
+
|
8
|
+
|
9
|
+
def test_serialize_workflow():
|
10
|
+
# GIVEN a Workflow with a code execution node
|
11
|
+
# WHEN we serialize it
|
12
|
+
workflow_display = get_workflow_display(
|
13
|
+
base_display_class=VellumWorkflowDisplay, workflow_class=SimpleCodeExecutionWorkflow
|
14
|
+
)
|
15
|
+
serialized_workflow: dict = workflow_display.serialize()
|
16
|
+
|
17
|
+
# THEN we should get a serialized representation of the Workflow
|
18
|
+
assert serialized_workflow.keys() == {
|
19
|
+
"workflow_raw_data",
|
20
|
+
"input_variables",
|
21
|
+
"output_variables",
|
22
|
+
}
|
23
|
+
|
24
|
+
# AND its input variables should be what we expect
|
25
|
+
input_variables = serialized_workflow["input_variables"]
|
26
|
+
assert len(input_variables) == 0
|
27
|
+
|
28
|
+
# AND its output variables should be what we expect
|
29
|
+
output_variables = serialized_workflow["output_variables"]
|
30
|
+
assert len(output_variables) == 2
|
31
|
+
assert not DeepDiff(
|
32
|
+
[
|
33
|
+
{"id": "ecdb8bf3-f456-400a-94af-a8f8338096b8", "key": "log", "type": "STRING"},
|
34
|
+
{"id": "461585c0-0f65-4d18-ba69-fdfb3874d2b3", "key": "result", "type": "NUMBER"},
|
35
|
+
],
|
36
|
+
output_variables,
|
37
|
+
ignore_order=True,
|
38
|
+
)
|
39
|
+
|
40
|
+
# AND its raw data should be what we expect
|
41
|
+
workflow_raw_data = serialized_workflow["workflow_raw_data"]
|
42
|
+
assert workflow_raw_data.keys() == {"edges", "nodes", "display_data", "definition"}
|
43
|
+
assert len(workflow_raw_data["edges"]) == 3
|
44
|
+
assert len(workflow_raw_data["nodes"]) == 4
|
45
|
+
|
46
|
+
# AND each node should be serialized correctly
|
47
|
+
entrypoint_node = workflow_raw_data["nodes"][0]
|
48
|
+
assert entrypoint_node == {
|
49
|
+
"id": "6d94a007-9b25-4b4f-a31d-74e7965b6696",
|
50
|
+
"type": "ENTRYPOINT",
|
51
|
+
"inputs": [],
|
52
|
+
"data": {
|
53
|
+
"label": "Entrypoint Node",
|
54
|
+
"source_handle_id": "5474e6da-f14c-458f-a82b-7a05fdfe3e5b",
|
55
|
+
},
|
56
|
+
"definition": {
|
57
|
+
"bases": [],
|
58
|
+
"module": [
|
59
|
+
"vellum",
|
60
|
+
"workflows",
|
61
|
+
"nodes",
|
62
|
+
"bases",
|
63
|
+
"base",
|
64
|
+
],
|
65
|
+
"name": "BaseNode",
|
66
|
+
},
|
67
|
+
"display_data": {
|
68
|
+
"position": {"x": 0.0, "y": 0.0},
|
69
|
+
},
|
70
|
+
}
|
71
|
+
|
72
|
+
code_execution_node = workflow_raw_data["nodes"][1]
|
73
|
+
assert code_execution_node == {
|
74
|
+
"id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
75
|
+
"type": "CODE_EXECUTION",
|
76
|
+
"inputs": [
|
77
|
+
{
|
78
|
+
"id": "f2e8a4fa-b54e-41e9-b314-0e5443519ac7",
|
79
|
+
"key": "code",
|
80
|
+
"value": {
|
81
|
+
"rules": [
|
82
|
+
{
|
83
|
+
"type": "CONSTANT_VALUE",
|
84
|
+
"data": {"type": "STRING", "value": "# flake8: noqa\ndef main():\n return 0\n"},
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"combinator": "OR",
|
88
|
+
},
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"id": "19d64948-f22b-4103-a7f5-3add184b31cc",
|
92
|
+
"key": "runtime",
|
93
|
+
"value": {
|
94
|
+
"rules": [{"type": "CONSTANT_VALUE", "data": {"type": "STRING", "value": "PYTHON_3_11_6"}}],
|
95
|
+
"combinator": "OR",
|
96
|
+
},
|
97
|
+
},
|
98
|
+
],
|
99
|
+
"data": {
|
100
|
+
"label": "Simple Code Execution Node",
|
101
|
+
"error_output_id": None,
|
102
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
103
|
+
"target_handle_id": "e02a2701-22c0-4533-8b00-175998e7350a",
|
104
|
+
"code_input_id": "f2e8a4fa-b54e-41e9-b314-0e5443519ac7",
|
105
|
+
"runtime_input_id": "19d64948-f22b-4103-a7f5-3add184b31cc",
|
106
|
+
"output_type": "NUMBER",
|
107
|
+
"packages": [],
|
108
|
+
"output_id": "0fde9607-353f-42c2-85c4-20f720ebc1ec",
|
109
|
+
"log_output_id": "7cac05e3-b7c3-475e-8df8-422b496c3398",
|
110
|
+
},
|
111
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
112
|
+
"definition": {
|
113
|
+
"bases": [
|
114
|
+
{
|
115
|
+
"module": [
|
116
|
+
"vellum",
|
117
|
+
"workflows",
|
118
|
+
"nodes",
|
119
|
+
"displayable",
|
120
|
+
"code_execution_node",
|
121
|
+
"node",
|
122
|
+
],
|
123
|
+
"name": "CodeExecutionNode",
|
124
|
+
}
|
125
|
+
],
|
126
|
+
"module": [
|
127
|
+
"tests",
|
128
|
+
"workflows",
|
129
|
+
"basic_code_execution_node",
|
130
|
+
"workflow",
|
131
|
+
],
|
132
|
+
"name": "SimpleCodeExecutionNode",
|
133
|
+
},
|
134
|
+
}
|
135
|
+
|
136
|
+
assert not DeepDiff(
|
137
|
+
[
|
138
|
+
{
|
139
|
+
"id": "e81b713c-b356-4654-9715-e8c54e3ca267",
|
140
|
+
"type": "TERMINAL",
|
141
|
+
"data": {
|
142
|
+
"label": "Final Output",
|
143
|
+
"name": "result",
|
144
|
+
"target_handle_id": "c0890e2a-8827-4f99-8e9a-144c7e937f33",
|
145
|
+
"output_id": "461585c0-0f65-4d18-ba69-fdfb3874d2b3",
|
146
|
+
"output_type": "NUMBER",
|
147
|
+
"node_input_id": "c28cc3c7-1285-4be3-ac51-c73456cee961",
|
148
|
+
},
|
149
|
+
"inputs": [
|
150
|
+
{
|
151
|
+
"id": "c28cc3c7-1285-4be3-ac51-c73456cee961",
|
152
|
+
"key": "node_input",
|
153
|
+
"value": {
|
154
|
+
"rules": [
|
155
|
+
{
|
156
|
+
"type": "NODE_OUTPUT",
|
157
|
+
"data": {
|
158
|
+
"node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
159
|
+
"output_id": "0fde9607-353f-42c2-85c4-20f720ebc1ec",
|
160
|
+
},
|
161
|
+
}
|
162
|
+
],
|
163
|
+
"combinator": "OR",
|
164
|
+
},
|
165
|
+
}
|
166
|
+
],
|
167
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
168
|
+
"definition": {
|
169
|
+
"bases": [
|
170
|
+
{
|
171
|
+
"bases": [],
|
172
|
+
"module": [
|
173
|
+
"vellum",
|
174
|
+
"workflows",
|
175
|
+
"nodes",
|
176
|
+
"bases",
|
177
|
+
"base",
|
178
|
+
],
|
179
|
+
"name": "BaseNode",
|
180
|
+
},
|
181
|
+
],
|
182
|
+
"module": [
|
183
|
+
"vellum",
|
184
|
+
"workflows",
|
185
|
+
"nodes",
|
186
|
+
"displayable",
|
187
|
+
"final_output_node",
|
188
|
+
"node",
|
189
|
+
],
|
190
|
+
"name": "FinalOutputNode",
|
191
|
+
},
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"id": "59e52e86-8059-4f32-b1f0-54f500b167a9",
|
195
|
+
"type": "TERMINAL",
|
196
|
+
"data": {
|
197
|
+
"label": "Final Output",
|
198
|
+
"name": "log",
|
199
|
+
"target_handle_id": "bb56d2ed-f5e2-4c00-a2ef-445a2210d6d1",
|
200
|
+
"output_id": "ecdb8bf3-f456-400a-94af-a8f8338096b8",
|
201
|
+
"output_type": "STRING",
|
202
|
+
"node_input_id": "e34369ff-8795-4f4f-8f40-c535a1c368bf",
|
203
|
+
},
|
204
|
+
"inputs": [
|
205
|
+
{
|
206
|
+
"id": "e34369ff-8795-4f4f-8f40-c535a1c368bf",
|
207
|
+
"key": "node_input",
|
208
|
+
"value": {
|
209
|
+
"rules": [
|
210
|
+
{
|
211
|
+
"type": "NODE_OUTPUT",
|
212
|
+
"data": {
|
213
|
+
"node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
214
|
+
"output_id": "7cac05e3-b7c3-475e-8df8-422b496c3398",
|
215
|
+
},
|
216
|
+
}
|
217
|
+
],
|
218
|
+
"combinator": "OR",
|
219
|
+
},
|
220
|
+
}
|
221
|
+
],
|
222
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
223
|
+
"definition": {
|
224
|
+
"bases": [
|
225
|
+
{
|
226
|
+
"bases": [],
|
227
|
+
"module": [
|
228
|
+
"vellum",
|
229
|
+
"workflows",
|
230
|
+
"nodes",
|
231
|
+
"bases",
|
232
|
+
"base",
|
233
|
+
],
|
234
|
+
"name": "BaseNode",
|
235
|
+
},
|
236
|
+
],
|
237
|
+
"module": [
|
238
|
+
"vellum",
|
239
|
+
"workflows",
|
240
|
+
"nodes",
|
241
|
+
"displayable",
|
242
|
+
"final_output_node",
|
243
|
+
"node",
|
244
|
+
],
|
245
|
+
"name": "FinalOutputNode",
|
246
|
+
},
|
247
|
+
},
|
248
|
+
],
|
249
|
+
workflow_raw_data["nodes"][2:],
|
250
|
+
ignore_order=True,
|
251
|
+
)
|
252
|
+
|
253
|
+
# AND each edge should be serialized correctly
|
254
|
+
serialized_edges = workflow_raw_data["edges"]
|
255
|
+
assert not DeepDiff(
|
256
|
+
[
|
257
|
+
{
|
258
|
+
"id": "7cb7522b-3d91-474c-a3ad-6170b8d0def1",
|
259
|
+
"source_node_id": "6d94a007-9b25-4b4f-a31d-74e7965b6696",
|
260
|
+
"source_handle_id": "5474e6da-f14c-458f-a82b-7a05fdfe3e5b",
|
261
|
+
"target_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
262
|
+
"target_handle_id": "e02a2701-22c0-4533-8b00-175998e7350a",
|
263
|
+
"type": "DEFAULT",
|
264
|
+
},
|
265
|
+
{
|
266
|
+
"id": "1b2ef8d2-9220-4aa7-9f09-fced39002337",
|
267
|
+
"source_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
268
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
269
|
+
"target_node_id": "59e52e86-8059-4f32-b1f0-54f500b167a9",
|
270
|
+
"target_handle_id": "bb56d2ed-f5e2-4c00-a2ef-445a2210d6d1",
|
271
|
+
"type": "DEFAULT",
|
272
|
+
},
|
273
|
+
{
|
274
|
+
"id": "caa519a9-3c17-45f2-b67f-7dc656780300",
|
275
|
+
"source_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
276
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
277
|
+
"target_node_id": "e81b713c-b356-4654-9715-e8c54e3ca267",
|
278
|
+
"target_handle_id": "c0890e2a-8827-4f99-8e9a-144c7e937f33",
|
279
|
+
"type": "DEFAULT",
|
280
|
+
},
|
281
|
+
],
|
282
|
+
serialized_edges,
|
283
|
+
ignore_order=True,
|
284
|
+
)
|
285
|
+
|
286
|
+
# AND the display data should be what we expect
|
287
|
+
display_data = workflow_raw_data["display_data"]
|
288
|
+
assert display_data == {
|
289
|
+
"viewport": {
|
290
|
+
"x": 0.0,
|
291
|
+
"y": 0.0,
|
292
|
+
"zoom": 1.0,
|
293
|
+
}
|
294
|
+
}
|
295
|
+
|
296
|
+
# AND the definition should be what we expect
|
297
|
+
definition = workflow_raw_data["definition"]
|
298
|
+
assert definition == {
|
299
|
+
"name": "SimpleCodeExecutionWorkflow",
|
300
|
+
"module": [
|
301
|
+
"tests",
|
302
|
+
"workflows",
|
303
|
+
"basic_code_execution_node",
|
304
|
+
"workflow",
|
305
|
+
],
|
306
|
+
}
|
307
|
+
|
308
|
+
|
309
|
+
def test_serialize_workflow__try_wrapped():
|
310
|
+
# GIVEN a Workflow with a code execution node
|
311
|
+
# WHEN we serialize it
|
312
|
+
workflow_display = get_workflow_display(
|
313
|
+
base_display_class=VellumWorkflowDisplay, workflow_class=TrySimpleCodeExecutionWorkflow
|
314
|
+
)
|
315
|
+
serialized_workflow: dict = workflow_display.serialize()
|
316
|
+
|
317
|
+
# THEN we should get a serialized representation of the Workflow
|
318
|
+
assert serialized_workflow.keys() == {
|
319
|
+
"workflow_raw_data",
|
320
|
+
"input_variables",
|
321
|
+
"output_variables",
|
322
|
+
}
|
323
|
+
|
324
|
+
# AND its input variables should be what we expect
|
325
|
+
input_variables = serialized_workflow["input_variables"]
|
326
|
+
assert len(input_variables) == 0
|
327
|
+
|
328
|
+
# AND its output variables should be what we expect
|
329
|
+
output_variables = serialized_workflow["output_variables"]
|
330
|
+
assert len(output_variables) == 2
|
331
|
+
assert not DeepDiff(
|
332
|
+
[
|
333
|
+
{"id": "5fbd27a0-9831-49c7-93c8-9c2a28c78696", "key": "log", "type": "STRING"},
|
334
|
+
{"id": "400f9ffe-e700-4204-a810-e06123565947", "key": "result", "type": "NUMBER"},
|
335
|
+
],
|
336
|
+
output_variables,
|
337
|
+
ignore_order=True,
|
338
|
+
)
|
339
|
+
|
340
|
+
# AND its raw data should be what we expect
|
341
|
+
workflow_raw_data = serialized_workflow["workflow_raw_data"]
|
342
|
+
assert workflow_raw_data.keys() == {"edges", "nodes", "display_data", "definition"}
|
343
|
+
assert len(workflow_raw_data["edges"]) == 3
|
344
|
+
assert len(workflow_raw_data["nodes"]) == 4
|
345
|
+
|
346
|
+
# AND each node should be serialized correctly
|
347
|
+
entrypoint_node = workflow_raw_data["nodes"][0]
|
348
|
+
assert entrypoint_node == {
|
349
|
+
"id": "1b300de0-cf41-493f-ab41-6fdadf406f6a",
|
350
|
+
"type": "ENTRYPOINT",
|
351
|
+
"inputs": [],
|
352
|
+
"data": {
|
353
|
+
"label": "Entrypoint Node",
|
354
|
+
"source_handle_id": "8cd1e612-39aa-4471-88cf-f7999b713fa6",
|
355
|
+
},
|
356
|
+
"definition": {
|
357
|
+
"bases": [],
|
358
|
+
"module": [
|
359
|
+
"vellum",
|
360
|
+
"workflows",
|
361
|
+
"nodes",
|
362
|
+
"bases",
|
363
|
+
"base",
|
364
|
+
],
|
365
|
+
"name": "BaseNode",
|
366
|
+
},
|
367
|
+
"display_data": {
|
368
|
+
"position": {"x": 0.0, "y": 0.0},
|
369
|
+
},
|
370
|
+
}
|
371
|
+
|
372
|
+
code_execution_node = workflow_raw_data["nodes"][1]
|
373
|
+
assert code_execution_node == {
|
374
|
+
"id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
375
|
+
"type": "CODE_EXECUTION",
|
376
|
+
"inputs": [
|
377
|
+
{
|
378
|
+
"id": "f2e8a4fa-b54e-41e9-b314-0e5443519ac7",
|
379
|
+
"key": "code",
|
380
|
+
"value": {
|
381
|
+
"rules": [
|
382
|
+
{
|
383
|
+
"type": "CONSTANT_VALUE",
|
384
|
+
"data": {"type": "STRING", "value": "# flake8: noqa\ndef main():\n return 0\n"},
|
385
|
+
}
|
386
|
+
],
|
387
|
+
"combinator": "OR",
|
388
|
+
},
|
389
|
+
},
|
390
|
+
{
|
391
|
+
"id": "19d64948-f22b-4103-a7f5-3add184b31cc",
|
392
|
+
"key": "runtime",
|
393
|
+
"value": {
|
394
|
+
"rules": [{"type": "CONSTANT_VALUE", "data": {"type": "STRING", "value": "PYTHON_3_11_6"}}],
|
395
|
+
"combinator": "OR",
|
396
|
+
},
|
397
|
+
},
|
398
|
+
],
|
399
|
+
"data": {
|
400
|
+
"label": "Simple Code Execution Node",
|
401
|
+
"error_output_id": "7236b0f4-b6bb-4103-a993-a8908d597dc3",
|
402
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
403
|
+
"target_handle_id": "e02a2701-22c0-4533-8b00-175998e7350a",
|
404
|
+
"code_input_id": "f2e8a4fa-b54e-41e9-b314-0e5443519ac7",
|
405
|
+
"runtime_input_id": "19d64948-f22b-4103-a7f5-3add184b31cc",
|
406
|
+
"output_type": "NUMBER",
|
407
|
+
"packages": [],
|
408
|
+
"output_id": "0fde9607-353f-42c2-85c4-20f720ebc1ec",
|
409
|
+
"log_output_id": "7cac05e3-b7c3-475e-8df8-422b496c3398",
|
410
|
+
},
|
411
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
412
|
+
"definition": {
|
413
|
+
"bases": [
|
414
|
+
{
|
415
|
+
"module": [
|
416
|
+
"vellum",
|
417
|
+
"workflows",
|
418
|
+
"nodes",
|
419
|
+
"displayable",
|
420
|
+
"code_execution_node",
|
421
|
+
"node",
|
422
|
+
],
|
423
|
+
"name": "CodeExecutionNode",
|
424
|
+
}
|
425
|
+
],
|
426
|
+
"module": [
|
427
|
+
"tests",
|
428
|
+
"workflows",
|
429
|
+
"basic_code_execution_node",
|
430
|
+
"try_workflow",
|
431
|
+
],
|
432
|
+
"name": "SimpleCodeExecutionNode",
|
433
|
+
},
|
434
|
+
}
|
435
|
+
|
436
|
+
final_output_nodes = workflow_raw_data["nodes"][2:]
|
437
|
+
assert not DeepDiff(
|
438
|
+
[
|
439
|
+
{
|
440
|
+
"id": "af4fc1ef-7701-43df-b5e7-4f354f707db2",
|
441
|
+
"type": "TERMINAL",
|
442
|
+
"definition": {
|
443
|
+
"bases": [
|
444
|
+
{
|
445
|
+
"bases": [],
|
446
|
+
"module": [
|
447
|
+
"vellum",
|
448
|
+
"workflows",
|
449
|
+
"nodes",
|
450
|
+
"bases",
|
451
|
+
"base",
|
452
|
+
],
|
453
|
+
"name": "BaseNode",
|
454
|
+
},
|
455
|
+
],
|
456
|
+
"module": [
|
457
|
+
"vellum",
|
458
|
+
"workflows",
|
459
|
+
"nodes",
|
460
|
+
"displayable",
|
461
|
+
"final_output_node",
|
462
|
+
"node",
|
463
|
+
],
|
464
|
+
"name": "FinalOutputNode",
|
465
|
+
},
|
466
|
+
"data": {
|
467
|
+
"label": "Final Output",
|
468
|
+
"name": "log",
|
469
|
+
"target_handle_id": "d243df8d-46f6-4928-ac31-7c775c5d73a9",
|
470
|
+
"output_id": "5fbd27a0-9831-49c7-93c8-9c2a28c78696",
|
471
|
+
"output_type": "STRING",
|
472
|
+
"node_input_id": "569e1c05-53fa-413b-abf0-0353eaa44208",
|
473
|
+
},
|
474
|
+
"inputs": [
|
475
|
+
{
|
476
|
+
"id": "569e1c05-53fa-413b-abf0-0353eaa44208",
|
477
|
+
"key": "node_input",
|
478
|
+
"value": {
|
479
|
+
"rules": [
|
480
|
+
{
|
481
|
+
"type": "NODE_OUTPUT",
|
482
|
+
"data": {
|
483
|
+
"node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
484
|
+
"output_id": "7cac05e3-b7c3-475e-8df8-422b496c3398",
|
485
|
+
},
|
486
|
+
}
|
487
|
+
],
|
488
|
+
"combinator": "OR",
|
489
|
+
},
|
490
|
+
}
|
491
|
+
],
|
492
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
493
|
+
},
|
494
|
+
{
|
495
|
+
"id": "4cbfa5f7-fc12-4ab2-81cb-168c5caef4f0",
|
496
|
+
"type": "TERMINAL",
|
497
|
+
"definition": {
|
498
|
+
"bases": [
|
499
|
+
{
|
500
|
+
"bases": [],
|
501
|
+
"module": [
|
502
|
+
"vellum",
|
503
|
+
"workflows",
|
504
|
+
"nodes",
|
505
|
+
"bases",
|
506
|
+
"base",
|
507
|
+
],
|
508
|
+
"name": "BaseNode",
|
509
|
+
},
|
510
|
+
],
|
511
|
+
"module": [
|
512
|
+
"vellum",
|
513
|
+
"workflows",
|
514
|
+
"nodes",
|
515
|
+
"displayable",
|
516
|
+
"final_output_node",
|
517
|
+
"node",
|
518
|
+
],
|
519
|
+
"name": "FinalOutputNode",
|
520
|
+
},
|
521
|
+
"data": {
|
522
|
+
"label": "Final Output",
|
523
|
+
"name": "result",
|
524
|
+
"target_handle_id": "9c43709e-25cb-4548-b840-3fcf6a1c9f3e",
|
525
|
+
"output_id": "400f9ffe-e700-4204-a810-e06123565947",
|
526
|
+
"output_type": "NUMBER",
|
527
|
+
"node_input_id": "3d6cb7ef-985f-48f1-ad23-de49be60666a",
|
528
|
+
},
|
529
|
+
"inputs": [
|
530
|
+
{
|
531
|
+
"id": "3d6cb7ef-985f-48f1-ad23-de49be60666a",
|
532
|
+
"key": "node_input",
|
533
|
+
"value": {
|
534
|
+
"rules": [
|
535
|
+
{
|
536
|
+
"type": "NODE_OUTPUT",
|
537
|
+
"data": {
|
538
|
+
"node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
539
|
+
"output_id": "0fde9607-353f-42c2-85c4-20f720ebc1ec",
|
540
|
+
},
|
541
|
+
}
|
542
|
+
],
|
543
|
+
"combinator": "OR",
|
544
|
+
},
|
545
|
+
}
|
546
|
+
],
|
547
|
+
"display_data": {"position": {"x": 0.0, "y": 0.0}},
|
548
|
+
},
|
549
|
+
],
|
550
|
+
final_output_nodes,
|
551
|
+
ignore_order=True,
|
552
|
+
)
|
553
|
+
|
554
|
+
# AND each edge should be serialized correctly
|
555
|
+
serialized_edges = workflow_raw_data["edges"]
|
556
|
+
assert not DeepDiff(
|
557
|
+
[
|
558
|
+
{
|
559
|
+
"id": "a95418ec-d44e-48e1-bb5e-b5b3cb060c38",
|
560
|
+
"source_node_id": "1b300de0-cf41-493f-ab41-6fdadf406f6a",
|
561
|
+
"source_handle_id": "8cd1e612-39aa-4471-88cf-f7999b713fa6",
|
562
|
+
"target_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
563
|
+
"target_handle_id": "e02a2701-22c0-4533-8b00-175998e7350a",
|
564
|
+
"type": "DEFAULT",
|
565
|
+
},
|
566
|
+
{
|
567
|
+
"id": "ac96ad63-d91f-465c-9c52-629877e56492",
|
568
|
+
"source_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
569
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
570
|
+
"target_node_id": "af4fc1ef-7701-43df-b5e7-4f354f707db2",
|
571
|
+
"target_handle_id": "d243df8d-46f6-4928-ac31-7c775c5d73a9",
|
572
|
+
"type": "DEFAULT",
|
573
|
+
},
|
574
|
+
{
|
575
|
+
"id": "636f4540-e0e3-4740-af72-45f78b700cf9",
|
576
|
+
"source_node_id": "c07155b3-7d99-4d2d-9b29-b5298013aa46",
|
577
|
+
"source_handle_id": "832f81ec-427b-42a8-825c-e62c43c1f961",
|
578
|
+
"target_node_id": "4cbfa5f7-fc12-4ab2-81cb-168c5caef4f0",
|
579
|
+
"target_handle_id": "9c43709e-25cb-4548-b840-3fcf6a1c9f3e",
|
580
|
+
"type": "DEFAULT",
|
581
|
+
},
|
582
|
+
],
|
583
|
+
serialized_edges,
|
584
|
+
ignore_order=True,
|
585
|
+
)
|
586
|
+
|
587
|
+
# AND the display data should be what we expect
|
588
|
+
display_data = workflow_raw_data["display_data"]
|
589
|
+
assert display_data == {
|
590
|
+
"viewport": {
|
591
|
+
"x": 0.0,
|
592
|
+
"y": 0.0,
|
593
|
+
"zoom": 1.0,
|
594
|
+
}
|
595
|
+
}
|
596
|
+
|
597
|
+
# AND the definition should be what we expect
|
598
|
+
definition = workflow_raw_data["definition"]
|
599
|
+
assert definition == {
|
600
|
+
"name": "TrySimpleCodeExecutionWorkflow",
|
601
|
+
"module": [
|
602
|
+
"tests",
|
603
|
+
"workflows",
|
604
|
+
"basic_code_execution_node",
|
605
|
+
"try_workflow",
|
606
|
+
],
|
607
|
+
}
|