Skip to content

Servers

ropt.plugins.server.default.DefaultServerPlugin

Bases: ServerPlugin

The default plugin for creating evaluators.

This plugin acts as a factory for the standard server implementations provided by ropt.

Supported Servers:

ropt.plugins.server._async_server.DefaultAsyncServer

Bases: ServerBase

An evaluator server that employs asynchronous workers.

__init__

__init__(*, workers: int = 1, queue_size: int = 0) -> None

Initialize the server.

Parameters:

Name Type Description Default
workers int

The number of workers to use.

1
queue_size int

Maximum size of the tasks queue.

0

start async

start(task_group: TaskGroup) -> None

Start the server.

Parameters:

Name Type Description Default
task_group TaskGroup

The task group to use.

required

cleanup

cleanup() -> None

Cleanup the server.

ropt.plugins.server._multiprocessing_server.DefaultMultiprocessingServer

Bases: ServerBase

An evaluator server that employs a pool of multiprocessing workers.

__init__

__init__(*, workers: int = 1, queue_size: int = 0) -> None

Initialize the server.

Parameters:

Name Type Description Default
workers int

The number of workers to use.

1
queue_size int

Maximum size of the tasks queue.

0

start async

start(task_group: TaskGroup) -> None

Start the server.

Parameters:

Name Type Description Default
task_group TaskGroup

The task group to use.

required

cleanup

cleanup() -> None

Cleanup the server.

ropt.plugins.server._hpc_server.DefaultHPCServer

Bases: ServerBase

A server for submitting tasks to a High-Performance Computing (HPC) cluster.

This server interfaces with an HPC queueing system (like Slurm) via the pysqa library. It manages the entire lifecycle of a remote task, including:

  • Serializing the task (function and arguments) and writing it to a shared filesystem.
  • Submitting the task as a job to the HPC queue.
  • Polling the queue for the job's status.
  • Retrieving the results (or any exceptions) once the job is complete.

Configuration of the cluster connection is handled either through a submission script template or a pysqa configuration directory.

__init__

__init__(
    *,
    workdir: Path | str = "./",
    workers: int = 1,
    queue_size: int = 0,
    interval: float = 1,
    queue_type: str = "slurm",
    template: str | None = None,
    config_path: Path | str | None = None,
    cluster: str | None = None,
) -> None

Initialize the HPC server.

This sets up the server for communication with an HPC cluster. The connection can be configured in two ways:

  1. By providing a template string for the job submission script.
  2. By providing a config_path to a directory containing pysqa cluster configurations.

If config_path is not given, the server will look for a default configuration at <sysconfig_data>/share/ropt/pysqa. One of these configuration methods is required.

Parameters:

Name Type Description Default
workdir Path | str

Working directory on a shared filesystem accessible by both the client and the HPC nodes. Used for temporary input/output files.

'./'
workers int

The maximum number of concurrent jobs to run on the HPC cluster.

1
queue_size int

The maximum number of tasks to hold in the internal queue before submission. A value of 0 means an unlimited size.

0
interval float

The interval in seconds at which to poll the HPC queue for job status updates.

1
queue_type str

The type of the queueing system (e.g., "slurm"). This is passed to pysqa and is also used to find the correct subdirectory within config_path.

'slurm'
template str | None

An optional submission script template. If provided, it will be used by pysqa to generate the job submission script.

None
config_path Path | str | None

An optional path to a directory containing pysqa cluster configuration files. This is used if template is not provided.

None
cluster str | None

Optional name of the cluster to use. If supported by the installation, this makes it possible to switch between clusters.

None

Raises:

Type Description
RuntimeError

If neither a template is provided nor a valid config_path can be found.

start async

start(task_group: TaskGroup) -> None

Start the server.

Parameters:

Name Type Description Default
task_group TaskGroup

The task group to use.

required

cleanup

cleanup() -> None

Clean up the server resources.

This method cancels the background worker task that polls the HPC queue and ensures that any clients waiting for results are notified of the shutdown.