Skip to content

Commit af9af44

Browse files
committed
Missing CLI methods
1 parent d005dc3 commit af9af44

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

src/zenml/cli/stack.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,22 @@ def register_stack(
676676
type=str,
677677
required=False,
678678
)
679+
@click.option(
680+
"--secret",
681+
"secrets",
682+
help="Secrets to attach to the stack.",
683+
type=str,
684+
required=False,
685+
multiple=True,
686+
)
687+
@click.option(
688+
"--remove-secret",
689+
"remove_secrets",
690+
help="Secrets to remove from the stack.",
691+
type=str,
692+
required=False,
693+
multiple=True,
694+
)
679695
def update_stack(
680696
stack_name_or_id: Optional[str] = None,
681697
artifact_store: Optional[str] = None,
@@ -690,6 +706,8 @@ def update_stack(
690706
data_validator: Optional[str] = None,
691707
image_builder: Optional[str] = None,
692708
model_registry: Optional[str] = None,
709+
secrets: List[str] = [],
710+
remove_secrets: List[str] = [],
693711
) -> None:
694712
"""Update a stack.
695713
@@ -708,6 +726,8 @@ def update_stack(
708726
data_validator: Name of the new data validator for this stack.
709727
image_builder: Name of the new image builder for this stack.
710728
model_registry: Name of the new model registry for this stack.
729+
secrets: Secrets to attach to the stack.
730+
remove_secrets: Secrets to remove from the stack.
711731
"""
712732
client = Client()
713733

@@ -746,6 +766,8 @@ def update_stack(
746766
updated_stack = client.update_stack(
747767
name_id_or_prefix=stack_name_or_id,
748768
component_updates=updates,
769+
add_secrets=secrets,
770+
remove_secrets=remove_secrets,
749771
)
750772

751773
except (KeyError, IllegalOperationError) as err:

src/zenml/cli/stack_components.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ def generate_stack_component_register_command(
232232
required=False,
233233
type=str,
234234
)
235+
@click.option(
236+
"--secret",
237+
"secrets",
238+
help="Secrets to attach to the component.",
239+
type=str,
240+
required=False,
241+
multiple=True,
242+
)
235243
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
236244
def register_stack_component_command(
237245
name: str,
@@ -240,6 +248,7 @@ def register_stack_component_command(
240248
labels: Optional[List[str]] = None,
241249
connector: Optional[str] = None,
242250
resource_id: Optional[str] = None,
251+
secrets: List[str] = [],
243252
) -> None:
244253
"""Registers a stack component.
245254
@@ -250,6 +259,7 @@ def register_stack_component_command(
250259
labels: Labels to be associated with the component.
251260
connector: Name of the service connector to connect the component to.
252261
resource_id: The resource ID to use with the connector.
262+
secrets: Secrets to attach to the component.
253263
"""
254264
client = Client()
255265

@@ -277,6 +287,7 @@ def register_stack_component_command(
277287
component_type=component_type,
278288
configuration=parsed_args,
279289
labels=parsed_labels,
290+
secrets=secrets,
280291
)
281292

282293
cli_utils.declare(
@@ -323,18 +334,38 @@ def generate_stack_component_update_command(
323334
"-l key1=value1 -l key2=value2.",
324335
multiple=True,
325336
)
337+
@click.option(
338+
"--secret",
339+
"secrets",
340+
help="Secrets to attach to the component.",
341+
type=str,
342+
required=False,
343+
multiple=True,
344+
)
345+
@click.option(
346+
"--remove-secret",
347+
"remove_secrets",
348+
help="Secrets to remove from the component.",
349+
type=str,
350+
required=False,
351+
multiple=True,
352+
)
326353
@click.argument("args", nargs=-1, type=click.UNPROCESSED)
327354
def update_stack_component_command(
328355
name_id_or_prefix: Optional[str],
329356
args: List[str],
330357
labels: Optional[List[str]] = None,
358+
secrets: List[str] = [],
359+
remove_secrets: List[str] = [],
331360
) -> None:
332361
"""Updates a stack component.
333362
334363
Args:
335364
name_id_or_prefix: The name or id of the stack component to update.
336365
args: Additional arguments to pass to the update command.
337366
labels: Labels to be associated with the component.
367+
secrets: Secrets to attach to the component.
368+
remove_secrets: Secrets to remove from the component.
338369
"""
339370
client = Client()
340371

@@ -358,6 +389,8 @@ def update_stack_component_command(
358389
component_type=component_type,
359390
configuration=parsed_args,
360391
labels=parsed_labels,
392+
add_secrets=secrets,
393+
remove_secrets=remove_secrets,
361394
)
362395
except KeyError as err:
363396
cli_utils.error(str(err))

src/zenml/models/v2/core/component.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,6 @@ class ComponentUpdate(BaseUpdate):
151151
default=None,
152152
title="Environment variables to set when running on this component.",
153153
)
154-
secrets: Optional[List[UUID]] = Field(
155-
default=None,
156-
title="Secrets to set as environment variables when running on this "
157-
"component.",
158-
)
159154
connector_resource_id: Optional[str] = Field(
160155
description="The ID of a specific resource instance to "
161156
"gain access to through the connector",

src/zenml/models/v2/core/stack.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ class StackUpdate(BaseUpdate):
171171
default=None,
172172
title="Environment variables to set when running on this stack.",
173173
)
174-
secrets: Optional[List[UUID]] = Field(
175-
default=None,
176-
title="Secrets to set as environment variables when running on this "
177-
"stack.",
178-
)
179174
labels: Optional[Dict[str, Any]] = Field(
180175
default=None,
181176
title="The stack labels.",

0 commit comments

Comments
 (0)