0
0
MLOpsdevops~10 mins

Apache Airflow for ML orchestration 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 import the Airflow DAG class.

MLOps
from airflow import [1]
Drag options to blanks, or click blank then click option'
AVariable
BTaskInstance
CBaseOperator
DDAG
Attempts:
3 left
💡 Hint
Common Mistakes
Importing TaskInstance instead of DAG
Using BaseOperator which is for tasks, not the DAG itself
2fill in blank
medium

Complete the code to define the default arguments for the DAG.

MLOps
default_args = {
    'owner': 'airflow',
    'start_date': [1]
}
Drag options to blanks, or click blank then click option'
Adatetime(2023, 1, 1)
Bdatetime.now()
Cdatetime.today()
Ddatetime.utcnow()
Attempts:
3 left
💡 Hint
Common Mistakes
Using datetime.now() which changes every time and causes errors
Using datetime.today() which is similar to now and not recommended
3fill in blank
hard

Fix the error in the DAG instantiation by completing the missing argument.

MLOps
dag = DAG('ml_pipeline', default_args=default_args, schedule_interval=[1])
Drag options to blanks, or click blank then click option'
A'@daily'
Bdaily
CNone()
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using bare word daily without quotes
Using None() which is not valid syntax
4fill in blank
hard

Fill both blanks to create a PythonOperator task that runs a function named train_model.

MLOps
train_task = PythonOperator(task_id='train', python_callable=[1], dag=[2])
Drag options to blanks, or click blank then click option'
Atrain_model
Btrain
Cdag
Ddefault_args
Attempts:
3 left
💡 Hint
Common Mistakes
Using task_id as python_callable
Passing default_args instead of dag object
5fill in blank
hard

Fill both blanks to set task dependencies: preprocess_task runs before train_task, which runs before evaluate_task.

MLOps
preprocess_task[1]train_task[2]evaluate_task
Drag options to blanks, or click blank then click option'
A >>
B <<
C &
D +
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<<' which reverses the order
Using '&' or '+' which are not valid for dependencies