0
0
MLOpsdevops~10 mins

Pipeline versioning and reproducibility in MLOps - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to save the pipeline version using MLflow.

MLOps
mlflow.set_experiment('my_experiment')
with mlflow.start_run():
    mlflow.log_param('pipeline_version', [1])
Drag options to blanks, or click blank then click option'
A'v1.0.0'
B1.0
Cversion
Dpipeline
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number instead of a string for version.
2fill in blank
medium

Complete the code to load a specific pipeline version from the registry.

MLOps
from mlflow import pyfunc
model = pyfunc.load_model('models:/my_pipeline/[1]')
Drag options to blanks, or click blank then click option'
Aproduction
Bv1
C1
Dlatest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'latest' which may not be stable.
3fill in blank
hard

Fix the error in the code to ensure pipeline reproducibility by pinning dependencies.

MLOps
import subprocess
def save_requirements():
    with open('requirements.txt', 'w') as f:
        f.write([1])
Drag options to blanks, or click blank then click option'
Aos.system('pip freeze > requirements.txt')
Bpip freeze > requirements.txt
Csubprocess.check_output(['pip', 'freeze'], text=True)
Df.write('pip freeze')
Attempts:
3 left
💡 Hint
Common Mistakes
Writing the string 'pip freeze' instead of the command output.
4fill in blank
hard

Fill both blanks to create a reproducible pipeline run with a fixed random seed.

MLOps
import random
import numpy as np
random.[1](42)
np.random.[2](42)
Drag options to blanks, or click blank then click option'
Aseed
Brandom
Crandint
Dchoice
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods that generate random numbers instead of setting the seed.
5fill in blank
hard

Fill all three blanks to log pipeline metadata with MLflow for reproducibility.

MLOps
mlflow.log_param('[1]', 'v1.0.0')
mlflow.log_param('[2]', 'my_experiment')
mlflow.log_param('[3]', '2024-06-01')
Drag options to blanks, or click blank then click option'
Apipeline_version
Brun_id
Cstart_date
Dexperiment_name
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameter names or using incorrect keys.