Skip to content

🔌 Auto Server (Context Manager)

Automatically connect to a running Docker enclave, verify health, and guarantee cleanup — all in a single with block.


Prerequisites

  1. VEOX Server: Start the local VEOX server (requires Docker):

    docker run -d \
      --name veox-enclave-server \
      -p 8090:8090 \
      714044927654.dkr.ecr.us-east-2.amazonaws.com/doug/single_enclave/veox-enclave-server:latest
    
    See the Quick Start for detailed server setup, health checks, and Docker Compose instructions.

  2. Python SDK: Install the veox package via PyPI:

    pip install veox
    


What It Does

Managing API endpoints and checking if the server is alive before launching a multi-hour evolution run is critical. The VeoxEvolver.serve() classmethod acts as a robust Python context manager (with block).

Pro Feature

This is a Pro SDK utility that replaces manual connection handling and health_check() verbosity. It requires an active VEOX Pro license.

Features Showcased

  • Auto-Discovery: Automatically probes host:port to establish a connection.
  • Preemptive Failure: If the enclave is down, it raises a clean RuntimeError before entering the with block, avoiding messy mid-job timeouts.
  • Resource Management: Guarantees clean teardown of sockets when the block exits, even on failure.

Full Example

import os
from sklearn.datasets import make_classification
import pandas as pd
from veox import VeoxEvolver

port = int(os.environ.get("VEOX_PORT", "8090"))
host = os.environ.get("VEOX_HOST", "127.0.0.1")

# Generate dataset
X, y = make_classification(n_samples=300, n_features=10, n_informative=6, random_state=42)
df = pd.DataFrame(X, columns=[f"f{i}" for i in range(10)])
df["target"] = y

try:
    # 💎 PRO FEATURE: VeoxEvolver.serve() auto-discovers and connects to the running enclave
    with VeoxEvolver.serve(port=port, host=host, category="binary") as ev:
        print("Connected! Running evolution...")

        ev.fit(
            data=df,
            target_column="target",
            max_generations=2,
            population_size=10,
            num_islands=1,
            timeout_per_eval=30,
            max_poll_time=120,
        )

        print(f"Best AUC:      {ev.best_fitness_:.4f}")
        print(f"Best Pipeline: {ev.best_pipeline_}")
        print(f"Evaluations:   {ev.result_.total_evals}")

except RuntimeError as exc:
    print(f"Error: {exc}")
    print("Make sure the enclave is running: bash Private/scripts/run_enclave.sh")

Comparison: Manual vs Auto Server

Approach Code Error Handling
Manual ev = VeoxEvolver(...) + ev.health_check() + ev.fit(...) Must handle cleanup yourself
Auto Server with VeoxEvolver.serve(...) as ev: Auto health-check, auto cleanup

💎 VEOX Pro Activation

To unlock Auto Server and other Pro features, you must authenticate your local node with a VEOX License Token.

from veox import VeoxEvolver

evolver = VeoxEvolver("binary", api_url="http://127.0.0.1:8090")

# 1. Fetch your unique Hardware Fingerprint
fingerprint = evolver.get_system_fingerprint()
print(f"My VEOX Node Fingerprint: {fingerprint}")

# 2. Provide this fingerprint to your VEOX Admin to receive a JWT Token
jwt_token = "eyJ0b2tlbiI6ICJVRExK...EXPIRES"  # Replace with your token

# 3. Activate the Enclave
if evolver.activate_license(jwt_token):
    print("VIP Features Unlocked!")

Tips

  • Port override: Set VEOX_PORT env var to connect to non-default ports.
  • Multiple runs: You can call ev.fit() multiple times within the same with block.
  • Exception safety: Even if your code crashes mid-evolution, the context manager ensures clean socket teardown.