Skip to content

optimize_anything_with_server

gepa.optimize_anything.optimize_anything_with_server(server: EvalServer, config: OptimizeAnythingConfig | None = None) -> Result

Run optimization against a caller-owned :class:EvalServer.

The caller is responsible for server.start() and server.stop(). Server-shaped config fields such as max_evals, output_dir, and tracker are ignored because they already belong to the server.

Source code in gepa/oa/ensemble.py
def optimize_anything_with_server(
    server: EvalServer,
    config: OptimizeAnythingConfig | None = None,
) -> Result:
    """Run optimization against a caller-owned :class:`EvalServer`.

    The caller is responsible for ``server.start()`` and ``server.stop()``.
    Server-shaped config fields such as ``max_evals``, ``output_dir``, and
    ``tracker`` are ignored because they already belong to the server.
    """
    # Lazy import avoids a circular import (gepa.optimize_anything imports this module).
    from gepa.optimize_anything import _build_engine, _run_engine

    if config is None:
        config = OptimizeAnythingConfig()
    engine = _build_engine(config)
    return _run_engine(server, engine, owns_server=False)