Skip to content

get_mlflow_resource_from_config

kedro_dagster.utils.get_mlflow_resource_from_config(mlflow_config)

Create a Dagster resource definition from MLflow config.

Parameters

Name Type Description Default
mlflow_config BaseModel

MLflow configuration.

required

Returns

Type Description
ResourceDefinition

Dagster resource definition for MLflow.

See Also

kedro_dagster.utils.is_mlflow_enabled : Checks whether MLflow integration is available. kedro_dagster.utils.get_mlflow_run_url : Returns the MLflow UI URL for the active run.

Source Code

Show/Hide source
def get_mlflow_resource_from_config(mlflow_config: "BaseModel") -> dg.ResourceDefinition:
    """Create a Dagster resource definition from MLflow config.

    Parameters
    ----------
    mlflow_config : BaseModel
        MLflow configuration.

    Returns
    -------
    ResourceDefinition
        Dagster resource definition for MLflow.

    See Also
    --------
    `kedro_dagster.utils.is_mlflow_enabled` :
        Checks whether MLflow integration is available.
    `kedro_dagster.utils.get_mlflow_run_url` :
        Returns the MLflow UI URL for the active run.
    """
    if mlflow_tracking is None:  # pragma: no cover
        msg = "dagster-mlflow is not installed. Please install it to use MLflow integration."
        LOGGER.error(msg)
        raise ImportError(msg)

    mlflow_resource = mlflow_tracking.configured({
        "experiment_name": mlflow_config.tracking.experiment.name,
        "mlflow_tracking_uri": mlflow_config.server.mlflow_tracking_uri,
        "parent_run_id": None,
    })

    return mlflow_resource