
Answer-first summary for fast verification
Answer: Use the Databricks CLI to create a library with a Python package, ensuring the inclusion of `__init__.py` files for proper package structure, and reference this package in the notebooks.
Option B is the correct approach because it leverages the Databricks CLI to create a properly structured Python package, which is essential for scalability and maintainability. Including `__init__.py` files ensures the package is recognized correctly, and referencing the package in notebooks allows for centralized updates and reduces manual errors. This method aligns with best practices for dependency management in a Databricks environment.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
In a scenario where you are working with multiple notebooks in a Databricks workspace that depend on a common Python library, and you need to ensure that the solution is scalable, maintainable, and adheres to best practices for dependency management, which of the following approaches would you choose? Consider the need for proper package structure, ease of updates, and minimal manual intervention. Choose the best option from the following:
A
Upload the Python files directly to the Databricks workspace as a library without any package structure, and reference them in each notebook.
B
Use the Databricks CLI to create a library with a Python package, ensuring the inclusion of __init__.py files for proper package structure, and reference this package in the notebooks.
C
Embed the Python code directly into each notebook using %pip magic commands to install the required packages at runtime.
D
Manually copy the Python files into each notebook's directory and reference them using relative paths, updating each file individually when changes are made.
No comments yet.