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

Update Score In Pull Request Number 4499 #384

Open
wants to merge 4 commits into
base: ci-test-60
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 63 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -119,17 +119,14 @@ jobs:

- name: Run pytest tests with coverage
run: |
pytest -n auto --cov=autogpt --cov-report term-missing --cov-branch --cov-report xml --cov-report term
pytest tests/integration/challenges/basic_abilities/test_write_file.py
python tests/integration/challenges/utils/build_current_score.py
env:
CI: true
PROXY: ${{ secrets.PROXY }}
AGENT_MODE: ${{ vars.AGENT_MODE }}
AGENT_TYPE: ${{ vars.AGENT_TYPE }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

- name: Update cassette submodule to push target if push event
if: ${{ github.event_name == 'push' }}
run: |
@@ -177,7 +174,7 @@ jobs:

# Check if there are any changes
if ! git diff-index --quiet HEAD; then
git commit -m "Auto-update cassettes after merging PR #$pr_number"
git commit -m "Auto-update cassettes after merging PR #${{ github.event.pull_request.number }}"
git push -f origin HEAD:refs/heads/$new_branch

else
@@ -193,10 +190,67 @@ jobs:
echo "DIFF_EXISTS=false" >> $GITHUB_ENV
fi

- name: Beat Challenges
if: ${{ env.DIFF_EXISTS == 'true' }}
run: |
pytest -n auto tests/integration/challenges/memory/test_memory_challenge_c.py tests/integration/challenges/basic_abilities/test_write_file.py --beat-challenges --cov=autogpt --cov-report term-missing --cov-branch --cov-report xml --cov-report term
python tests/integration/challenges/utils/build_current_score.py
env:
CI: true
PROXY: ${{ secrets.PROXY }}
AGENT_MODE: ${{ vars.AGENT_MODE }}
AGENT_TYPE: ${{ vars.AGENT_TYPE }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3

- name: Beat challenges - Update cassette submodule to submodule branch if PR event
if: ${{ env.DIFF_EXISTS == 'true' }}
run: |
new_branch="${{ github.event.pull_request.user.login }}-${{ github.event.pull_request.head.ref }}"

cd tests/Auto-GPT-test-cassettes
git config --global user.name "Auto-GPT-Bot"
git config --global user.email "github-bot@agpt.co"
git add .

# Check if there are any changes
if ! git diff-index --quiet HEAD; then
git commit -m "Auto-update cassettes after merging PR #${{ github.event.pull_request.number }} (Beat challenges)"
git push -f origin HEAD:refs/heads/$new_branch

else
echo "No changes to commit"
exit 0
fi

- name: Create Pull Request
if: ${{ env.DIFF_EXISTS == 'true' }}
run: |
current_date_time=$(date +'%Y%m%d%H%M%S')
new_branch="update-score-${{ github.event.pull_request.number }}-$current_date_time"

git config --global user.name "Auto-GPT-Bot"
git config --global user.email "github-bot@agpt.co"
git add tests/integration/challenges/current_score.json
if ! git diff-index --quiet HEAD; then
git commit -m "Update score"
git checkout -b $new_branch
git push origin $new_branch

echo ${{ secrets.PAT_REVIEW }} | gh auth login --with-token
gh pr create --title "Update Score In Pull Request Number ${{ github.event.pull_request.number }}" \
--head "$new_branch" \
--base "${{ github.event.pull_request.head.ref }}" \
--body "This pull request updates the current score of Auto-GPT. Please check the files changed and merge the pull request." \
--repo ${{ github.event.pull_request.head.repo.full_name }}
else
echo "The current score didn't change."
fi

- name: Apply or remove behaviour change label and comment
if: ${{ github.event_name == 'pull_request_target' }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
TOKEN=${{ secrets.PAT_REVIEW }}
REPO=${{ github.repository }}

@@ -205,15 +259,15 @@ jobs:
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels \
https://api.github.com/repos/$REPO/issues/${{ github.event.pull_request.number }}/labels \
-d '{"labels":["behaviour change"]}'

echo $TOKEN | gh auth login --with-token
gh api repos/$REPO/issues/$PR_NUMBER/comments -X POST -F body="You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged."
gh api repos/$REPO/issues/${{ github.event.pull_request.number }}/comments -X POST -F body="You changed AutoGPT's behaviour. The cassettes have been updated and will be merged to the submodule when this Pull Request gets merged."
else
echo "Removing label..."
curl -X DELETE \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO/issues/$PR_NUMBER/labels/behaviour%20change
https://api.github.com/repos/$REPO/issues/${{ github.event.pull_request.number }}/labels/behaviour%20change
fi
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "tests/Auto-GPT-test-cassettes"]
path = tests/Auto-GPT-test-cassettes
url = https://github.com/Significant-Gravitas/Auto-GPT-test-cassettes
branch = master
branch = ci-test-1
4 changes: 3 additions & 1 deletion autogpt/llm/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -96,7 +96,9 @@ def _wrapped(*args, **kwargs):
user_warned = True

except APIError as e:
if (e.http_status not in [502, 429]) or (attempt == num_attempts):
if (e.http_status not in [502, 429]) or (
attempt == num_attempts
):
raise

backoff = backoff_base ** (attempt + 2)
4 changes: 2 additions & 2 deletions tests/integration/agent_factory.py
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ def writer_agent(agent_test_config, memory_none: NoMemory, workspace: Workspace)
ai_role="an AI designed to use the write_to_file command to write 'Hello World' into a file named \"hello_world.txt\" and then use the task_complete command to complete the task.",
ai_goals=[
"Use the write_to_file command to write 'Hello World' into a file named \"hello_world.txt\".",
"Use the task_complete command to complete the task.",
"Use the task_complete command to complete the task!",
"Do not use any other commands.",
],
)
@@ -116,7 +116,7 @@ def memory_management_agent(agent_test_config, memory_json_file, workspace: Work

ai_config = AIConfig(
ai_name="Follow-Instructions-GPT",
ai_role="an AI designed to read the instructions_1.txt file using the read_file method and follow the instructions in the file.",
ai_role="an AI designed to read the instructions_1.txt file using the read_file method and follow the instructions in the file!",
ai_goals=[
"Use the command read_file to read the instructions_1.txt file",
"Follow the instructions in the instructions_1.txt file",
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from tests.integration.challenges.challenge_decorator.challenge_decorator import (
@@ -15,7 +16,7 @@
@challenge
def test_browse_website(
browser_agent: Agent,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
monkeypatch: pytest.MonkeyPatch,
level_to_run: int,
) -> None:
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file
@@ -17,7 +18,7 @@
@challenge
def test_write_file(
writer_agent: Agent,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
monkeypatch: pytest.MonkeyPatch,
config: Config,
level_to_run: int,
36 changes: 1 addition & 35 deletions tests/integration/challenges/current_score.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
{
"basic_abilities": {
"browse_website": {
"max_level": 1,
"max_level_beaten": 1
},
"write_file": {
"max_level": 1,
"max_level_beaten": 1
}
},
"debug_code": {
"debug_code_challenge_a": {
"max_level": 1,
"max_level_beaten": 1
}
},
"information_retrieval": {
"information_retrieval_challenge_a": {
"max_level": 3,
"max_level_beaten": 1
},
"information_retrieval_challenge_b": {
"max_level": 1,
"max_level_beaten": 1
}
},
"kubernetes": {
"kubernetes_template_challenge_a": {
"max_level": 1,
"max_level_beaten": null
}
},
"memory": {
"memory_challenge_a": {
"max_level": 3,
"max_level_beaten": 3
},
"memory_challenge_b": {
"max_level": 5,
"max_level_beaten": null
},
"memory_challenge_c": {
"max_level": 5,
"max_level": 1,
"max_level_beaten": 1
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.commands.file_operations import read_file
from autogpt.config import Config
@@ -19,7 +20,7 @@
def test_information_retrieval_challenge_a(
information_retrieval_agents: Agent,
monkeypatch: pytest.MonkeyPatch,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
config: Config,
level_to_run: int,
) -> None:
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib

import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file
@@ -20,7 +21,7 @@
def test_information_retrieval_challenge_b(
get_nobel_prize_agent: Agent,
monkeypatch: pytest.MonkeyPatch,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
level_to_run: int,
config: Config,
) -> None:
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import yaml
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file
@@ -21,6 +22,7 @@ def test_kubernetes_template_challenge_a(
monkeypatch: pytest.MonkeyPatch,
config: Config,
level_to_run: int,
patched_api_requestor: MockerFixture,
) -> None:
"""
Test the challenge_a function in a given agent by mocking user inputs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file, write_to_file
@@ -15,7 +16,7 @@
@challenge
def test_memory_challenge_a(
memory_management_agent: Agent,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
monkeypatch: pytest.MonkeyPatch,
config: Config,
level_to_run: int,
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file, write_to_file
@@ -17,7 +18,7 @@
@challenge
def test_memory_challenge_b(
memory_management_agent: Agent,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
monkeypatch: pytest.MonkeyPatch,
config: Config,
level_to_run: int,
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from pytest_mock import MockerFixture

from autogpt.agent import Agent
from autogpt.commands.file_operations import read_file, write_to_file
@@ -18,7 +19,7 @@
@challenge
def test_memory_challenge_c(
memory_management_agent: Agent,
patched_api_requestor: None,
patched_api_requestor: MockerFixture,
monkeypatch: pytest.MonkeyPatch,
config: Config,
level_to_run: int,
4 changes: 3 additions & 1 deletion tests/integration/memory/test_json_file_memory.py
Original file line number Diff line number Diff line change
@@ -80,7 +80,9 @@ def test_json_memory_get(config: Config, memory_item: MemoryItem, mock_get_embed

@pytest.mark.vcr
@requires_api_key("OPENAI_API_KEY")
def test_json_memory_get_relevant(config: Config, patched_api_requestor: None) -> None:
def test_json_memory_get_relevant(
config: Config, patched_api_requestor: MockerFixture
) -> None:
index = JSONFileMemory(config)
mem1 = MemoryItem.from_text_file("Sample text", "sample.txt")
mem2 = MemoryItem.from_text_file("Grocery list:\n- Pancake mix", "groceries.txt")