DP-100 · Question #402
DP-100 Question #402: Real Exam Question with Answer & Explanation
The question tests the ability to correctly sequence commands for creating a new Conda environment, installing Python dependencies including Jupyter, and registering it as a Jupyter kernel in an Azure Machine Learning compute instance.
Question
Drag and Drop Question You manage an Azure Machine Learning workspace named workspace1 with a compute instance named compute1. You connect to compute1 by using a terminal window from workspace1. You create a file named "requirements.txt" containing Python dependencies to include Jupyter. You need to add a new Jupyter kernel to compute1. Which four commands should you use? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order. Answer:
Explanation
The question tests the ability to correctly sequence commands for creating a new Conda environment, installing Python dependencies including Jupyter, and registering it as a Jupyter kernel in an Azure Machine Learning compute instance.
Approach. The correct interaction is to drag the four relevant commands from the 'Commands' list to the 'Answer Area' and arrange them in the following order:
- conda create -n "python_env": This is the first step, as it creates a new isolated Conda environment named 'python_env'. This environment will house the specific Python version and libraries needed for the new Jupyter kernel, preventing conflicts with other projects.
- conda activate "python_env": After creating the environment, it must be activated. Activating the environment ensures that any subsequent commands (like
conda installoripython kernel install) operate within this specific environment rather than the base or another environment. - conda install -r requirements.txt: With the new environment activated, this command installs all the Python packages listed in the 'requirements.txt' file. The scenario states that 'requirements.txt' contains Python dependencies 'to include Jupyter', so this step ensures that Jupyter and its necessary components are installed into 'python_env'.
- ipython kernel install -user -name="python_env": This final command registers the currently active Python environment (which now has Jupyter installed) as a new Jupyter kernel. The '--user' flag installs it for the current user, and '--name="python_env"' gives the kernel a recognizable name that will appear in Jupyter's kernel selection list. This makes the newly configured environment available for use in Jupyter notebooks.
Common mistakes.
- common_mistake. A common mistake is selecting or misplacing 'jupyter run'. This command is used to launch a Jupyter application (like Jupyter Notebook or JupyterLab) or execute a script using Jupyter, but it is not part of the process for creating or registering a new Jupyter kernel. Other mistakes include incorrect ordering, such as attempting to install packages before creating and activating an environment, or trying to register a kernel before Jupyter itself has been installed into that environment.
Concept tested. The core concept tested is the ability to manage Python environments using Conda (creation, activation, package installation) and to register a custom Python environment as a new Jupyter kernel, specifically within the context of an Azure Machine Learning compute instance. It also implicitly tests understanding of dependency management using 'requirements.txt'.
Topics
Community Discussion
No community discussion yet for this question.