Skip to content

Commit

Permalink
added new config param and results file
Browse files Browse the repository at this point in the history
  • Loading branch information
islem-esi committed Dec 13, 2024
1 parent 08f12c3 commit a9e4dc2
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 13 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,35 @@ Run ExecutionAgent with the batch file:
```
ExecutionAgent will process each project listed in the file, performing the same steps as the single repository mode. The `-l` option can also be applied here by adding it to the command when running the script.

To show the results of the last experiment for a specific project, you can call:
```sh
#
python3.10 show_results.py <project_name>
# example python3.10 show_results.py pytest
```

To clean all the logs and unset the api token, you can use the following command (WARNING: ALL THE LOGS AND EXECUTION RESULTS WOULD BE DELETED)
```sh
./clean.sh
```

---

## 🔧 Configuration

**More options on configuring the agent would be coming soon**

### Control the Number of Iterations:
By default, the number of attempts `ExecutionAgent` will make is 3. After each attempt, `ExecutionAgent` learns from the previous one and adjust its strategy.
In each attempt, the agent executes a number of commands (or cycles) defined by the parameter `l` mentioned above (default = 40).

To set the number of attempts, you need to change line 17 (local max_retries=2) to any number you want (the total number of attempts would be max_retries +1).

### Keep or Delete a docker container
You can set this option in the file `customize.json`. Default value is `"FALSE"` (containers would be deleted). The other option is `"True"` which keeps the containers.

This options useful for the ones who want to reuse the container already built by the agent.

---

## 📊 Results Summary
Expand Down
3 changes: 2 additions & 1 deletion autogpt/agents/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def __init__(
self.project_url = self.hyperparams["project_url"]
self.language = self.hyperparams["language"]
self.workspace_path = "execution_agent_workspace"

self.keep_container = True if self.hyperparams["keep_container"] == "TRUE" else False

self.current_step = "1"
self.steps_list = ["1", "2", "3", "4", "5", "6", "7"]

Expand Down
5 changes: 3 additions & 2 deletions autogpt/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ def graceful_agent_interrupt(signum: int, frame: Optional[FrameType]) -> None:
# Get user input #
##################
if cycles_remaining == 1: # Last cycle
stop_and_remove(agent.container)
os.system("docker system prune -f")
if not agent.keep_container:
stop_and_remove(agent.container)
os.system("docker system prune -af")
exit()
user_feedback, user_input, new_cycles_remaining = get_user_feedback(
config,
Expand Down
7 changes: 4 additions & 3 deletions autogpt/commands/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ def task_complete(reason: str, agent: Agent) -> NoReturn:
#Average coverage: [PUT CONCRETE VALUE HERE]
# """
logger.info(title="Shutting down...\n", message=reason)
stop_and_remove(agent.container)
os.system("docker system prune -f")
with open(os.path.join("experimental_setups", agent.exp_number, "saved_contexts", "SUCCESS"), "w") as ssf:
if not agent.keep_container:
stop_and_remove(agent.container)
os.system("docker system prune -af")
with open(os.path.join("experimental_setups", agent.exp_number, "saved_contexts", project_path, "SUCCESS"), "w") as ssf:
ssf.write("SUCCESS")
quit()
3 changes: 2 additions & 1 deletion clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ rm -rf logs/*
rm -rf execution_agent_workspace/*
touch execution_agent_workspace/readme
python3.10 remove_api_token.py
rm model_logging_temp.txt
rm model_logging_temp.txt
echo "" > experimental_setups/experiments_list.txt
5 changes: 4 additions & 1 deletion clone_and_set_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def clone_repository(github_url, project_name):

def create_metadata_file(project_name, github_url, language, image):
# Define metadata dictionary
with open("customize.json") as ctz:
customize = json.load(ctz)
metadata = {
"repetition_handling": "RESTRICT",
"project_path": project_name,
Expand All @@ -27,7 +29,8 @@ def create_metadata_file(project_name, github_url, language, image):
"name": "NO-TRACK"
},
"language": language,
"image": image
"image": image,
"keep_container": customize["KEEP_CONTAINER"]
}

# Define metadata file path
Expand Down
3 changes: 2 additions & 1 deletion customize.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"WEB-SEARCH": "TRUE",
"WORKFLOWS-SEARCH": "TRUE",
"BUDGET": 40,
"REQUIRED_FILES": ["test_results.txt", "SETUP_AND_INSTALL.sh", "Dockerfile"]
"REQUIRED_FILES": ["test_results.txt", "SETUP_AND_INSTALL.sh", "Dockerfile"],
"KEEP_CONTAINER": "FALSE"
}
1 change: 1 addition & 0 deletions experimental_setups/experiments_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

14 changes: 10 additions & 4 deletions show_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def main():
dockerfile = get_highest_numbered_file(files_dir, "Dockerfile_")
if dockerfile:
dockerfile_path = os.path.join(files_dir, dockerfile)
print(f"Highest-numbered Dockerfile: {dockerfile_path}")
print("="*70)
print(f"Latest docker file Dockerfile: {dockerfile_path}")
print("="*70)
with open(dockerfile_path, 'r') as f:
print(f.read())
else:
Expand All @@ -49,7 +51,9 @@ def main():
setup_file = get_highest_numbered_file(files_dir, "SETUP_AND_INSTALL.sh_")
if setup_file:
setup_file_path = os.path.join(files_dir, setup_file)
print(f"Highest-numbered SETUP_AND_INSTALL.sh: {setup_file_path}")
print("="*70)
print(f"Latest installation script SETUP_AND_INSTALL.sh: {setup_file_path}")
print("="*70)
with open(setup_file_path, 'r') as f:
print(f.read())
else:
Expand All @@ -58,9 +62,11 @@ def main():
# Check for SUCCESS file in saved_contexts directory
success_file = f"experimental_setups/{last_line}/saved_contexts/{project_name}/SUCCESS"
if os.path.exists(success_file):
print("SUCCESS file found.")
print("="*70)
print("SUCCESS")
else:
print("SUCCESS file not found.")
print("="*70)
print("FAILED")

if __name__ == "__main__":
main()

0 comments on commit a9e4dc2

Please sign in to comment.