pyfebiopt.monitoring.state
==========================

.. py:module:: pyfebiopt.monitoring.state

.. autoapi-nested-parse::

   Track manifest-based jobs and runtime updates for the monitor UI.



Classes
-------

.. autoapisummary::

   pyfebiopt.monitoring.state.ArtifactInfo
   pyfebiopt.monitoring.state.JobInfo
   pyfebiopt.monitoring.state.StorageInventory


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

.. py:class:: ArtifactInfo

   Describe a file artifact attached to a job.


   .. py:attribute:: kind
      :type:  str


   .. py:attribute:: path
      :type:  pathlib.Path


   .. py:attribute:: size
      :type:  int


.. py:class:: JobInfo

   Hold metadata for a stored monitoring job.


   .. py:attribute:: project
      :type:  str


   .. py:attribute:: iter_id
      :type:  int


   .. py:attribute:: case
      :type:  str


   .. py:attribute:: tag
      :type:  str


   .. py:attribute:: status
      :type:  str


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


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


   .. py:attribute:: placement_root
      :type:  pathlib.Path


   .. py:attribute:: artifacts
      :type:  list[ArtifactInfo]
      :value: []



   .. py:attribute:: summary
      :type:  dict[str, float]


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


   .. py:property:: job_id
      :type: str


      Return the stable identifier for this job.


.. py:class:: StorageInventory(roots: collections.abc.Iterable[pathlib.Path], *, poll_interval: float = 5.0)

   Scan manifest roots and build a current view of stored jobs.

   Set up the inventory scanner with the provided storage roots.


   .. py:attribute:: roots


   .. py:attribute:: poll_interval


   .. py:method:: refresh(force: bool = False) -> None

      Refresh the inventory if the poll interval allows or forcing is requested.



   .. py:method:: list_jobs() -> list[JobInfo]

      Return the current snapshot of discovered jobs.



   .. py:method:: get_job(job_id: str) -> JobInfo | None

      Lookup a job by its identifier.

      :returns: Job metadata if known, else None.
      :rtype: JobInfo | None



   .. py:method:: apply_event(job_id: str, event: str, payload: dict[str, object], ts: float) -> None

      Ingest a monitor event to keep job metadata fresh.



