Scaleout Edge API Client
This section documents the Scaleout Edge API Client, the high-level interface used by external applications, orchestration layers, and tools to interact with a running Scaleout Edge network. The API Client provides convenient methods for:
querying network state
managing clients, attributes, and sessions
submitting models and retrieving results
interacting with controllers, combiners, and server functions
It acts as the primary Python entry point for programmatic communication with the Scaleout Edge backend.
- class scaleout.Scaleout(host: str, *, port: int = None, secure: bool | None = None, verify: bool = True, token: str = None, auth_scheme: str = None, token_endpoint: str = None, access_token_provider: Callable[[], str | None] | None = None)[source]
Bases:
objectPython client for interacting with the statestore and controller.
- Parameters:
- __init__(host: str, *, port: int = None, secure: bool | None = None, verify: bool = True, token: str = None, auth_scheme: str = None, token_endpoint: str = None, access_token_provider: Callable[[], str | None] | None = None)[source]
Initialize the Scaleout client.
- Parameters:
host (str) – The host of the api server.
port (int) – The port of the api server.
secure (bool) – Whether to use https.
verify (bool) – Whether to verify the server SSL certificate (default: True). Set to False for development with self-signed certificates.
token (str) – Refresh token for automatic token management. Can also be set via SCALEOUT_AUTH_TOKEN env var.
auth_scheme (str) – Authorization scheme (e.g., ‘Bearer’). Defaults to ‘Bearer’.
token_endpoint (str) – Token refresh endpoint URL. If not provided, will be constructed from host.
- add_attributes(attribute: dict) dict[source]
Add or update node attributes via the controller API.
- Parameters:
attribute – A dict matching AttributeDTO.schema, e.g.:
{ "key": "charging", "value": "true", "entity_id": "client_123", }- Returns:
Parsed JSON response from the server.
- Return type:
- add_status(status: dict) dict[source]
Submit a status entry to the controller API.
- Parameters:
status –
A dict matching StatusDTO.schema, e.g.:
{ "type": "MODEL_UPDATE", "log_level": "INFO", "status": "Training complete", "sender": { "client_id": "abc-123" } }
- Returns:
Parsed JSON response from the server.
- Return type:
- continue_session(session_id: str, rounds: int = 5, round_timeout: int = 180)[source]
Continue a session.
- get_active_clients(combiner_id: str = None, n_max: int = None)[source]
Get active clients from the statestore.
- get_active_model()[source]
Get the latest model from the statestore.
- Returns:
The latest model.
- Return type:
- get_active_package()[source]
Get the (active) compute package from the statestore.
- Returns:
Package.
- Return type:
- get_client_config(checksum=True)[source]
Get client config from controller. Optionally include the checksum. The config is used for clients to connect to the controller and ask for combiner assignment.
- get_clients_count(only_active: bool = False)[source]
Get the number of clients in the statestore.
- Returns:
The number of clients.
- Return type:
- get_combiners_count()[source]
Get the number of combiners in the statestore.
- Returns:
The number of combiners.
- Return type:
- get_commands(n_max: int = None, parent_correlation_id: str = None)[source]
Get commands in the network.
- get_commands_count()[source]
Get the number of commands in the statestore.
- Returns:
The number of commands.
- Return type:
- get_commands_roots(n_max: int = None)[source]
Get root commands (commands without parent) in the network.
- get_controller_status()[source]
Get the status of the controller.
- Returns:
The status of the controller.
- Return type:
- get_current_attributes(entity_list)[source]
Get the current attributes of the entity(ies).
- Parameters:
entity_list (list|str) – The list of entities to get the attributes for or a single entity_id (client_id or combiner_id)
- Raises:
ValueError – If entity_list is not a list or empty.
- Returns:
The current attributes of the entities.
- Return type:
- get_metrics(*, session_id: str = None, model_id: str = None, round_id: str = None, key: str = None, sender_name: str = None, sender_role: str = None, sender_client_id: str = None, n_max: int = None)[source]
Get metrics logged with EdgeClient.log_metric from the statestore. Filter by input parameters.
- Parameters:
session_id (str) – The session id to get metrics for.
model_id (str) – The model id to get metrics for.
round_id (str) – The round id to get metrics for.
key (str) – The metric key (name) to get metrics for.
sender_name (str) – The sender name to get metrics for.
sender_role (str) – The sender role to get metrics for.
sender_client_id (str) – The sender client id to get metrics for.
n_max (int) – The maximum number of metrics to get (If none all will be fetched).
- Returns:
Metrics.
- Return type:
- get_metrics_count(session_id: str = None)[source]
Get the number of metrics in the statestore.
- Returns:
The number of metrics.
- Return type:
- get_model_trail(id: str = None, include_self: bool = True, reverse: bool = True, n_max: int = None)[source]
Get the model trail.
- get_models_count()[source]
Get the number of models in the statestore.
- Returns:
The number of models.
- Return type:
- get_package_checksum()[source]
Get the checksum of the compute package.
- Returns:
The checksum.
- Return type:
- get_packages_count()[source]
Get the number of compute packages in the statestore.
- Returns:
The number of packages.
- Return type:
- get_rounds_count()[source]
Get the number of rounds in the statestore.
- Returns:
The number of rounds.
- Return type:
- get_sessions_count()[source]
Get the number of sessions in the statestore.
- Returns:
The number of sessions.
- Return type:
- get_statuses(session_id: str = None, event_type: str = None, sender_name: str = None, sender_role: str = None, n_max: int = None)[source]
Get statuses from the statestore. Filter by input parameters
- get_statuses_count()[source]
Get the number of statuses in the statestore.
- Returns:
The number of statuses.
- Return type:
- get_validations(*, session_id: str = None, model_id: str = None, correlation_id: str = None, sender_name: str = None, sender_role: str = None, sender_client_id: str = None, n_max: int = None)[source]
Get validations from the statestore. Filter by input parameters.
- Parameters:
session_id (str) – The session id to get validations for.
model_id (str) – The model id to get validations for.
correlation_id (str) – The correlation id to get validations for.
sender_name (str) – The sender name to get validations for.
sender_role (str) – The sender role to get validations for.
sender_client_id (str) – The sender client id to get validations for.
n_max (int) – The maximum number of validations to get (If none all will be fetched).
- Returns:
Validations.
- Return type:
- get_validations_count(session_id: str = None)[source]
Get the number of validations in the statestore.
- Returns:
The number of validations.
- Return type:
- run_custom_command(command_type: str, synchronous: bool = False, timeout: int = None, client_ids: list = None, parameters: dict = None)[source]
- set_active_model(path)[source]
Set the initial model in the statestore and upload to model repository.
- Parameters:
path (str) – The file path of the initial model to set.
- Raises:
RuntimeError – If the file type is unsupported (only .npz and .bin are supported), or if the server responds with a non-success status code.
- Returns:
A dict with success or failure message.
- Return type:
- set_active_package(path: str, helper: str, name: str, description: str = '', restart_clients: bool = False)[source]
Set the compute package in the statestore.
- set_public_hostname(id: str, public_hostname: str)[source]
Set the public hostname of a combiner.
- Parameters:
- Raises:
RuntimeError – If the server responds with a non-success status code.
- Returns:
The server response (a success message).
- Return type:
- start_inference(model_id: str, synchronous: bool = True, timeout: int = None, client_ids: list = None, parameters: dict = None)[source]
Start an inference trail for a model.
- Parameters:
model_id (str) – The id of the model to start inference for.
parameters (dict) – The parameters for the inference.
client_ids (list) – The list of client ids to start inference on (if None all clients will be started).
timeout (int) – The timeout for the inference session in seconds, -1 for infinite (default: 180).
synchronous – Whether to run the inference synchronously (in order) or asynchronously (default: True).
- Returns:
A dict with success or failure message.
- Return type:
- start_session(*, name: str = None, aggregator: str = 'fedavg', aggregator_kwargs: dict = None, model_id: str = None, round_timeout: int = 180, rounds: int = 5, round_buffer_size: int = -1, delete_models: bool = True, validate: bool = True, helper: str = None, min_clients: int = 1, requested_clients: int = 8, server_functions: ServerFunctionsBase = None)[source]
Start a new session.
- Parameters:
name (str) – The name of the session
aggregator (str) – The aggregator plugin to use.
model_id (str) – The id of the initial model.
round_timeout (int) – The round timeout to use in seconds.
rounds (int) – The number of rounds to perform.
round_buffer_size (int) – The round buffer size to use.
delete_models (bool) – Whether to delete models after each round at combiner (save storage).
validate (bool) – Whether to validate the model after each round.
helper (str) – The helper type to use.
min_clients (int) – The minimum number of clients required.
requested_clients (int) – The requested number of clients.
- Returns:
A dict with success or failure message and session config.
- Return type:
- start_validation(session_id: str, model_id: str)[source]
Start a validation for a given session and model.
- step_command(correlation_id: str)[source]
Skip a synchronization barrier in a session control for a specific correlation id.
- stop_current_command()[source]
Stop a session control.
- Parameters:
session_id (str) – The id of the session to stop.
- Raises:
RuntimeError – If the server responds with a non-success status code.
- Returns:
A dict with success or failure message.
- Return type: