mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-09 06:15:41 -05:00
This pull request includes several changes to improve the backend functionality and configuration of the `autogpt_platform`. The most important changes involve adding a RabbitMQ service for testing, enhancing logging configuration, updating the linter script to handle errors gracefully, and modifying test configurations. Backend configuration improvements: * [`autogpt_platform/backend/docker-compose.test.yaml`](diffhunk://#diff-f6a211ff1c6d96d19adb5641ee287258a6af8d72a99e33dafb4a334094205a43R29-R43): Added RabbitMQ service configuration for testing, including health checks and environment variables. * [`autogpt_platform/backend/.env.example`](diffhunk://#diff-62020caf1b9a15e0e3b9b3b1b69d5f6464bf7643f62354cbbaabf755d57b6064R191-R192): Added a section delimiter for optional API keys for use in finding the optional keys end when auto generating integrations. Error handling and logging enhancements: * [`autogpt_platform/backend/linter.py`](diffhunk://#diff-0787e3ef718ac9963df64d9ab1d8e7a3b35dc4ab0cb874c65da6c2901e1e4991R3): Updated the `run` function to handle `subprocess.CalledProcessError` exceptions and print error output to `stderr` and prevent raising a stack trace when it should not. [[1]](diffhunk://#diff-0787e3ef718ac9963df64d9ab1d8e7a3b35dc4ab0cb874c65da6c2901e1e4991R3) [[2]](diffhunk://#diff-0787e3ef718ac9963df64d9ab1d8e7a3b35dc4ab0cb874c65da6c2901e1e4991L13-R23) Testing configuration updates: * [`autogpt_platform/backend/pyproject.toml`](diffhunk://#diff-26ebebd91da791c6484f07d9d91484a66f52836708f5294b24365603438b880cR111): Added `asyncio_default_fixture_loop_scope` to pytest configuration for better control over asyncio fixtures. * [`autogpt_platform/backend/run_tests.py`](diffhunk://#diff-f09930577243a4ef5213bf6191a3c500a4b8d3dcfee2d4b452cf7ce66b3c494fL55): Removed the `postgres-test` service from the test setup script as we need all of docker services up for the tests to run.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
directory = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
BACKEND_DIR = "."
|
|
LIBS_DIR = "../autogpt_libs"
|
|
TARGET_DIRS = [BACKEND_DIR, LIBS_DIR]
|
|
|
|
|
|
def run(*command: str) -> None:
|
|
print(f">>>>> Running poetry run {' '.join(command)}")
|
|
try:
|
|
subprocess.run(
|
|
["poetry", "run"] + list(command),
|
|
cwd=directory,
|
|
check=True,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
)
|
|
except subprocess.CalledProcessError as e:
|
|
print(e.output.decode("utf-8"), file=sys.stderr)
|
|
|
|
|
|
def lint():
|
|
try:
|
|
run("ruff", "check", *TARGET_DIRS, "--exit-zero")
|
|
run("ruff", "format", "--diff", "--check", LIBS_DIR)
|
|
run("isort", "--diff", "--check", "--profile", "black", BACKEND_DIR)
|
|
run("black", "--diff", "--check", BACKEND_DIR)
|
|
run("pyright", *TARGET_DIRS)
|
|
except subprocess.CalledProcessError as e:
|
|
print("Lint failed, try running `poetry run format` to fix the issues: ", e)
|
|
raise e
|
|
|
|
|
|
def format():
|
|
run("ruff", "check", "--fix", *TARGET_DIRS)
|
|
run("ruff", "format", LIBS_DIR)
|
|
run("isort", "--profile", "black", BACKEND_DIR)
|
|
run("black", BACKEND_DIR)
|
|
run("pyright", *TARGET_DIRS)
|