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

ref(classic): Do not 'rm -rf <unquoted variable>' when removing classic env #8417

Merged
merged 12 commits into from
Nov 18, 2024

Conversation

dagelf
Copy link
Contributor

@dagelf dagelf commented Oct 23, 2024

Updated "classic" forge to not accidentally delete my environment without warning. (Updated #8056)

Background

I just did the "tutorial" and thankfully I implemented this change before I did, because I would've been MOST unhappy if this happened:

[coenraad@r2t2 AutoGPT]$ ./run agent create test
🎉 New agent 'test' created. The code for your new agent is in: agents/test
[coenraad@r2t2 AutoGPT]$ ./run agent start test
⌛ Running setup for agent 'test'...
Path /home/coenraad/AutoGPT/agents/benchmark for agbenchmark does not exist
Press ENTER to remove /home/coenraad/.venv
^C

$ /usr/bin/du $(poetry env info --path) --max-depth=0 -h|sort -h
14G	/home/coenraad/.venv

My connectivity isn't that great, and this environment, being my development environment, has packages accumulated over months. This is not my reproducible production machine, it's my personal dev machine... maybe I shouldn't try out new projects outside of a sandbox.... but a lot of people do, and this can really bite them.

Changes 🏗️

Quoted the "$ENV_PATH". Also made sure the script fails, if the rm command fails.
Also added a double confirmation.
Also added a way to skip the confirmation: touch delete. We can add that to the docs or any CI, if confirmed safe.

This also closes #7404

PR Quality Scorecard ✨

  • Have you used the PR description template?   +2 pts
  • Is your pull request atomic, focusing on a single change?   +5 pts
  • Have you linked the GitHub issue(s) that this PR addresses?   +5 pts
  • Have you documented your changes clearly and comprehensively?   +5 pts
  • Have you changed or added a feature?   -4 pts
    • Have you added/updated corresponding documentation?   +4 pts
    • Have you added/updated corresponding integration tests?   +5 pts
  • Have you changed the behavior of AutoGPT?   -5 pts
    • Have you also run agbenchmark to verify that these changes do not regress performance?   +10 pts

I would be most unhappy if this was removed on my dev machine:

$ /usr/bin/du $(poetry env info --path) --max-depth=0 -h|sort -h
14G	/home/user/.venv
I would be MOST unhappy if this happened on my dev machine;

$ /usr/bin/du $(poetry env info --path) --max-depth=0 -h|sort -h
14G	/home/user/.venv
I would be most unhappy if this was deleted on my dev machine:

$ /usr/bin/du $(poetry env info --path) --max-depth=0 -h|sort -h
14G	/home/user/.venv

Also, not quoting a variable fed to "rm -rf" can lead to catastrophy.
Copy link

PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

7404 - Partially compliant

Fully compliant requirements:

  • Warn the user before removing the virtual environment
  • Ask for confirmation before deleting the venv

Not compliant requirements:

  • Explain why the venv is being removed or point users in the right direction
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Handling
The script uses rm -r instead of rm -rf for removing the environment, which might fail if there are read-only files. Consider using rm -rf for consistency with the original script.

User Experience
The script doesn't explain why the environment is being removed or provide guidance on recreating it. Consider adding a brief explanation or link to documentation.

Copy link

netlify bot commented Oct 23, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 257cbfc
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/673bc79c63b0fd000915196c

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (dev@8fccf2e). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff           @@
##             dev    #8417   +/-   ##
======================================
  Coverage       ?   58.16%           
======================================
  Files          ?      106           
  Lines          ?     5765           
  Branches       ?      720           
======================================
  Hits           ?     3353           
  Misses         ?     2306           
  Partials       ?      106           
Flag Coverage Δ
Linux 57.86% <ø> (?)
Windows 54.64% <ø> (?)
forge 58.03% <ø> (?)
macOS 57.03% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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


🚨 Try these New Features:

ntindle
ntindle previously approved these changes Oct 29, 2024
@ntindle
Copy link
Member

ntindle commented Oct 29, 2024

This is going to be challenging to merge as the CI for the classic is broken since moving it. #8338

@dagelf
Copy link
Contributor Author

dagelf commented Oct 30, 2024

If it's broken, merging this won't break it further ...... at least people following the instructions linked in the original issue won't be able to accidentally wipe their environments.

@dagelf
Copy link
Contributor Author

dagelf commented Oct 30, 2024

I will look at the CI if I get a chance though......

@ntindle ntindle changed the base branch from master to dev November 14, 2024 16:37
@ntindle ntindle dismissed their stale review November 14, 2024 16:37

The base branch was changed.

@ntindle
Copy link
Member

ntindle commented Nov 15, 2024

I went and fixed the ci, once its merged #8338, this can go in

@CLAassistant
Copy link

CLAassistant commented Nov 15, 2024

CLA assistant check
All committers have signed the CLA.

@ntindle ntindle changed the title Please do not 'rm -rf <unquoted variable> ref(classic): Do not 'rm -rf <unquoted variable>' Nov 15, 2024
@ntindle ntindle changed the title ref(classic): Do not 'rm -rf <unquoted variable>' ref(classic): Do not 'rm -rf <unquoted variable>' when removing classic env Nov 15, 2024
@ntindle
Copy link
Member

ntindle commented Nov 15, 2024

@dagelf I Got this fixed up, so we can merge it! I just need you to sign the CLA :)

@ntindle ntindle merged commit 865e3c0 into Significant-Gravitas:dev Nov 18, 2024
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

agent setup rm -rf <venv> ... should warn beforehand.
4 participants