plugins.h_mlflow.MLFlowTracker¶
- class hamilton.plugins.h_mlflow.MLFlowTracker(tracking_uri: str | None = None, registry_uri: str | None = None, artifact_location: str | None = None, experiment_name: str = 'Hamilton', experiment_tags: dict | None = None, experiment_description: str | None = None, run_id: str | None = None, run_name: str | None = None, run_tags: dict | None = None, run_description: str | None = None, log_system_metrics: bool = False)¶
Driver adapter logging Hamilton execution results to an MLFlow server.
- __init__(tracking_uri: str | None = None, registry_uri: str | None = None, artifact_location: str | None = None, experiment_name: str = 'Hamilton', experiment_tags: dict | None = None, experiment_description: str | None = None, run_id: str | None = None, run_name: str | None = None, run_tags: dict | None = None, run_description: str | None = None, log_system_metrics: bool = False)¶
Configure the MLFlow client and experiment for the lifetime of the tracker
- Parameters:
tracking_uri – Destination of the logged artifacts and metadata. It can be a filesystem, database, or server. [reference](https://mlflow.org/docs/latest/getting-started/tracking-server-overview/index.html)
registry_uri – Destination of the registered models. By default it’s the same as the tracking destination, but they can be different. [reference](https://mlflow.org/docs/latest/getting-started/registering-first-model/index.html)
artifact_location – Root path on tracking server where experiment is stored
experiment_name – MLFlow experiment name used to group runs.
experiment_tags – Tags to query experiments programmatically (not displayed).
experiment_description – Description of the experiment displayed
run_id – Run id to log to an existing run (every execution logs to the same run)
run_name – Run name displayed and used to query runs. You can have multiple runs with the same name but different run ids.
run_tags – Tags to query runs and appears as columns in the UI for filtering and grouping. It automatically includes serializable inputs and Driver config.
run_description – Description of the run displayed
log_system_metrics – Log system metrics to display (requires additonal dependencies)
- post_graph_construct(*, graph: FunctionGraph, modules: List[ModuleType], config: Dict[str, Any])¶
Hooks that is called after the graph is constructed.
- Parameters:
graph – Graph that has been constructed.
modules – Modules passed into the graph
config – Config passed into the graph
- post_graph_execute(*, run_id: str, graph: FunctionGraph, success: bool, error: Exception | None, results: Dict[str, Any] | None)¶
Just delegates to the interface method, passing in the right data.
- post_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], success: bool, error: Exception | None, result: Any | None, task_id: str | None = None)¶
Wraps the after_execution method, providing a bridge to an external-facing API. Do not override this!
- pre_graph_execute(*, run_id: str, graph: FunctionGraph, final_vars: List[str], inputs: Dict[str, Any], overrides: Dict[str, Any])¶
Implementation of the pre_graph_execute hook. This just converts the inputs to the format the user-facing hook is expecting – performing a walk of the DAG to pass in the set of nodes to execute. Delegates to the interface method.
- pre_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], task_id: str | None = None)¶
Wraps the before_execution method, providing a bridge to an external-facing API. Do not override this!
- run_after_graph_construction(*, config: dict[str, Any], **kwargs)¶
Store the Driver config before creating the graph
- run_after_graph_execution(success: bool, *args, **kwargs)¶
End the MLFlow run
- run_after_node_execution(*, node_name: str, node_return_type: Type, node_tags: dict, node_kwargs: dict, result: Any, **kwargs)¶
Log materializers and final vars as artifacts
- run_before_graph_execution(*, run_id: str, final_vars: List[str], inputs: Dict[str, Any], graph: HamiltonGraph, **kwargs)¶
Create and start MLFlow run. Log graph version, run_id, inputs, overrides
- run_before_node_execution(*args, **kwargs)¶
Placeholder required to subclass NodeExecutionHook