Skip to content

Commit 2561167

Browse files
Add --release-tag option to pull CLI command (#3343)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
1 parent 492051a commit 2561167

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

ee/vellum_cli/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,19 @@ def get_command(self, ctx, cmd_name):
208208
help="""Directory to pull the workflow into. If not specified, \
209209
the workflow will be pulled into the current working directory.""",
210210
)
211+
@click.option(
212+
"--release-tag",
213+
type=str,
214+
help="""Release tag to use when pulling from a deployment.""",
215+
)
211216
def pull(
212217
ctx: click.Context,
213218
include_json: Optional[bool],
214219
exclude_code: Optional[bool],
215220
strict: Optional[bool],
216221
include_sandbox: Optional[bool],
217222
target_directory: Optional[str],
223+
release_tag: Optional[str],
218224
) -> None:
219225
"""Pull Resources from Vellum"""
220226

@@ -225,6 +231,7 @@ def pull(
225231
strict=strict,
226232
include_sandbox=include_sandbox,
227233
target_directory=target_directory,
234+
release_tag=release_tag,
228235
)
229236

230237

@@ -271,6 +278,11 @@ def pull(
271278
type=str,
272279
help="The specific Workspace config to use when pulling",
273280
)
281+
@click.option(
282+
"--release-tag",
283+
type=str,
284+
help="""Release tag to use when pulling from a deployment.""",
285+
)
274286
def workflows_pull(
275287
module: Optional[str],
276288
include_json: Optional[bool],
@@ -281,6 +293,7 @@ def workflows_pull(
281293
include_sandbox: Optional[bool],
282294
target_directory: Optional[str],
283295
workspace: Optional[str],
296+
release_tag: Optional[str],
284297
) -> None:
285298
"""
286299
Pull Workflows from Vellum. If a module is provided, only the Workflow for that module will be pulled.
@@ -297,6 +310,7 @@ def workflows_pull(
297310
include_sandbox=include_sandbox,
298311
target_directory=target_directory,
299312
workspace=workspace,
313+
release_tag=release_tag,
300314
)
301315

302316

@@ -332,13 +346,19 @@ def workflows_pull(
332346
help="""Directory to pull the workflow into. If not specified, \
333347
the workflow will be pulled into the current working directory.""",
334348
)
349+
@click.option(
350+
"--release-tag",
351+
type=str,
352+
help="""Release tag to use when pulling from a deployment.""",
353+
)
335354
def pull_module(
336355
ctx: click.Context,
337356
include_json: Optional[bool],
338357
exclude_code: Optional[bool],
339358
strict: Optional[bool],
340359
include_sandbox: Optional[bool],
341360
target_directory: Optional[str],
361+
release_tag: Optional[str],
342362
) -> None:
343363
"""Pull a specific module from Vellum"""
344364

@@ -350,6 +370,7 @@ def pull_module(
350370
strict=strict,
351371
include_sandbox=include_sandbox,
352372
target_directory=target_directory,
373+
release_tag=release_tag,
353374
)
354375

355376

ee/vellum_cli/pull.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def pull_command(
145145
include_sandbox: Optional[bool] = None,
146146
target_directory: Optional[str] = None,
147147
workspace: Optional[str] = None,
148+
release_tag: Optional[str] = None,
148149
) -> None:
149150
load_dotenv(dotenv_path=os.path.join(os.getcwd(), ".env"))
150151
logger = load_cli_logger()
@@ -198,6 +199,7 @@ def pull_command(
198199

199200
response = client.workflows.pull(
200201
pk,
202+
release_tag=release_tag,
201203
request_options={"additional_query_parameters": query_parameters},
202204
)
203205

ee/vellum_cli/tests/test_pull.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,3 +1337,33 @@ def test_pull__workspace_option__uses_different_api_key(mock_module, vellum_clie
13371337
assert os.path.exists(workflow_py)
13381338
with open(workflow_py) as f:
13391339
assert f.read() == "print('hello')"
1340+
1341+
1342+
@pytest.mark.parametrize(
1343+
"base_command",
1344+
[
1345+
["pull"],
1346+
["workflows", "pull"],
1347+
],
1348+
ids=["pull", "workflows_pull"],
1349+
)
1350+
def test_pull__release_tag(vellum_client, mock_module, base_command):
1351+
"""Tests that the --release-tag option is passed to the API."""
1352+
1353+
# GIVEN a module on the user's filesystem
1354+
module = mock_module.module
1355+
1356+
# AND the workflow pull API call returns a zip file
1357+
vellum_client.workflows.pull.return_value = iter([zip_file_map({"workflow.py": "print('hello')"})])
1358+
1359+
# WHEN the user runs the pull command with --release-tag
1360+
runner = CliRunner()
1361+
result = runner.invoke(cli_main, base_command + [module, "--release-tag", "my-release-tag"])
1362+
1363+
# THEN the command returns successfully
1364+
assert result.exit_code == 0
1365+
1366+
# AND the pull api is called with release_tag="my-release-tag"
1367+
vellum_client.workflows.pull.assert_called_once()
1368+
call_args = vellum_client.workflows.pull.call_args.kwargs
1369+
assert call_args["release_tag"] == "my-release-tag"

0 commit comments

Comments
 (0)