Skip to content

delete-project subcommand - #9

Merged
ethanholz merged 14 commits into
omsf-eco-infra:mainfrom
dwhswenson:delete-project
Mar 17, 2026
Merged

ethanholz merged 14 commits into
omsf-eco-infra:mainfrom
dwhswenson:delete-project

Conversation

@dwhswenson

Copy link
Copy Markdown
Member

Subcommand to delete a project. Gives two verification opportunities: before you delete from the DynamoDB table, and before you delete the actual data (AMI+snapshot). Override with --force.

This also standardizes on raising errors/returning structured data in the manager class; previously some methods returned tuples of success_bool, message. It also adds a few helper methods to the manager class; as we move the lambda logic into the package, we might refactor them to reuse these.

@codecov

codecov Bot commented Feb 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.73%. Comparing base (d252cd5) to head (cc4f905).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
+ Coverage   99.70%   99.73%   +0.03%     
==========================================
  Files          13       13              
  Lines        2405     2690     +285     
==========================================
+ Hits         2398     2683     +285     
  Misses          7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

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.

Pull request overview

This PR adds a new delete-project subcommand to the DevBox CLI and refactors the terminate_instance method to use structured return values and exceptions instead of tuple-based success/failure indicators.

Changes:

  • Adds delete-project command with two-stage confirmation (database entry deletion, then AMI/snapshot cleanup) and --force flag to skip confirmations
  • Refactors error handling pattern from returning (bool, str) tuples to raising exceptions and returning structured dictionaries
  • Adds four new helper methods to DevBoxManager: get_project_item, project_in_use, delete_project_entry, and delete_ami_and_snapshots

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
src/devbox/devbox_manager.py Adds helper methods for project deletion and refactors terminate_instance to raise exceptions instead of returning status tuples
src/devbox/cli.py Implements delete-project command with two-stage confirmation and updates terminate command to handle new return format
tests/test_devbox_manager.py Updates terminate_instance tests to expect exceptions and adds basic tests for new helper methods
tests/test_cli.py Updates terminate tests and adds comprehensive test suite for delete-project command covering success and cancellation scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_devbox_manager.py
Comment on lines +323 to +329
except ClientError as e:
error_code = e.response.get('Error', {}).get('Code', 'UnknownError')
raise utils.AWSClientError(
f"Error deleting AMI {ami_id}: {error_code} - {str(e)}",
error_code=error_code,
original_exception=e
)

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

The error message "Error deleting AMI" at line 326 is misleading when the error occurs during the describe_images call (line 293) before any deletion has occurred. Consider separating the error handling or making the error message more generic, such as "Error processing AMI deletion" or handling describe_images errors separately with a message like "Error retrieving AMI information".

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The additional error information, from the original error, should be sufficient to clarify.

Comment thread tests/test_cli.py
Comment thread src/devbox/devbox_manager.py Outdated
Comment thread src/devbox/cli.py Outdated
Comment thread tests/test_devbox_manager.py
Comment thread tests/test_devbox_manager.py
Also updated some old stuff to use unittest.mock.patch instead of
manually patching.

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_devbox_manager.py
Comment thread tests/test_cli.py
Comment thread tests/test_devbox_manager.py Outdated
@dwhswenson
dwhswenson requested a review from ethanholz March 17, 2026 15:51

@ethanholz ethanholz left a comment

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.

Fix the doc comments for the stuff in this PR. Would like a followup PR updating the existing docstrings to numpy docstrings.

Comment on lines +227 to +235
"""Check whether a project is currently in use.

Args:
project: Project name
item: Optional project item from DynamoDB

Returns:
Tuple of (in_use, reason)
"""

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.

We aren't using numpy docstrings here. Upon further review, neither is the rest of the repo. Please update.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do in follow-up PR

ami_id: AMI ID to delete

Returns:
Dict with AMI cleanup details

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.

Might be worth adding what this can potentially throw in the doc comments

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in cc4f905

Comment thread pixi.lock

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.

Why did this update?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The PR was in progress when you added the lockfile to the repo, and I think there was a conflict early on. It has been a headache ever since; every pull is a conflict. This latest version is just from deleting the conflicting file, and regenerating it with pixi install --all

@dwhswenson dwhswenson left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updates / responses made! Ready for another round, @ethanholz

Comment on lines +227 to +235
"""Check whether a project is currently in use.

Args:
project: Project name
item: Optional project item from DynamoDB

Returns:
Tuple of (in_use, reason)
"""

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do in follow-up PR

ami_id: AMI ID to delete

Returns:
Dict with AMI cleanup details

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in cc4f905

Comment thread pixi.lock

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The PR was in progress when you added the lockfile to the repo, and I think there was a conflict early on. It has been a headache ever since; every pull is a conflict. This latest version is just from deleting the conflicting file, and regenerating it with pixi install --all

@dwhswenson
dwhswenson requested a review from ethanholz March 17, 2026 18:15
@ethanholz
ethanholz merged commit bbeadcd into omsf-eco-infra:main Mar 17, 2026
5 checks passed
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