Skip to content

Commit

Permalink
feat: support parsing space for deletion (#3926)
Browse files Browse the repository at this point in the history
`bentoml models delete` and `bentoml delete` should now supported deleting objects with space

Fixes  #3418

Co-authored-by: omkarmozar <[email protected]>
Co-authored-by: Aaron Pham <[email protected]>
  • Loading branch information
3 people authored Jun 2, 2023
1 parent 03b9d7d commit e1f81d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/bentoml_cli/bentos.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def parse_delete_targets_argument_callback(
) -> list[str]:
if value is None:
return value
delete_targets = value.split(",")
value = " ".join(value)
if "," in value:
delete_targets = value.split(",")
else:
delete_targets = value.split()
delete_targets = list(map(str.strip, delete_targets))
for delete_target in delete_targets:
if not (
Expand Down Expand Up @@ -145,7 +149,7 @@ def list_bentos(bento_name: str, output: str) -> None: # type: ignore (not acce
@cli.command()
@click.argument(
"delete_targets",
type=click.STRING,
nargs=-1,
callback=parse_delete_targets_argument_callback,
required=True,
)
Expand All @@ -163,7 +167,8 @@ def delete(delete_targets: list[str], yes: bool) -> None: # type: ignore (not a
Examples:
* Delete single bento bundle by "name:version", e.g: `bentoml delete IrisClassifier:v1`
* Bulk delete all bento bundles with a specific name, e.g.: `bentoml delete IrisClassifier`
* Bulk delete multiple bento bundles by name and version, separated by ",", e.g.: `benotml delete Irisclassifier:v1,MyPredictService:v2`
* Bulk delete multiple bento bundles by name and version, separated by ",", e.g.: `bentoml delete Irisclassifier:v1,MyPredictService:v2`
* Bulk delete multiple bento bundles by name and version, separated by " ", e.g.: `bentoml delete Irisclassifier:v1 MyPredictService:v2`
* Bulk delete without confirmation, e.g.: `bentoml delete IrisClassifier --yes`
"""

Expand Down
11 changes: 8 additions & 3 deletions src/bentoml_cli/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def parse_delete_targets_argument_callback(
) -> t.Any:
if value is None:
return value
delete_targets = value.split(",")
value = " ".join(value)
if "," in value:
delete_targets = value.split(",")
else:
delete_targets = value.split()
delete_targets = list(map(str.strip, delete_targets))
for delete_target in delete_targets:
if not (
Expand Down Expand Up @@ -136,7 +140,7 @@ def list_models(model_name: str, output: str) -> None: # type: ignore (not acce
@model_cli.command()
@click.argument(
"delete_targets",
type=click.STRING,
nargs=-1,
callback=parse_delete_targets_argument_callback,
required=True,
)
Expand All @@ -154,7 +158,8 @@ def delete(delete_targets: str, yes: bool) -> None: # type: ignore (not accesse
Examples:
* Delete single model by "name:version", e.g: `bentoml models delete iris_clf:v1`
* Bulk delete all models with a specific name, e.g.: `bentoml models delete iris_clf`
* Bulk delete multiple models by name and version, separated by ",", e.g.: `benotml models delete iris_clf:v1,iris_clf:v2`
* Bulk delete multiple models by name and version, separated by ",", e.g.: `bentoml models delete iris_clf:v1,iris_clf:v2`
* Bulk delete multiple models by name and version, separated by " ", e.g.: `bentoml models delete iris_clf:v1 iris_clf:v2`
* Bulk delete without confirmation, e.g.: `bentoml models delete IrisClassifier --yes`
""" # noqa

Expand Down

0 comments on commit e1f81d0

Please sign in to comment.