Skip to content

CLI command for quickly deleting local development instances#572

Merged
dkolas merged 5 commits into
mainfrom
clean-development-instances
Oct 6, 2023
Merged

CLI command for quickly deleting local development instances#572
dkolas merged 5 commits into
mainfrom
clean-development-instances

Conversation

@dkolas
Copy link
Copy Markdown
Contributor

@dkolas dkolas commented Oct 4, 2023

Per discussion on discord: https://discord.com/channels/927675537390968882/927675537390968885/1159144491450630224

Create a command clean local which iterates through local development instances of the current package, across workspaces, and asks the user if they wish to delete. Using the --all flag deletes them without prompt.

$ ship clean local
Steamship Python CLI version 2.17.31.post1.dev0+g47b0eb17.d20231004
Deleting LOCAL DEVELOPMENT instances of package [my-test-package] across workspaces.
Delete instance [urbane-firefly-rjlch] in workspace [teal-moon-yyeue] created 2023-10-04 20:14:26+00:00 [y/N]: y
Deleted instance [urbane-firefly-rjlch] in workspace [teal-moon-yyeue]
Delete instance [light-shelter-gdgph] in workspace [default] created 2023-10-04 17:42:38+00:00 [y/N]:
ship clean local --all
Steamship Python CLI version 2.17.31.post1.dev0+g47b0eb17.d20231004
Deleting LOCAL DEVELOPMENT instances of package [my-test-package] across workspaces.
Deleted instance [light-shelter-gdgph] in workspace [default]

@dkolas dkolas requested review from GitOnUp and douglas-reid October 4, 2023 20:40
@douglas-reid
Copy link
Copy Markdown
Contributor

this makes me wonder if we should have ship local [run|clean|...], as I kinda wanted this command to be ship clean local when reading your description.

Comment thread src/steamship/cli/cli.py Outdated
):
workspace = Workspace.get(client, instance.workspace_id)
result = all or click.confirm(
f"Delete instance [{instance.handle}] in workspace [{workspace.handle}] created {instance.created_at}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Add ? to confirmation prompt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread src/steamship/cli/cli.py Outdated
f"Delete instance [{instance.handle}] in workspace [{workspace.handle}] created {instance.created_at}"
)
if result:
instance.delete()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/except here, to allow deletion to continue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it continue, if it can't delete something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strikes me as a "I want to clean up as much as possible" thing, I'd personally be annoyed if this failed for some reason on the first one and I had 20 other files that needed deleting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread src/steamship/cli/cli.py Outdated
default=False,
help="Delete all local development instances without prompting",
)
def delete_local_dev_instances(all: Optional[bool] = False):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: naming differences between "delete" here vs "clean" in argument name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

workspace_id: str = None
workspace_handle: str = None
init_status: Optional[InvocableInitStatus] = None
created_at: Optional[datetime] = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For instances created before this change, is this just expected to be None? I don't see where this hydration happens otherwise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When hydrating in from_dict, Pydantic will ignore fields that it doesn't have a slot for. The createdAt field has been passed by the engine, but ignored by Pydantic / this object until this field is added.

@dkolas
Copy link
Copy Markdown
Contributor Author

dkolas commented Oct 5, 2023

this makes me wonder if we should have ship local [run|clean|...], as I kinda wanted this command to be ship clean local when reading your description.

Yeah I struggled a bit with what the name ought to be here. The other command is ship run [local|remote] though, so I wasn't quite sure how to fit clean into that scheme.

@douglas-reid
Copy link
Copy Markdown
Contributor

this makes me wonder if we should have ship local [run|clean|...], as I kinda wanted this command to be ship clean local when reading your description.

Yeah I struggled a bit with what the name ought to be here. The other command is ship run [local|remote] though, so I wasn't quite sure how to fit clean into that scheme.

should we make it parallel: ship clean local ? if we ever add a "killall" type of thing, that could be ship clean remote ?

@dkolas
Copy link
Copy Markdown
Contributor Author

dkolas commented Oct 6, 2023

this makes me wonder if we should have ship local [run|clean|...], as I kinda wanted this command to be ship clean local when reading your description.

Yeah I struggled a bit with what the name ought to be here. The other command is ship run [local|remote] though, so I wasn't quite sure how to fit clean into that scheme.

should we make it parallel: ship clean local ? if we ever add a "killall" type of thing, that could be ship clean remote ?

I like this. PR updated.

@dkolas dkolas added this pull request to the merge queue Oct 6, 2023
Merged via the queue into main with commit 436f6fb Oct 6, 2023
@dkolas dkolas deleted the clean-development-instances branch October 6, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants