Databricks-ML-Pro Model Development Practice Question
A machine learning engineer is using MLflow to log a custom PyTorch model. They define a custom pyfunc class that inherits from mlflow.pyfunc.PythonModel and implements predict(). After logging the model with mlflow.pyfunc.log_model(), they load it with mlflow.pyfunc.load_model() and call predict() with a pandas DataFrame. The prediction fails with an error about missing context. What is the most likely cause?
⚠ Common exam trap
The trap here is assuming that the context parameter is optional or that it relates to environment loading, when it is a required argument in the predict() method signature.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The predict() method signature must include a context parameter as the first argument, but the implementation omitted it.
MLflow's PythonModel.predict() method is defined as predict(self, context, model_input). The context argument is always passed by MLflow when calling predict. If the custom class defines predict(self, model_input), Python will raise a TypeError about missing arguments when MLflow attempts to call it with both context and model_input. The fix is to include context in the method signature, even if it is not used.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The model was logged without specifying the conda_env, so the context cannot be reconstructed during loading.
Why it's wrong here
The conda_env is used to recreate the Python environment for the model, but it does not affect the predict() method's signature. Even if conda_env is not specified, MLflow uses a default environment. The error about missing context is unrelated to the environment; it is a programming error in the PythonModel implementation.
- ✗
The pandas DataFrame passed to predict() must be converted to a NumPy array first, otherwise the context is not passed.
Why it's wrong here
The type of input data does not affect whether context is passed; MLflow always passes context as the first argument to predict(). Converting to NumPy would not fix a missing parameter in the method definition. The error is due to the method signature, not the input type.
- ✗
The custom pyfunc class must inherit from mlflow.pyfunc.PythonModel and also implement load_context(), which is missing.
Why it's wrong here
load_context() is optional; if not implemented, the base class provides a no-op. The error about missing context during predict() is not caused by a missing load_context(). While load_context() is useful for loading artifacts, its absence does not cause a missing context argument error. The issue is strictly the predict() method signature.
- ✓
The predict() method signature must include a context parameter as the first argument, but the implementation omitted it.
Why this is correct
In MLflow's PythonModel, the predict() method must accept two arguments: context and model_input. The context provides information about the model and environment. If the implementation defines predict(self, model_input) without context, loading and calling predict will raise an error because MLflow passes the context. This is a common mistake when writing custom pyfunc models.
About these practice questions
This Databricks-ML-Pro question is part of Courseiva's 300-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Databricks exam blueprint
This Databricks-ML-Pro practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-ML-Pro exam.