-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add rollback functionality to setup wizard #75
base: main
Are you sure you want to change the base?
Conversation
Fixes AgentOps-AI#9 Add error handling and rollback functionality to the setup wizard. * Add `rollback_actions` function in `agentstack/cli/cli.py` to undo actions like directory creation and file writing. * Update `init_project_builder` in `agentstack/cli/cli.py` to catch exceptions and call `rollback_actions`. * Track created files and directories in `insert_template` for potential rollback in `agentstack/cli/cli.py`. * Add `rollback_actions` function in `agentstack/generation/agent_generation.py` and `agentstack/generation/task_generation.py` to undo actions. * Update `generate_agent` in `agentstack/generation/agent_generation.py` and `generate_task` in `agentstack/generation/task_generation.py` to catch exceptions and call `rollback_actions`. * Add tests in `tests/test_cli_loads.py` to verify rollback functionality. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/AgentOps-AI/AgentStack/issues/9?shareId=XXXX-XXXX-XXXX-XXXX).
@@ -20,86 +20,100 @@ | |||
from .. import generation | |||
from ..utils import open_json_file, term_color, is_snake_case | |||
|
|||
created_files = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These variables should be created inside the function scope, not at the module level.
os.remove(file) | ||
for dir in created_dirs: | ||
if os.path.exists(dir): | ||
shutil.rmtree(dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be very careful about deleting files when any exception occurs. Possible that running this command on an already initialized project would permanently erase user data.
Thanks for taking the time to submit this PR! I like the sentiment here, but we need to be careful about the implementation. The module-level variable names and rollback functions have no indication of what feature they're specifically related to. Stylistically, indenting the entire method inside a Potential solution to this is to create a def init_project_builder(...):
def forward():
...
def backward():
...
try:
forward()
except:
backward() |
Fixes #9
Add error handling and rollback functionality to the setup wizard.
rollback_actions
function inagentstack/cli/cli.py
to undo actions like directory creation and file writing.init_project_builder
inagentstack/cli/cli.py
to catch exceptions and callrollback_actions
.insert_template
for potential rollback inagentstack/cli/cli.py
.rollback_actions
function inagentstack/generation/agent_generation.py
andagentstack/generation/task_generation.py
to undo actions.generate_agent
inagentstack/generation/agent_generation.py
andgenerate_task
inagentstack/generation/task_generation.py
to catch exceptions and callrollback_actions
.tests/test_cli_loads.py
to verify rollback functionality.For more details, open the Copilot Workspace session.