Skip to content
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

fix(cli): allow dep update to honor public/private photon namespace. #382

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions leptonai/api/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def update_deployment(
conn: Connection,
name: str,
photon_id: Optional[str] = None,
photon_namespace: Optional[str] = None,
min_replicas: Optional[int] = None,
resource_shape: Optional[str] = None,
is_public: Optional[bool] = None,
Expand All @@ -112,6 +113,7 @@ def update_deployment(
"""
deployment_user_spec = types.DeploymentUserSpec(
photon_id=photon_id,
photon_namespace=photon_namespace,
resource_requirement=types.ResourceRequirement(
resource_shape=resource_shape,
min_replicas=min_replicas,
Expand Down
18 changes: 18 additions & 0 deletions leptonai/cli/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,15 @@ def log(name, replica):
" the deployment to have no timeout."
),
)
@click.option(
"--public-photon",
is_flag=True,
help=(
"If specified, get the photon from the public photon registry. If not"
" specified, we will inherit the namespace of the current deployment."
),
default=None,
)
def update(
name,
id,
Expand All @@ -364,6 +373,7 @@ def update(
tokens,
remove_tokens,
no_traffic_timeout,
public_photon,
):
"""
Updates a deployment. Note that for all the update options, changes are made
Expand Down Expand Up @@ -405,6 +415,13 @@ def update(
]
id = sorted(records, key=lambda x: x[3])[-1][2]
console.print(f"Updating to latest photon id [green]{id}[/].")
if public_photon is None:
dep_info = guard_api(
api.get_deployment(conn, name),
detail=True,
msg=f"Cannot obtain info for [red]{name}[/]. See error above.",
)
public_photon = dep_info.get("photon_namespace", "private") == "public"
if remove_tokens:
# [] means removing all tokens
tokens = []
Expand All @@ -416,6 +433,7 @@ def update(
conn,
name,
photon_id=id,
photon_namespace="public" if public_photon else "private",
min_replicas=min_replicas,
resource_shape=resource_shape,
is_public=public,
Expand Down
Loading