formating

This commit is contained in:
Aarushi
2024-09-05 22:29:25 +01:00
parent fd0572cb43
commit 7e4d535d5f
6 changed files with 14 additions and 12 deletions

View File

@@ -1,14 +1,11 @@
from multiprocessing import freeze_support, set_start_method
from typing import TYPE_CHECKING
import Pyro5.api as pyro
from tenacity import retry, stop_after_attempt, wait_exponential
from .util.logging import configure_logging
if TYPE_CHECKING:
from autogpt_server.util.process import AppProcess
def run_processes(processes: list["AppProcess"], **kwargs):
"""
Execute all processes in the app. The last process is run in the foreground.
@@ -26,17 +23,18 @@ def main(**kwargs):
freeze_support()
configure_logging()
from autogpt_server.executor import ExecutionScheduler
from autogpt_server.server import AgentServer
from autogpt_server.util.service import PyroNameServer
from autogpt_server.executor import ExecutionScheduler
run_processes(
[
ExecutionScheduler(),
AgentServer(),
],
**kwargs
)
def execution_manager(**kwargs):
set_start_method("spawn", force=True)
freeze_support()
@@ -51,5 +49,6 @@ def execution_manager(**kwargs):
**kwargs
)
if __name__ == "__main__":
main()

View File

@@ -1,5 +1,4 @@
import inspect
import logging
from collections import defaultdict
from contextlib import asynccontextmanager
from functools import wraps
@@ -239,7 +238,7 @@ class AgentServer(AppService):
@property
def execution_scheduler_client(self) -> ExecutionScheduler:
return get_service_client(ExecutionScheduler,8003)
return get_service_client(ExecutionScheduler, 8003)
@classmethod
def handle_internal_http_error(cls, request: Request, exc: Exception):

View File

@@ -6,6 +6,7 @@ import time
from abc import abstractmethod
from typing import Any, Callable, Coroutine, Type, TypeVar, cast
import Pyro5.api
from Pyro5 import api as pyro
from Pyro5 import nameserver
from tenacity import retry, stop_after_attempt, wait_exponential
@@ -14,7 +15,6 @@ from autogpt_server.data import db
from autogpt_server.data.queue import AsyncEventQueue, AsyncRedisEventQueue
from autogpt_server.util.process import AppProcess
from autogpt_server.util.settings import Config
import Pyro5.api
logger = logging.getLogger(__name__)
conn_retry = retry(
@@ -65,6 +65,7 @@ class AppService(AppProcess):
def __init__(self, port):
self.port = port
self.uri = None
@classmethod
@property
def service_name(cls) -> str:
@@ -108,7 +109,9 @@ class AppService(AppProcess):
daemon = Pyro5.api.Daemon(host=host, port=self.port)
self.uri = daemon.register(self, objectId=self.service_name)
logger.info(f"Service in start pyro [{self.service_name}] Ready. Object URI = {self.uri}")
logger.info(
f"Service in start pyro [{self.service_name}] Ready. Object URI = {self.uri}"
)
daemon.requestLoop()
def __start_async_loop(self):

View File

@@ -13,7 +13,7 @@ async def test_agent_schedule(server: SpinTestServer):
test_user = await create_test_user()
test_graph = await graph.create_graph(create_test_graph(), user_id=test_user.id)
scheduler = get_service_client(ExecutionScheduler,8002)
scheduler = get_service_client(ExecutionScheduler, 8002)
schedules = scheduler.get_execution_schedules(test_graph.id, test_user.id)
assert len(schedules) == 0

View File

@@ -29,7 +29,7 @@ class TestService(AppService):
@pytest.mark.asyncio(scope="session")
async def test_service_creation(server):
with TestService():
client = get_service_client(TestService)
client = get_service_client(TestService, 8000)
assert client.add(5, 3) == 8
assert client.subtract(10, 4) == 6
assert client.fun_with_async(5, 3) == 8

View File

@@ -47,6 +47,7 @@ services:
- AUTH_ENABLED=false
- PYRO_HOST=0.0.0.0
- EXECUTIONMANAGER_HOST=execution_manager
- EXECUTIONSCHEDULER_HOST=execution_scheduler
ports:
- "8000:8000"
networks: