Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

Quicker logs in pytest (#4486)

merwanehamadi3081f56ecb15
diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml
deleted file mode 100644
index 272fca17bd..0000000000
--- a/.github/workflows/benchmarks.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-name: Run Benchmarks
-
-on:
- workflow_dispatch:
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- env:
- python-version: '3.10'
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v3
-
- - name: Set up Python ${{ env.python-version }}
- uses: actions/setup-python@v4
- with:
- python-version: ${{ env.python-version }}
-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements.txt
-
- - name: benchmark
- env:
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- run: |
- python benchmark/benchmark_entrepreneur_gpt_with_undecisive_user.py
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cf851ef380..8e3d548449 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -156,6 +156,7 @@ jobs:
PROXY: ${{ secrets.PROXY }}
AGENT_MODE: ${{ secrets.AGENT_MODE }}
AGENT_TYPE: ${{ secrets.AGENT_TYPE }}
+ PLAIN_OUTPUT: True
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml
index ff43666c44..cacb58c566 100644
--- a/.github/workflows/docker-ci.yml
+++ b/.github/workflows/docker-ci.yml
@@ -102,6 +102,7 @@ jobs:
- id: test
name: Run tests
env:
+ PLAIN_OUTPUT: True
CI: true
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
diff --git a/tests/conftest.py b/tests/conftest.py
index 0ee023b58d..8e607c393c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,3 +1,4 @@
+import os
from pathlib import Path
import pytest
@@ -5,6 +6,7 @@ from pytest_mock import MockerFixture
from autogpt.config.config import Config
from autogpt.llm.api_manager import ApiManager
+from autogpt.logs import TypingConsoleHandler
from autogpt.workspace import Workspace
pytest_plugins = [
@@ -43,3 +45,15 @@ def api_manager() -> ApiManager:
if ApiManager in ApiManager._instances:
del ApiManager._instances[ApiManager]
return ApiManager()
+
+
[email protected](autouse=True)
+def patch_emit(monkeypatch):
+ # convert plain_output to a boolean
+
+ if bool(os.environ.get("PLAIN_OUTPUT")):
+
+ def quick_emit(self, record: str):
+ print(self.format(record))
+
+ monkeypatch.setattr(TypingConsoleHandler, "emit", quick_emit)