Skip to content

Servers

ropt.plugins.server.base.ServerPlugin

Bases: Plugin

Abstract base class for asynchronous server plugins.

This class defines the interface for plugins responsible for creating Evaluator instances within an optimization workflow.

create abstractmethod classmethod

create(name: str, **kwargs: Any) -> Server

Create a Server instance.

This abstract class method serves as a factory for creating concrete Server objects. Plugin implementations must override this method to return an instance of their specific Server subclass.

The PluginManager calls this method when an evaluator provided by this plugin is requested.

The name argument specifies the requested evaluator, potentially in the format "plugin-name/method-name" or just "method-name". Implementations can use this name to vary the created evaluator if the plugin supports multiple evaluator types.

Parameters:

Name Type Description Default
name str

The requested server name (potentially plugin-specific).

required
kwargs Any

Additional arguments for custom configuration.

{}

Returns:

Type Description
Server

An initialized instance of an Server subclass.

ropt.plugins.server.base.Server

Bases: ABC

Abstract base class for server components within an optimization workflow.

Subclasses must implement the following abstract methods and properties:

  • start: Starts the server.
  • cancel: Stops the server.
  • task_queue: Retrieves the servers task queue.
  • loop: Retrieves the currently running asyncio loop.
  • task_group: The asyncio.Taskgroup used by this server.
  • is_running: Checks if the server is running.

task_queue abstractmethod property

task_queue: Queue[Any]

Get the task queue.

loop abstractmethod property

loop: AbstractEventLoop | None

Get the asyncio loop used by this server.

task_group abstractmethod property

task_group: TaskGroup | None

Get the task group used by this server.

start abstractmethod async

start(task_group: TaskGroup) -> None

Start the evaluation server.

Parameters:

Name Type Description Default
task_group TaskGroup

The task group to use.

required

Raises:

Type Description
RuntimeError

If the evaluator is already running or using an external queue.

cancel abstractmethod

cancel() -> None

Stop the evaluation server.

is_running abstractmethod

is_running() -> bool

Check if the server is not running.

Returns:

Type Description
bool

True if the server is not running.

ropt.plugins.server.base.Task dataclass

Bases: ABC

A task to be executed by a worker.

Attributes:

Name Type Description
function Callable[..., Any]

The function to execute.

args tuple[Any, ...]

The arguments to pass to the function.

kwargs dict[str, Any]

The keyword arguments to pass to the function.

results_queue ResultsQueue

The queue to put the result in.

result Any | None

The result of the function, or None if no result is available.

put_result

put_result(result: Any) -> None

Put the result in the result queue.

cancel_all

cancel_all() -> None

Stop putting results in the result queue.

ropt.plugins.server.base.ServerBase

Bases: Server

An base class for asynchronous servers.

loop property

loop: AbstractEventLoop | None

Get the asyncio loop used by this server.

task_group property

task_group: TaskGroup | None

Get the task group used by this server.

task_queue property

task_queue: Queue[Task]

Get the task queue.

__init__

__init__(queue_size: int = 0) -> None

Initialize the server.

Parameters:

Name Type Description Default
queue_size int

Maximum size of the task queue.

0

cancel

cancel() -> None

Stop the evaluation server.

cleanup abstractmethod

cleanup() -> None

Cleanup the server.

is_running

is_running() -> bool

Check if the server is not running.

Returns:

Type Description
bool

True if the server is running.