er and set a stack with the new experiment trackerzenml stack register custom_stack -e mlflow_experiment_tracker ... --set

This method requires you to configure a ZenML secret to store the MLflow tracking service credentials securely.

You can create the secret using the zenml secret create command:

# Create a secret called `mlflow_secret` with key-value pairs for the

# username and password to authenticate with the MLflow tracking server

zenml secret create mlflow_secret \

--username=<USERNAME> \

--password=<PASSWORD>

Once the secret is created, you can use it to configure the MLflow Experiment Tracker:

# Reference the username and password in our experiment tracker component

zenml experiment-tracker register mlflow \

--flavor=mlflow \

--tracking_username={{mlflow_secret.username}} \

--tracking_password={{mlflow_secret.password}} \

...

Read more about ZenML Secrets in the ZenML documentation.

For more, up-to-date information on the MLflow Experiment Tracker implementation and its configuration, you can have a look at the SDK docs .

How do you use it?

To be able to log information from a ZenML pipeline step using the MLflow Experiment Tracker component in the active stack, you need to enable an experiment tracker using the @step decorator. Then use MLflow's logging or auto-logging capabilities as you would normally do, e.g.:

import mlflow

@step(experiment_tracker="<MLFLOW_TRACKER_STACK_COMPONENT_NAME>")

def tf_trainer(

x_train: np.ndarray,

y_train: np.ndarray,

) -> tf.keras.Model:

"""Train a neural net from scratch to recognize MNIST digits return our

model or the learner"""

# compile model

mlflow.tensorflow.autolog()

# train model

# log additional information to MLflow explicitly if needed

mlflow.log_param(...)

mlflow.log_metric(...)

mlflow.log_artifact(...)

return model

Instead of hardcoding an experiment tracker name, you can also use the Client to dynamically use the experiment tracker of your active stack:

from zenml.client import Client