forked from databrickslabs/ucx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strip preliminary comments in pip cells (databrickslabs#2763)
## Changes Current implementation fails when pip command is preceded by non MAGIC comments This PR fixes the issue ### Linked issues None ### Functionality None ### Tests - [x] added unit tests Co-authored-by: Eric Vergnaud <eric.vergnaud@databricks.com>
- Loading branch information
1 parent
d14a2cf
commit 97b9996
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
|
||
from databricks.sdk.service.workspace import Language | ||
|
||
from databricks.labs.ucx.source_code.base import CurrentSessionState | ||
from databricks.labs.ucx.source_code.graph import Dependency, DependencyGraph | ||
from databricks.labs.ucx.source_code.linters.files import FileLoader | ||
from databricks.labs.ucx.source_code.notebooks.sources import Notebook | ||
|
||
|
||
def test_malformed_pip_cell_is_supported(simple_ctx): | ||
source = """# Databricks notebook source | ||
# MAGIC %md This notebook sets up the companion cluster(s) to run the solution accelerator. It also creates the Workflow to illustrate the order of execution. Happy exploring! | ||
# COMMAND ---------- | ||
# DBTITLE 0,Install util packages | ||
# MAGIC %pip install git+https://github.com/databricks-academy/dbacademy@v1.0.13 git+https://github.com/databricks-industry-solutions/notebook-solution-companion@safe-print-html --quiet --disable-pip-version-check | ||
""" | ||
notebook = Notebook.parse(Path(""), source=source, default_language=Language.PYTHON) | ||
dependency = Dependency(FileLoader(), Path("")) | ||
parent = DependencyGraph( | ||
dependency, None, simple_ctx.dependency_resolver, simple_ctx.path_lookup, CurrentSessionState() | ||
) | ||
problems = notebook.build_dependency_graph(parent) | ||
assert not problems |