vellum-ai 1.1.4__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vellum/client/core/client_wrapper.py +2 -2
- vellum/workflows/emitters/vellum_emitter.py +5 -0
- vellum/workflows/sandbox.py +22 -5
- vellum/workflows/state/context.py +8 -52
- vellum/workflows/workflows/base.py +1 -1
- {vellum_ai-1.1.4.dist-info → vellum_ai-1.2.0.dist-info}/METADATA +1 -1
- {vellum_ai-1.1.4.dist-info → vellum_ai-1.2.0.dist-info}/RECORD +32 -32
- vellum_ee/workflows/display/nodes/base_node_display.py +5 -5
- vellum_ee/workflows/display/nodes/tests/test_base_node_display.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/inline_prompt_node.py +4 -0
- vellum_ee/workflows/display/nodes/vellum/retry_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_retry_node.py +1 -1
- vellum_ee/workflows/display/nodes/vellum/tests/test_tool_calling_node.py +75 -1
- vellum_ee/workflows/display/nodes/vellum/try_node.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_adornments_serialization.py +9 -9
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_attributes_serialization.py +59 -9
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_outputs_serialization.py +3 -3
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_ports_serialization.py +14 -15
- vellum_ee/workflows/display/tests/workflow_serialization/generic_nodes/test_trigger_serialization.py +58 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_code_execution_node_serialization.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_prompt_node_serialization.py +4 -0
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_inline_subworkflow_serialization.py +1 -1
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_inline_workflow_serialization.py +6 -3
- vellum_ee/workflows/display/tests/workflow_serialization/test_basic_tool_calling_node_serialization.py +5 -2
- vellum_ee/workflows/display/types.py +13 -2
- vellum_ee/workflows/display/utils/expressions.py +5 -1
- vellum_ee/workflows/display/workflows/base_workflow_display.py +35 -0
- vellum_ee/workflows/display/workflows/tests/test_workflow_display.py +44 -2
- vellum_ee/workflows/tests/test_serialize_module.py +31 -0
- {vellum_ai-1.1.4.dist-info → vellum_ai-1.2.0.dist-info}/LICENSE +0 -0
- {vellum_ai-1.1.4.dist-info → vellum_ai-1.2.0.dist-info}/WHEEL +0 -0
- {vellum_ai-1.1.4.dist-info → vellum_ai-1.2.0.dist-info}/entry_points.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
import pytest
|
2
|
-
from uuid import uuid4
|
3
|
-
from typing import Optional
|
2
|
+
from uuid import UUID, uuid4
|
3
|
+
from typing import Any, Optional
|
4
4
|
|
5
5
|
from vellum.workflows.inputs import BaseInputs
|
6
6
|
from vellum.workflows.nodes.bases.base import BaseNode
|
@@ -11,11 +11,13 @@ from vellum.workflows.nodes.core.try_node.node import TryNode
|
|
11
11
|
from vellum.workflows.nodes.displayable.final_output_node.node import FinalOutputNode
|
12
12
|
from vellum.workflows.references.lazy import LazyReference
|
13
13
|
from vellum.workflows.state.base import BaseState
|
14
|
+
from vellum.workflows.types.core import JsonObject
|
14
15
|
from vellum.workflows.workflows.base import BaseWorkflow
|
15
16
|
from vellum_ee.workflows.display.editor.types import NodeDisplayData, NodeDisplayPosition
|
16
17
|
from vellum_ee.workflows.display.nodes import BaseNodeDisplay
|
17
18
|
from vellum_ee.workflows.display.nodes.vellum.retry_node import BaseRetryNodeDisplay
|
18
19
|
from vellum_ee.workflows.display.nodes.vellum.try_node import BaseTryNodeDisplay
|
20
|
+
from vellum_ee.workflows.display.types import WorkflowDisplayContext
|
19
21
|
from vellum_ee.workflows.display.workflows.get_vellum_workflow_display_class import get_workflow_display
|
20
22
|
|
21
23
|
|
@@ -955,3 +957,43 @@ def test_serialize_workflow__state_variables():
|
|
955
957
|
"required": False,
|
956
958
|
"extensions": {"color": None},
|
957
959
|
}
|
960
|
+
|
961
|
+
|
962
|
+
def test_serialize_workflow__with_complete_node_failure_prunes_edges():
|
963
|
+
"""Test that edges are pruned when a node completely fails to serialize (serialized_node is null)."""
|
964
|
+
|
965
|
+
# GIVEN a node that completely fails to serialize
|
966
|
+
class FailingNode(BaseNode):
|
967
|
+
class Outputs(BaseNode.Outputs):
|
968
|
+
result: str
|
969
|
+
|
970
|
+
class FailingNodeDisplay(BaseNodeDisplay[FailingNode]):
|
971
|
+
def serialize(
|
972
|
+
self, display_context: WorkflowDisplayContext, error_output_id: Optional[UUID] = None, **kwargs: Any
|
973
|
+
) -> JsonObject:
|
974
|
+
raise NotImplementedError("Complete node serialization failure")
|
975
|
+
|
976
|
+
# AND a workflow with the failing node connected to another node
|
977
|
+
class WorkingNode(BaseNode):
|
978
|
+
class Outputs(BaseNode.Outputs):
|
979
|
+
value: str
|
980
|
+
|
981
|
+
class Workflow(BaseWorkflow):
|
982
|
+
graph = FailingNode >> WorkingNode
|
983
|
+
|
984
|
+
# WHEN we serialize the workflow with dry_run=True
|
985
|
+
workflow_display = get_workflow_display(workflow_class=Workflow, dry_run=True)
|
986
|
+
|
987
|
+
# AND we register the failing display class
|
988
|
+
workflow_display.display_context.node_displays[FailingNode] = FailingNodeDisplay()
|
989
|
+
|
990
|
+
data: dict = workflow_display.serialize()
|
991
|
+
|
992
|
+
# THEN the workflow should serialize but with no edges (pruned due to invalid node)
|
993
|
+
assert data["workflow_raw_data"]["edges"] == []
|
994
|
+
|
995
|
+
# AND only the working node and entrypoint should be in the serialized nodes
|
996
|
+
assert len(data["workflow_raw_data"]["nodes"]) == 2
|
997
|
+
node_types = [node["type"] for node in data["workflow_raw_data"]["nodes"]]
|
998
|
+
assert "ENTRYPOINT" in node_types
|
999
|
+
assert "GENERIC" in node_types # This is the WorkingNode that should still be serialized
|
@@ -1,6 +1,37 @@
|
|
1
1
|
from vellum_ee.workflows.display.workflows.base_workflow_display import BaseWorkflowDisplay
|
2
2
|
|
3
3
|
|
4
|
+
def test_serialize_module_with_dataset():
|
5
|
+
"""Test that serialize_module correctly serializes dataset from sandbox modules."""
|
6
|
+
module_path = "tests.workflows.basic_inputs_and_outputs"
|
7
|
+
|
8
|
+
result = BaseWorkflowDisplay.serialize_module(module_path)
|
9
|
+
|
10
|
+
assert hasattr(result, "dataset")
|
11
|
+
|
12
|
+
assert result.dataset is None
|
13
|
+
|
14
|
+
|
15
|
+
def test_serialize_module_with_actual_dataset():
|
16
|
+
"""Test that serialize_module correctly serializes dataset when sandbox has dataset attribute."""
|
17
|
+
module_path = "tests.workflows.test_dataset_serialization"
|
18
|
+
|
19
|
+
result = BaseWorkflowDisplay.serialize_module(module_path)
|
20
|
+
|
21
|
+
assert hasattr(result, "dataset")
|
22
|
+
|
23
|
+
assert result.dataset is not None
|
24
|
+
assert isinstance(result.dataset, list)
|
25
|
+
assert len(result.dataset) == 2
|
26
|
+
|
27
|
+
for i, item in enumerate(result.dataset):
|
28
|
+
assert "label" in item
|
29
|
+
assert "inputs" in item
|
30
|
+
assert item["label"] == f"Scenario {i + 1}"
|
31
|
+
assert isinstance(item["inputs"], dict)
|
32
|
+
assert "message" in item["inputs"]
|
33
|
+
|
34
|
+
|
4
35
|
def test_serialize_module_happy_path():
|
5
36
|
"""Test that serialize_module works with a valid module path."""
|
6
37
|
module_path = "tests.workflows.trivial"
|
File without changes
|
File without changes
|
File without changes
|