-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: passthrough extra args for adk deploy cloud_run
as Cloud Run args
#2544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jackwotherspoon
wants to merge
10
commits into
google:main
Choose a base branch
from
jackwotherspoon:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+97
−22
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b74e585
first pass
jackwotherspoon 56b253f
chore: update test
jackwotherspoon 2d1b561
Merge branch 'main' into main
hangfei 52072c5
chore: update test to ignore ctx
jackwotherspoon 069e533
Merge branch 'main' into main
jackwotherspoon 51d7441
chore: lint
jackwotherspoon a254958
Merge branch 'main' into main
jackwotherspoon 7b8422e
Merge branch 'main' into main
jackwotherspoon f9a09f4
Merge branch 'main' into main
jackwotherspoon 1eb19c0
Merge branch 'main' into main
hangfei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,49 @@ def _boom(*_a: Any, **_k: Any) -> None: # noqa: D401 | |
assert "Deploy failed: boom" in result.output | ||
|
||
|
||
def test_cli_deploy_cloud_run_passthrough_args( | ||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch | ||
) -> None: | ||
"""Extra args should be passed through to the gcloud command.""" | ||
rec = _Recorder() | ||
monkeypatch.setattr(cli_tools_click.cli_deploy, "to_cloud_run", rec) | ||
|
||
agent_dir = tmp_path / "agent_passthrough" | ||
agent_dir.mkdir() | ||
runner = CliRunner() | ||
result = runner.invoke( | ||
cli_tools_click.main, | ||
[ | ||
"deploy", | ||
"cloud_run", | ||
"--project", | ||
"test-project", | ||
"--region", | ||
"us-central1", | ||
str(agent_dir), | ||
"--labels=test-label=test", | ||
"--memory=1Gi", | ||
"--cpu=1", | ||
], | ||
) | ||
# Print debug information if the test fails | ||
if result.exit_code != 0: | ||
print(f"Exit code: {result.exit_code}") | ||
print(f"Output: {result.output}") | ||
print(f"Exception: {result.exception}") | ||
|
||
assert result.exit_code == 0 | ||
assert rec.calls, "cli_deploy.to_cloud_run must be invoked" | ||
|
||
# Check that extra_gcloud_args were passed correctly | ||
called_kwargs = rec.calls[0][1] | ||
extra_args = called_kwargs.get("extra_gcloud_args") | ||
assert extra_args is not None | ||
assert "--labels=test-label=test" in extra_args | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is adk-labels? could you assert that? |
||
assert "--memory=1Gi" in extra_args | ||
assert "--cpu=1" in extra_args | ||
|
||
|
||
# cli deploy agent_engine | ||
def test_cli_deploy_agent_engine_success( | ||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make it harder to maintain long-term.
I'd recommend adding a
--gcloud_extra_arg
option (with--multiple=True
) to host.Usage pattern could be
--gcloud_extra_arg="--args1=val1" --gcloud_extra_arg="--args2=val2"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jacksunwei can you explain why this makes it harder to maintain...?
Seems way easier to maintain than the current approach of adding supported flags one by one.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a DevX perspective I find this much worse than my current approach (in my opinion), you are asking folks to learn something new and have to do extra work to convert...
Versus telling folks to "take any of your existing Cloud Run deployments and copy your flags and just append them to your command".
The second option feels a bit more magical and it "just works"
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes things confusing. From user's perspective, when they do
adk deploy cloud_run --arg1 val1 --arg2 val2
.There is no easy way to tell whether
arg1
is foradk deploy cloud_run
or for the underlyinggcloud
command.User cannot have help text from
adk deploy cloud_run --help
, either.It appears to be doing less things, but it will just confuse people and shut our door to provide any additional options in the future, because if gcloud also has an option of the same name, we may accidentally break users' existing setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jacksunwei I think you may be mis-understanding...
Anything after
AGENT_PATH
is considered a gcloud arg, everything before is ADK flag...Yes there is, anything before
AGENT_PATH
is an ADK arg, if I try and add a gcloud flag beforeAGENT_PATH
it will error:Yes they can,
adk deploy cloud_run --help
, works fine. Only time it would potentially not work is--help
after theAGENT_PATH
.This is a fair point, but do we really see this being the case...? Is there a plan to add a bunch more flags to
adk deploy cloud_run
? The benefits here seem to be huge.