Skip to content

Commit

Permalink
rename RpcAgentServerLauncher to AgentServerLauncher
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed May 10, 2024
1 parent 51ab7a8 commit dbf5b18
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docs/sphinx_doc/en/source/tutorial/208-distribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ agentscope.init(
...
)
# Create an agent service process
server = RpcAgentServerLauncher(
server = AgentServerLauncher(
host="ip_a",
port=12001, # choose an available port
)
Expand All @@ -88,7 +88,7 @@ agentscope.init(
...
)
# Create an agent service process
server = RpcAgentServerLauncher(
server = AgentServerLauncher(
host="ip_b",
port=12002, # choose an available port
)
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx_doc/zh_CN/source/tutorial/208-distribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ agentscope.init(
...
)
# Create an agent service process
server = RpcAgentServerLauncher(
server = AgentServerLauncher(
host="ip_a",
port=12001, # choose an available port
)
Expand All @@ -87,7 +87,7 @@ agentscope.init(
...
)
# Create an agent service process
server = RpcAgentServerLauncher(
server = AgentServerLauncher(
host="ip_b",
port=12002, # choose an available port
)
Expand Down
4 changes: 2 additions & 2 deletions examples/distributed_basic/distributed_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import agentscope
from agentscope.agents.user_agent import UserAgent
from agentscope.agents.dialog_agent import DialogAgent
from agentscope.server import RpcAgentServerLauncher
from agentscope.server import AgentServerLauncher


def parse_args() -> argparse.Namespace:
Expand Down Expand Up @@ -36,7 +36,7 @@ def setup_assistant_server(assistant_host: str, assistant_port: int) -> None:
agentscope.init(
model_configs="configs/model_configs.json",
)
assistant_server_launcher = RpcAgentServerLauncher(
assistant_server_launcher = AgentServerLauncher(
host=assistant_host,
port=assistant_port,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/distributed_debate/distributed_debate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import agentscope
from agentscope.agents import DialogAgent
from agentscope.msghub import msghub
from agentscope.server import RpcAgentServerLauncher
from agentscope.server import AgentServerLauncher
from agentscope.message import Msg
from agentscope.utils.logging_utils import logger

Expand Down Expand Up @@ -75,7 +75,7 @@ def setup_server(parsed_args: argparse.Namespace) -> None:
)
host = getattr(parsed_args, f"{parsed_args.role}_host")
port = getattr(parsed_args, f"{parsed_args.role}_port")
server_launcher = RpcAgentServerLauncher(
server_launcher = AgentServerLauncher(
host=host,
port=port,
custom_agents=[UserProxyAgent, DialogAgent],
Expand Down
4 changes: 2 additions & 2 deletions examples/distributed_simulation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import agentscope
from agentscope.agents import AgentBase
from agentscope.server import RpcAgentServerLauncher
from agentscope.server import AgentServerLauncher
from agentscope.message import Msg


Expand Down Expand Up @@ -58,7 +58,7 @@ def setup_participant_agent_server(host: str, port: int) -> None:
model_configs="configs/model_configs.json",
use_monitor=False,
)
assistant_server_launcher = RpcAgentServerLauncher(
assistant_server_launcher = AgentServerLauncher(
host=host,
port=port,
max_pool_size=16384,
Expand Down
4 changes: 2 additions & 2 deletions src/agentscope/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class _AgentMeta(ABCMeta):
"""

def __init__(cls, name: Any, bases: Any, attrs: Any) -> None:
if not hasattr(cls, "registry"):
if not hasattr(cls, "_registry"):
cls._registry = {}
else:
if name in cls._registry:
Expand Down Expand Up @@ -245,7 +245,7 @@ def register_agent_class(cls, agent_class: Type[AgentBase]) -> None:
"""
agent_class_name = agent_class.__name__
if agent_class_name in cls._registry:
logger.warning(
logger.info(
f"Agent class with name [{agent_class_name}] already exists.",
)
else:
Expand Down
4 changes: 2 additions & 2 deletions src/agentscope/agents/rpc_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
serialize,
)
from agentscope.rpc import RpcAgentClient
from agentscope.server.launcher import RpcAgentServerLauncher
from agentscope.server.launcher import AgentServerLauncher


def rpc_servicer_method( # type: ignore[no-untyped-def]
Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(
launch_server = port is None
if launch_server:
self.host = "localhost"
self.server_launcher = RpcAgentServerLauncher(
self.server_launcher = AgentServerLauncher(
host=self.host,
port=port,
max_pool_size=max_pool_size,
Expand Down
4 changes: 2 additions & 2 deletions src/agentscope/server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""Import all server related modules in the package."""
from .launcher import RpcAgentServerLauncher
from .launcher import AgentServerLauncher
from .servicer import AgentPlatform

__all__ = [
"RpcAgentServerLauncher",
"AgentServerLauncher",
"AgentPlatform",
]
20 changes: 10 additions & 10 deletions src/agentscope/server/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
add_RpcAgentServicer_to_server = Any


def setup_rpc_agent_server(
def setup_agent_server(
host: str,
port: int,
init_settings: dict = None,
Expand All @@ -36,7 +36,7 @@ def setup_rpc_agent_server(
max_timeout_seconds: int = 1800,
custom_agents: list = None,
) -> None:
"""Setup gRPC server rpc agent.
"""Setup agent server.
Args:
host (`str`, defaults to `"localhost"`):
Expand All @@ -63,7 +63,7 @@ def setup_rpc_agent_server(
A list of custom agent classes that are not in `agentscope.agents`.
"""
asyncio.run(
setup_rpc_agent_server_async(
setup_agent_server_async(
host=host,
port=port,
init_settings=init_settings,
Expand All @@ -78,7 +78,7 @@ def setup_rpc_agent_server(
)


async def setup_rpc_agent_server_async(
async def setup_agent_server_async(
host: str,
port: int,
init_settings: dict = None,
Expand All @@ -90,7 +90,7 @@ async def setup_rpc_agent_server_async(
max_timeout_seconds: int = 1800,
custom_agents: list = None,
) -> None:
"""Setup gRPC server rpc agent in an async way.
"""Setup agent server in an async way.
Args:
host (`str`, defaults to `"localhost"`):
Expand Down Expand Up @@ -207,7 +207,7 @@ def check_port(port: Optional[int] = None) -> int:
return port


class RpcAgentServerLauncher:
class AgentServerLauncher:
"""The launcher of AgentPlatform (formerly RpcAgentServer)."""

def __init__(
Expand All @@ -222,7 +222,7 @@ def __init__(
agent_args: tuple = (),
agent_kwargs: dict = None,
) -> None:
"""Init a rpc agent server launcher.
"""Init a launcher of agent server.
Args:
host (`str`, defaults to `"localhost"`):
Expand Down Expand Up @@ -262,7 +262,7 @@ def __init__(
):
logger.warning(
"`agent_class`, `agent_args` and `agent_kwargs` is deprecated"
" in `RpcAgentServerLauncher`",
" in `AgentServerLauncher`",
)

def _launch_in_main(self) -> None:
Expand All @@ -271,7 +271,7 @@ def _launch_in_main(self) -> None:
f"Launching agent server at [{self.host}:{self.port}]...",
)
asyncio.run(
setup_rpc_agent_server_async(
setup_agent_server_async(
host=self.host,
port=self.port,
max_pool_size=self.max_pool_size,
Expand All @@ -289,7 +289,7 @@ def _launch_in_sub(self) -> None:
self.parent_con, child_con = Pipe()
start_event = Event()
server_process = Process(
target=setup_rpc_agent_server,
target=setup_agent_server,
kwargs={
"host": self.host,
"port": self.port,
Expand Down
10 changes: 5 additions & 5 deletions tests/rpc_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import agentscope
from agentscope.agents import AgentBase, DistConf
from agentscope.server import RpcAgentServerLauncher
from agentscope.server import AgentServerLauncher
from agentscope.message import Msg
from agentscope.message import PlaceholderMessage
from agentscope.message import deserialize
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_single_rpc_agent_server(self) -> None:

def test_connect_to_an_existing_rpc_server(self) -> None:
"""test connecting to an existing server"""
launcher = RpcAgentServerLauncher(
launcher = AgentServerLauncher(
# choose port automatically
host="127.0.0.1",
port=12010,
Expand Down Expand Up @@ -420,7 +420,7 @@ def test_standalone_multiprocess_init(self) -> None:

def test_multi_agent_in_same_server(self) -> None:
"""test agent server with multi agent"""
launcher = RpcAgentServerLauncher(
launcher = AgentServerLauncher(
host="127.0.0.1",
port=12010,
local_mode=False,
Expand Down Expand Up @@ -548,14 +548,14 @@ def test_error_handling(self) -> None:
def test_agent_nesting(self) -> None:
"""Test agent nesting"""
host = "localhost"
launcher1 = RpcAgentServerLauncher(
launcher1 = AgentServerLauncher(
# choose port automatically
host=host,
port=12010,
local_mode=False,
custom_agents=[DemoGatherAgent, DemoGeneratorAgent],
)
launcher2 = RpcAgentServerLauncher(
launcher2 = AgentServerLauncher(
# choose port automatically
host=host,
port=12011,
Expand Down

0 comments on commit dbf5b18

Please sign in to comment.