Skip to content

Commit 32de6bb

Browse files
authored
Cater for empty python cells (#3212)
## Changes Notebok cells such as the following will crash the dependency builder. This PR fixes the issue. ``` # COMMAND ---------- #only run this step if you are running below Databricks runtime 13.2 GPU; if using 13.2 and above this is not needed. %sh wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub sudo add-apt-repository -y "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" sudo apt-get update ``` ### Linked issues None ### Functionality None ### Tests - [x] ran solacc on failed repo Co-authored-by: Eric Vergnaud <eric.vergnaud@databricks.com>
1 parent 56cd45a commit 32de6bb

File tree

1 file changed

+4
-2
lines changed
  • src/databricks/labs/ucx/source_code/notebooks

1 file changed

+4
-2
lines changed

src/databricks/labs/ucx/source_code/notebooks/sources.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ def _load_tree_from_python_cell(self, python_cell: PythonCell, register_trees: b
199199
maybe_tree = Tree.maybe_normalized_parse(python_cell.original_code)
200200
if maybe_tree.failure:
201201
yield maybe_tree.failure
202-
assert maybe_tree.tree is not None
203202
tree = maybe_tree.tree
203+
# a cell with only comments will not produce a tree
204204
if register_trees:
205-
self._python_trees[python_cell] = tree
205+
self._python_trees[python_cell] = tree or Tree.new_module()
206+
if not tree:
207+
return
206208
yield from self._load_children_from_tree(tree)
207209

208210
def _load_children_from_tree(self, tree: Tree) -> Iterable[Advice]:

0 commit comments

Comments
 (0)