Skip to content

Commit

Permalink
Cater for empty python cells (#3212)
Browse files Browse the repository at this point in the history
## 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>
  • Loading branch information
ericvergnaud and ericvergnaud authored Nov 7, 2024
1 parent 56cd45a commit 32de6bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/databricks/labs/ucx/source_code/notebooks/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,12 @@ def _load_tree_from_python_cell(self, python_cell: PythonCell, register_trees: b
maybe_tree = Tree.maybe_normalized_parse(python_cell.original_code)
if maybe_tree.failure:
yield maybe_tree.failure
assert maybe_tree.tree is not None
tree = maybe_tree.tree
# a cell with only comments will not produce a tree
if register_trees:
self._python_trees[python_cell] = tree
self._python_trees[python_cell] = tree or Tree.new_module()
if not tree:
return
yield from self._load_children_from_tree(tree)

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

0 comments on commit 32de6bb

Please sign in to comment.