pyfebiopt.optimize.runners
==========================

.. py:module:: pyfebiopt.optimize.runners

.. autoapi-nested-parse::

   Lightweight helpers for launching local FEBio runs.



Classes
-------

.. autoapisummary::

   pyfebiopt.optimize.runners.RunResult
   pyfebiopt.optimize.runners.RunHandle
   pyfebiopt.optimize.runners.Runner
   pyfebiopt.optimize.runners.LocalSerialRunner
   pyfebiopt.optimize.runners.LocalParallelRunner


Module Contents
---------------

.. py:class:: RunResult

   Summary information about a finished simulation command.


   .. py:attribute:: exit_code
      :type:  int


   .. py:attribute:: started_at
      :type:  float


   .. py:attribute:: ended_at
      :type:  float


   .. py:attribute:: log_path
      :type:  pathlib.Path


   .. py:attribute:: metadata
      :type:  dict[str, object]


   .. py:property:: duration
      :type: float


      Execution time in seconds.


.. py:class:: RunHandle

   Future-like wrapper returned by runner implementations.


   .. py:method:: wait(timeout: float | None = None) -> RunResult

      Block until the underlying future completes.

      :returns: RunResult containing exit code and metadata.



   .. py:method:: done() -> bool

      Return True when the run has finished.



   .. py:method:: cancel() -> bool

      Attempt to cancel the run.

      :returns: ``True`` if cancellation succeeded.



   .. py:method:: result() -> RunResult

      Return the RunResult, blocking if necessary.



   .. py:method:: __await__() -> collections.abc.Generator[RunResult, None, RunResult]


.. py:class:: Runner

   Minimal interface expected by the optimization engine.


   .. py:method:: run(job_dir: str | pathlib.Path, feb_name: str | pathlib.Path, *, env: dict[str, str] | None = None) -> RunHandle
      :abstractmethod:


      Schedule a FEBio run and return a handle for tracking completion.



   .. py:method:: shutdown() -> None

      Clean up any resources held by the runner.



.. py:class:: LocalSerialRunner(command: collections.abc.Sequence[str] | None = None, *, env: dict[str, str] | None = None)

   Bases: :py:obj:`_BaseLocalRunner`


   Execute simulations sequentially on the local machine.

   Create a serial runner for single-threaded execution.


.. py:class:: LocalParallelRunner(n_jobs: int, command: collections.abc.Sequence[str] | None = None, *, env: dict[str, str] | None = None)

   Bases: :py:obj:`_BaseLocalRunner`


   Execute simulations concurrently using a thread pool.

   Create a parallel runner backed by a thread pool.


   .. py:attribute:: n_jobs


