mlflow.config

mlflow.config.disable_system_metrics_logging()[source]

Note

Experimental: This function may change or be removed in a future release without warning.

Disable system metrics logging globally.

Calling this function will disable system metrics logging globally, but users can still opt in system metrics logging for individual runs by mlflow.start_run(log_system_metrics=True).

mlflow.config.enable_async_logging(enable=True)[source]

Enable or disable async logging globally.

Parameters

enable – bool, if True, enable async logging. If False, disable async logging.

Example
import mlflow

mlflow.config.enable_async_logging(True)

with mlflow.start_run():
    mlflow.log_param("a", 1)  # This will be logged asynchronously

mlflow.config.enable_async_logging(False)
with mlflow.start_run():
    mlflow.log_param("a", 1)  # This will be logged synchronously
mlflow.config.enable_system_metrics_logging()[source]

Note

Experimental: This function may change or be removed in a future release without warning.

Enable system metrics logging globally.

Calling this function will enable system metrics logging globally, but users can still opt out system metrics logging for individual runs by mlflow.start_run(log_system_metrics=False).

mlflow.config.get_registry_uri()str[source]

Get the current registry URI. If none has been specified, defaults to the tracking URI.

Returns

The registry URI.

# Get the current model registry uri
mr_uri = mlflow.get_registry_uri()
print(f"Current model registry uri: {mr_uri}")

# Get the current tracking uri
tracking_uri = mlflow.get_tracking_uri()
print(f"Current tracking uri: {tracking_uri}")

# They should be the same
assert mr_uri == tracking_uri
Current model registry uri: file:///.../mlruns
Current tracking uri: file:///.../mlruns
mlflow.config.get_tracking_uri()str[source]

Get the current tracking URI. This may not correspond to the tracking URI of the currently active run, since the tracking URI can be updated via set_tracking_uri.

Returns

The tracking URI.

import mlflow

# Get the current tracking uri
tracking_uri = mlflow.get_tracking_uri()
print(f"Current tracking uri: {tracking_uri}")
Current tracking uri: file:///.../mlruns
mlflow.config.is_tracking_uri_set()[source]

Returns True if the tracking URI has been set, False otherwise.

mlflow.config.set_registry_uri(uri: str)None[source]

Set the registry server URI. This method is especially useful if you have a registry server that’s different from the tracking server.

Parameters

uri – An empty string, or a local file path, prefixed with file:/. Data is stored locally at the provided file (or ./mlruns if empty). An HTTP URI like https://my-tracking-server:5000. A Databricks workspace, provided as the string “databricks” or, to use a Databricks CLI profile, “databricks://<profileName>”.

Example
import mflow

# Set model registry uri, fetch the set uri, and compare
# it with the tracking uri. They should be different
mlflow.set_registry_uri("sqlite:////tmp/registry.db")
mr_uri = mlflow.get_registry_uri()
print(f"Current registry uri: {mr_uri}")
tracking_uri = mlflow.get_tracking_uri()
print(f"Current tracking uri: {tracking_uri}")

# They should be different
assert tracking_uri != mr_uri
Output
Current registry uri: sqlite:////tmp/registry.db
Current tracking uri: file:///.../mlruns
mlflow.config.set_system_metrics_node_id(node_id)[source]

Note

Experimental: This function may change or be removed in a future release without warning.

Set the system metrics node id.

node_id is the identifier of the machine where the metrics are collected. This is useful in multi-node (distributed training) setup.

mlflow.config.set_system_metrics_samples_before_logging(samples)[source]

Note

Experimental: This function may change or be removed in a future release without warning.

Set the number of samples before logging system metrics.

Every time samples samples have been collected, the system metrics will be logged to mlflow. By default samples=1.

mlflow.config.set_system_metrics_sampling_interval(interval)[source]

Note

Experimental: This function may change or be removed in a future release without warning.

Set the system metrics sampling interval.

Every interval seconds, the system metrics will be collected. By default interval=10.

mlflow.config.set_tracking_uri(uri: Union[str, pathlib.Path])None[source]

Set the tracking server URI. This does not affect the currently active run (if one exists), but takes effect for successive runs.

Parameters

uri

  • An empty string, or a local file path, prefixed with file:/. Data is stored locally at the provided file (or ./mlruns if empty).

  • An HTTP URI like https://my-tracking-server:5000.

  • A Databricks workspace, provided as the string “databricks” or, to use a Databricks CLI profile, “databricks://<profileName>”.

  • A pathlib.Path instance

Example
import mlflow

mlflow.set_tracking_uri("file:///tmp/my_tracking")
tracking_uri = mlflow.get_tracking_uri()
print(f"Current tracking uri: {tracking_uri}")
Output
Current tracking uri: file:///tmp/my_tracking