mantik.mlflow

Attributes

logger

Functions

active_run(→ Optional[mlflow.ActiveRun])

Get the currently active run, or None if no such run exists.

call_method(→ Any)

A general function to call any given MLflow method.

create_experiment(→ None)

Not supported: only permitted via the Mantik platform.

delete_experiment(→ None)

Not supported: only permitted via the Mantik platform.

delete_run(→ None)

Not supported: only permitted via the Mantik platform.

delete_tag(→ None)

Delete a tag.

end_run() → None)

End an active MLflow run.

get_local_backend_config_run_id_env_var(→ str)

Get the MLflow local backend config run id environment variable.

get_tracking_uri(→ str)

Get the MLflow tracking URI set as MLFLOW_TRACKING_URI.

init_tracking(→ mantik.tracking.environment.Environment)

Attempts to initialize tracking to Mantik, emits warning if it fails.

log_artifact(→ None)

Log a local file or directory as an artifact of the currently

log_artifacts(→ None)

Log all the contents of a local directory as artifacts of the run.

log_dict(→ Any)

Log a JSON/YAML-serializable object (e.g. dict) as an artifact.

log_figure(→ Any)

Log a figure as an artifact.

log_image(→ Any)

Log an image as an artifact.

log_metric(→ None)

Log a metric for the current run.

log_metrics(→ None)

Log a batch of metrics for the current run.

log_param(→ Any)

Log a parameter (e.g. model hyperparameter) for the current run.

log_params(→ None)

Log a batch of params for the current run.

log_text(→ None)

Log text as an artifact.

register_model(...)

Create a new model version in the model registry.

set_tag(→ None)

Log a tag for the current run.

set_tags(→ None)

Log a batch of tags for the current run.

set_tracking_uri(→ None)

Set the tracking server URI (MLFLOW_TRACKING_URI environment

start_run(→ mlflow.ActiveRun)

Start a new MLflow run or pick up the run specified as MLFLOW_RUN_ID,

Module Contents

mantik.mlflow.active_run() mlflow.ActiveRun | None[source]

Get the currently active run, or None if no such run exists.

mantik.mlflow.call_method(method: Callable | str, *args, **kwargs) Any[source]

A general function to call any given MLflow method.

Parameters:
  • method (Callable or str) –

    MLflow method to invoke.

    If str, only the method name is requried, e.g. for mlflow.log_param, method=”log_param” is required.

  • args – Passed to the MLflow method.

  • kwargs – Passed to the MLflow method.

Examples

With the mlflow method:

>>> import mantik.mlflow
>>> import mlflow
>>> mantik.mlflow.call_method(mlflow.log_param, key="<name>", value="<value>")  # noqa: E501

or with a str:

>>> import mantik.mlflow as mlflow
>>> mlflow.call_method("log_param", key="<name>", value="<value>")  # noqa: E501
Return type:

The returned instance of the MLflow method.

mantik.mlflow.create_experiment(name: str, artifact_location: str | None = None, tags: Dict[str, Any] | None = None) None[source]

Not supported: only permitted via the Mantik platform.

mantik.mlflow.delete_experiment(experiment_id: int) None[source]

Not supported: only permitted via the Mantik platform.

mantik.mlflow.delete_run(run_id: str) None[source]

Not supported: only permitted via the Mantik platform.

mantik.mlflow.delete_tag(key: str) None[source]

Delete a tag.

mantik.mlflow.end_run(status: str = mlflow.entities.RunStatus.to_string(mlflow.entities.RunStatus.FINISHED)) None[source]

End an active MLflow run.

mantik.mlflow.get_local_backend_config_run_id_env_var() str[source]

Get the MLflow local backend config run id environment variable.

mantik.mlflow.get_tracking_uri() str[source]

Get the MLflow tracking URI set as MLFLOW_TRACKING_URI.

mantik.mlflow.init_tracking() mantik.tracking.environment.Environment[source]

Attempts to initialize tracking to Mantik, emits warning if it fails.

If successful, this sets the MLFLOW_TRACKING_TOKEN environment variable to the access token retrieved from the Mantik API.

Returns:

Holds the access token for the Mantik and MLflow API.

Return type:

mantik.tracking.environment.Environment

mantik.mlflow.log_artifact(local_path: str, artifact_path: str | None = None) None[source]

Log a local file or directory as an artifact of the currently active run.

mantik.mlflow.log_artifacts(local_dir: str, artifact_path: str | None = None) None[source]

Log all the contents of a local directory as artifacts of the run.

mantik.mlflow.log_dict(dictionary: Any, artifact_file: str) Any[source]

Log a JSON/YAML-serializable object (e.g. dict) as an artifact.

mantik.mlflow.log_figure(figure, artifact_file: str) Any[source]

Log a figure as an artifact.

mantik.mlflow.log_image(image, artifact_file: str) Any[source]

Log an image as an artifact.

mantik.mlflow.log_metric(key: str, value: float, step: int | None = None) None[source]

Log a metric for the current run.

mantik.mlflow.log_metrics(metrics: Dict[str, float], step: int | None = None) None[source]

Log a batch of metrics for the current run.

mantik.mlflow.log_param(key: str, value: Any) Any[source]

Log a parameter (e.g. model hyperparameter) for the current run.

mantik.mlflow.log_params(params: Dict[str, Any]) None[source]

Log a batch of params for the current run.

mantik.mlflow.log_text(text: str, artifact_file: str) None[source]

Log text as an artifact.

mantik.mlflow.logger[source]
mantik.mlflow.register_model(model_uri, name, *, tags: Dict[str, Any] | None = None) mlflow.entities.model_registry.ModelVersion[source]

Create a new model version in the model registry.

mantik.mlflow.set_tag(key: str, value: Any) None[source]

Log a tag for the current run.

mantik.mlflow.set_tags(tags: Dict[str, Any]) None[source]

Log a batch of tags for the current run.

mantik.mlflow.set_tracking_uri(uri: str | pathlib.Path) None[source]

Set the tracking server URI (MLFLOW_TRACKING_URI environment variable).

mantik.mlflow.start_run(run_id: str = None, experiment_id: str | None = None, run_name: str | None = None, nested: bool = False, tags: Dict[str, Any] | None = None, description: str | None = None) mlflow.ActiveRun[source]

Start a new MLflow run or pick up the run specified as MLFLOW_RUN_ID, which is set by the Mantik Compute Backend when submitting a run.