Quicker logs in pytest (#4486)

pull/4630/head^2
merwanehamadi 2023-06-09 15:18:56 -07:00 committed by GitHub
parent 923c67e92a
commit 3081f56ecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -102,6 +102,7 @@ jobs:
- id: test
name: Run tests
env:
PLAIN_OUTPUT: True
CI: true
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |

View File

@ -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()
@pytest.fixture(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)