OCDocker.Workbench.Server module

FastAPI-backed local HTTP API for the OCDocker Workbench dashboard.

exception OCDocker.Workbench.Server.WorkbenchAPIError(message, *, status_code=400)[source]

Bases: Exception

HTTP-aware error raised by Workbench API payload builders.

Parameters:
  • message (str)

  • status_code (int)

Return type:

None

__init__(message, *, status_code=400)[source]

Create a Workbench API error.

Parameters:
  • message (str) – Error message.

  • status_code (int) – HTTP status code returned by the local API handler.

Return type:

None

OCDocker.Workbench.Server.build_workbench_api_app(root, *, max_depth=6, server_port=8765, optuna_dashboard_host='127.0.0.1', optuna_dashboard_port_start=None, optuna_dashboard_port_end=None, optuna_dashboard_slots=None)[source]

Build a FastAPI application bound to one OCScore root.

Parameters:
  • root (str or pathlib.Path) – Served OCScore root.

  • max_depth (int) – Maximum recursive depth inside each replica.

  • server_port (int) – TCP port the app will be served on (used to auto-select Optuna dashboard ports).

  • optuna_dashboard_host (str) – Bind host used for local Optuna dashboard subprocesses.

  • optuna_dashboard_port_start (int or None) – Explicit first Optuna dashboard port.

  • optuna_dashboard_port_end (int or None) – Explicit last Optuna dashboard port.

  • optuna_dashboard_slots (int or None) – Override Optuna dashboard slot count.

Returns:

Configured application.

Return type:

fastapi.FastAPI

OCDocker.Workbench.Server.build_workbench_api_payload(root, endpoint, query=None, *, max_depth=6)[source]

Build one strict Workbench API payload without starting a server.

Parameters:
  • root (str or pathlib.Path) – Served OCScore root.

  • endpoint (str) – API endpoint path.

  • query (QueryMap or None) – Parsed query parameters.

  • max_depth (int) – Maximum recursive depth inside each replica.

Returns:

JSON-safe payload.

Return type:

dict[str, Any]

OCDocker.Workbench.Server.serve_workbench_api(root, *, host='127.0.0.1', port=8765, max_depth=6, optuna_dashboard_host='127.0.0.1', optuna_dashboard_port_start=None, optuna_dashboard_port_end=None, optuna_dashboard_slots=None, verbose=False)[source]

Serve the OCDocker Workbench API until interrupted.

Parameters:
  • root (str or pathlib.Path) – Served OCScore root.

  • host (str) – Bind host.

  • port (int) – Bind port.

  • max_depth (int) – Maximum recursive depth inside each replica.

  • optuna_dashboard_host (str)

  • optuna_dashboard_port_start (int | None)

  • optuna_dashboard_port_end (int | None)

  • optuna_dashboard_slots (int | None)

  • verbose (bool)

Return type:

None