Skip to main content

DynexConfig

Handles all SDK configuration: credentials, compute backend, gRPC endpoint, timeouts, and output formatting.
from dynex import DynexConfig, ComputeBackend, QPUModel

Constructor

DynexConfig(
    sdk_key: Optional[str] = None,
    grpc_endpoint: Optional[str] = None,
    solver_path: Optional[str] = None,
    compute_backend: Union[ComputeBackend, str] = ComputeBackend.UNSPECIFIED,
    qpu_model: Optional[Union[QPUModel, str]] = None,
    use_notebook_output: bool = True,
    default_timeout: float = 300.0,
    default_description: str = "Dynex SDK Job",
    retry_count: int = 5,
    preserve_solutions: bool = False,
    remove_local_solutions: bool = False,
    dotenv_path: Optional[str] = None,
)

Parameters

sdk_key
str
SDK authentication key. If not provided, loaded from DYNEX_SDK_KEY environment variable or .env file.
grpc_endpoint
str
gRPC server endpoint. Defaults to "127.0.0.1:9090". Set via DYNEX_GRPC_ENDPOINT env var or provide directly.Production: "quantum-router-engine-grpc.hz.dynex.co:3000"
compute_backend
ComputeBackend | str
default:"ComputeBackend.UNSPECIFIED"
Compute backend to use. Accepts enum value or string:
ValueStringDescription
ComputeBackend.GPU"gpu"Dynex neuromorphic GPU chips — primary backend
ComputeBackend.QPU"qpu"Specific QPU hardware model
ComputeBackend.CPU"cpu"CPU workers on the network
ComputeBackend.LOCAL"local"Local binary, no network required
qpu_model
QPUModel | str
Required when compute_backend=QPU. Available models:
ValueString
QPUModel.APOLLO_RC1"apollo_rc1"
QPUModel.APOLLO_10000"apollo_10000"
use_notebook_output
bool
default:"True"
Enable Jupyter-friendly output formatting (progress bars, tables).
default_timeout
float
default:"300.0"
Job timeout in seconds. Applies to network backends.
default_description
str
default:"\"Dynex SDK Job\""
Default job description shown in the Dynex job dashboard.
retry_count
int
default:"5"
Number of retries for transient network failures.
preserve_solutions
bool
default:"False"
If True, keep solution files on disk after sampling completes.
remove_local_solutions
bool
default:"False"
If True, automatically delete local solution files after reading.
dotenv_path
str
Custom path to .env file. If not provided, searches current directory and up to 3 parent directories.
solver_path
str
Custom path to directory containing dynexcore binary (LOCAL mode only).

Configuration priority

Parameters are resolved in this order (highest to lowest priority):
  1. Constructor arguments
  2. Environment variables (DYNEX_SDK_KEY, DYNEX_GRPC_ENDPOINT, etc.)
  3. .env file values (if python-dotenv is installed)
  4. Default values

Examples

from dynex import DynexConfig, ComputeBackend, QPUModel

# GPU — Dynex neuromorphic chips, primary production backend
config = DynexConfig(compute_backend=ComputeBackend.GPU)

# QPU — specific hardware model
config = DynexConfig(
    compute_backend=ComputeBackend.QPU,
    qpu_model=QPUModel.APOLLO_RC1,
    default_timeout=600.0,
    default_description="Production portfolio optimization",
)

# CPU — lightweight network testing
config = DynexConfig(compute_backend=ComputeBackend.CPU)

# LOCAL — offline development, no credentials needed
config = DynexConfig(compute_backend=ComputeBackend.LOCAL)

# Inspect configuration
print(config.as_dict())
print(config.get_platform_prefix())  # "APOLLO-RC1" | "CPU" | "LOCAL" etc.

as_dict() method

Returns all configuration parameters as a dictionary:
config.as_dict()
# {
#   'sdk_key': '...',
#   'grpc_endpoint': 'quantum-router-engine-grpc.hz.dynex.co:3000',
#   'mainnet': True,
#   'solver_path': None,
#   'retry_count': 5,
#   'compute_backend': 'qpu',
#   'qpu_model': 'apollo_rc1',
#   'use_notebook_output': True,
#   'default_timeout': 300.0,
#   'default_description': 'Dynex SDK Job',
#   'preserve_solutions': False,
# }

Errors

ExceptionCause
ValueErrorInvalid compute_backend or qpu_model string; missing qpu_model for QPU backend
FileNotFoundErrordynexcore binary not found in LOCAL mode
PermissionErrorCannot create tmp/ directory