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", "sender": { "name": "", "role": "", "client_id": "abc123" # or "combiner_id": "abc123" } }- 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_controller_status()[source]
Get the status of the controller.
- Returns:
The status of the controller.
- Return type:
- get_current_attributes(node_list)[source]
Get the current attributes of the node(s).
- Parameters:
node_list (list|str) – The list of nodes to get the attributes for or a single node_id (client_id or combiner_id)
- Raises:
ValueError – If node_list is not a list or empty.
- Returns:
The current attributes of the nodes.
- 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_predictions(model_id: str = None, correlation_id: str = None, client_id: str = None, n_max: int = None)[source]
Get predictions from the statestore. Filter by input parameters.
- Parameters:
- Returns:
Predictions.
- 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, blocking: 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.
- set_active_package(path: str, helper: str, name: str, description: str = '')[source]
Set the compute package in the statestore.
- start_predictions(prediction_id: str = None, model_id: str = None)[source]
Start predictions for a model.
- 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: