fleche.metadata
Attributes
Classes
Abstract base class for defining metadata types. |
|
Metadata type for capturing runtime information. |
|
Metadata type for capturing the execution environment. |
|
Metadata type for capturing the git state of the working directory. |
|
Metadata type for storing arbitrary tags. |
Functions
|
Register a MetaData subclass as zero-arg configurable and set its name. |
|
Run |
Module Contents
- type fleche.metadata.JSONValue = str | int | float | bool | None | list['JSONValue'] | dict[str, 'JSONValue'][source]
- class fleche.metadata.MetaData[source]
Bases:
abc.ABCAbstract base class for defining metadata types.
Implementations must return only JSON-serializable values from pre() and post(). That means scalars (str, int, float, bool, None), lists of those, or dicts with str keys and JSON-serializable values.
- pre(call: fleche.call.Call) dict[str, JSONValue][source]
Hook for collecting metadata before the function execution.
- post(pre: dict[str, JSONValue], call: fleche.call.Call) dict[str, JSONValue][source]
Hook for collecting metadata after the function execution.
The return value of the function is available on the call.result attribute.
- fleche.metadata.configurable(cls: type[MetaData]) type[MetaData][source]
Register a MetaData subclass as zero-arg configurable and set its name.
Sets
cls.nametocls.__name__.lower()and adds the class to theCONFIGURABLEregistry undercls.__name__, making it selectable from the TOML[default] metadata = [...]list. Classes that require constructor arguments (e.g.Tags) must not be decorated.
- class fleche.metadata.Runtime[source]
Bases:
MetaDataMetadata type for capturing runtime information.
- Keys:
timestart (float): The timestamp when the execution started. timestop (float): The timestamp when the execution stopped. walltime (float): The total execution time in seconds.
Notes
Values are JSON-serializable.
- pre(call: fleche.call.Call) dict[str, Any][source]
Records the start time before function execution.
- post(pre: dict[str, Any], call: fleche.call.Call) dict[str, Any][source]
Records the stop time and calculates the wall time after function execution.
- class fleche.metadata.Environment[source]
Bases:
MetaDataMetadata type for capturing the execution environment.
- Keys:
hostname (str): The machine hostname (
socket.gethostname()). username (str): The current user (getpass.getuser()). cwd (str): The working directory at call time (os.getcwd()). fleche_version (str): The fleche package version (fleche.__version__);"unknown"when the package was imported without an installed_version.py(e.g. an editable checkout without a build).python_version (str): The CPython runtime version (
platform.python_version()).
- pre(call: fleche.call.Call) dict[str, Any][source]
Hook for collecting metadata before the function execution.
- fleche.metadata._git(*args: str) str | None[source]
Run
gitwith args and return stripped stdout, orNoneon failure.
- class fleche.metadata.Git[source]
Bases:
MetaDataMetadata type for capturing the git state of the working directory.
- Keys:
root (str | None): Repository top level (
git rev-parse --show-toplevel). commit (str | None): HEAD commit SHA (git rev-parse HEAD). branch (str | None): Current branch name (git rev-parse --abbrev-ref HEAD);"HEAD"when in detached-HEAD state.- dirty (bool | None):
Trueif there are uncommitted changes (tracked or untracked),
Falseotherwise;Nonewhen not inside a repository or git is unavailable.
- dirty (bool | None):
All keys are
Nonewhen not inside a git repository or when thegitexecutable is missing.- pre(call: fleche.call.Call) dict[str, Any][source]
Hook for collecting metadata before the function execution.
- class fleche.metadata.Tags[source]
Bases:
MetaDataMetadata type for storing arbitrary tags.
For each key in the
tagsdictionary, a new metadata column is created.- Keys:
tags (dict): A dictionary of user-defined tags.
Notes
Tag values must be JSON-serializable.
- pre(call: fleche.call.Call) dict[str, Any][source]
Hook for collecting metadata before the function execution.