Skip to content

Commit 5237f40

Browse files
Fix push command to include dataset parameter for scenarios (#3302)
* Fix push command to include dataset parameter for scenarios Co-Authored-By: [email protected] <[email protected]> * Add test for dataset parameter in push command 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 10b37b8 commit 5237f40

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

ee/vellum_cli/push.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ def push_command(
220220

221221
provided_id = workflow_config.workflow_sandbox_id or workflow_sandbox_id
222222

223+
dataset_serialized = json.dumps(serialization_result.dataset) if serialization_result.dataset else OMIT
224+
223225
try:
224226
response = client.workflows.push(
225227
exec_config=json.dumps(exec_config),
@@ -228,6 +230,7 @@ def push_command(
228230
# We should check with fern if we could auto-serialize typed object fields for us
229231
# https://app.shortcut.com/vellum/story/5568
230232
deployment_config=deployment_config_serialized, # type: ignore[arg-type]
233+
dataset=dataset_serialized, # type: ignore[arg-type]
231234
dry_run=dry_run,
232235
strict=strict,
233236
)

ee/vellum_cli/tests/test_push.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from vellum.utils.uuid import is_valid_uuid
1616
from vellum_cli import main as cli_main
1717
from vellum_ee.workflows.display.nodes.utils import to_kebab_case
18+
from vellum_ee.workflows.display.workflows.base_workflow_display import BaseWorkflowDisplay, WorkflowSerializationResult
1819

1920

2021
def _extract_tar_gz(tar_gz_bytes: bytes) -> dict[str, str]:
@@ -174,6 +175,61 @@ def test_push__happy_path(mock_module, vellum_client, base_command):
174175
assert extracted_files["workflow.py"] == workflow_py_file_content
175176

176177

178+
def test_push__forwards_dataset_to_client(mock_module, vellum_client, mocker):
179+
"""
180+
Tests that the push command forwards the serialized dataset (scenarios)
181+
to the API client when present.
182+
"""
183+
184+
# GIVEN a single workflow configured
185+
temp_dir = mock_module.temp_dir
186+
module = mock_module.module
187+
188+
# AND a workflow exists in the module successfully
189+
_ensure_workflow_py(temp_dir, module)
190+
191+
# AND serialize_module returns an exec_config and a dataset with a workflow_trigger_id
192+
fake_exec_config = {
193+
"workflow_raw_data": {
194+
"definition": {"name": "ExampleWorkflow"},
195+
}
196+
}
197+
fake_dataset = [
198+
{
199+
"label": "Scenario 1",
200+
"inputs": {},
201+
"workflow_trigger_id": "trigger-123",
202+
}
203+
]
204+
mocker.patch.object(
205+
BaseWorkflowDisplay,
206+
"serialize_module",
207+
return_value=WorkflowSerializationResult(
208+
exec_config=fake_exec_config,
209+
errors=[],
210+
dataset=fake_dataset,
211+
),
212+
)
213+
214+
# AND the push API call returns successfully
215+
vellum_client.workflows.push.return_value = WorkflowPushResponse(
216+
workflow_sandbox_id=str(uuid4()),
217+
)
218+
219+
# WHEN calling `vellum workflows push`
220+
runner = CliRunner()
221+
result = runner.invoke(cli_main, ["workflows", "push", module])
222+
223+
# THEN it should succeed
224+
assert result.exit_code == 0
225+
226+
# AND we should have called the push API with the dataset argument
227+
vellum_client.workflows.push.assert_called_once()
228+
call_args = vellum_client.workflows.push.call_args.kwargs
229+
assert "dataset" in call_args
230+
assert json.loads(call_args["dataset"]) == fake_dataset
231+
232+
177233
@pytest.mark.usefixtures("info_log_level")
178234
def test_push__verify_default_url_in_raw_httpx_transport(mock_module, mock_httpx_transport):
179235
# GIVEN a single workflow configured

0 commit comments

Comments
 (0)