fleche.metadata

Attributes

JSONValue

Classes

MetaData

Abstract base class for defining metadata types.

Runtime

Metadata type for capturing runtime information.

Tags

Metadata type for storing arbitrary tags.

Module Contents

type fleche.metadata.JSONValue = str | int | float | bool | None | list['JSONValue'] | dict[str, 'JSONValue'][source]
class fleche.metadata.MetaData[source]

Bases: abc.ABC

Abstract 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.

Parameters:

call (Call) – The call object of the decorated function.

Returns:

A flat dictionary of JSON-serializable metadata collected before execution.

Return type:

dict[str, JSONValue]

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.

Parameters:
  • pre (dict[str, JSONValue]) – Metadata collected during the pre-execution phase.

  • call (Call) – The call object of the decorated function.

Returns:

A flat dictionary of JSON-serializable metadata collected after execution.

Return type:

dict[str, JSONValue]

property keys: dict[str, type][source]
Abstractmethod:

Defines the schema of the metadata, mapping metadata keys to their expected types.

Returns:

A dictionary representing the metadata schema.

Return type:

dict[str, type]

property name: str[source]
Abstractmethod:

The unique name of this metadata type.

Returns:

The name of the metadata type.

Return type:

str

class fleche.metadata.Runtime[source]

Bases: MetaData

Metadata 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.

name: str = 'runtime'[source]

The unique name of this metadata type.

Returns:

The name of the metadata type.

Return type:

str

keys: dict[str, type][source]

Defines the schema of the metadata, mapping metadata keys to their expected types.

Returns:

A dictionary representing the metadata schema.

Return type:

dict[str, type]

class fleche.metadata.Tags[source]

Bases: MetaData

Metadata type for storing arbitrary tags.

For each key in the tags dictionary, a new metadata column is created.

Keys:

tags (dict): A dictionary of user-defined tags.

Notes

Tag values must be JSON-serializable.

tags: dict[str, Any][source]
pre(call: fleche.call.Call) dict[str, Any][source]

Hook for collecting metadata before the function execution.

Parameters:

call (Call) – The call object of the decorated function.

Returns:

A flat dictionary of JSON-serializable metadata collected before execution.

Return type:

dict[str, JSONValue]

name: str = 'tags'[source]

The unique name of this metadata type.

Returns:

The name of the metadata type.

Return type:

str

property keys[source]

Defines the schema of the metadata, mapping metadata keys to their expected types.

Returns:

A dictionary representing the metadata schema.

Return type:

dict[str, type]