diff --git a/src/databricks/labs/ucx/source_code/notebook.py b/src/databricks/labs/ucx/source_code/notebook.py index fa4d3119ee..5d257db63c 100644 --- a/src/databricks/labs/ucx/source_code/notebook.py +++ b/src/databricks/labs/ucx/source_code/notebook.py @@ -167,6 +167,22 @@ def migrate_notebook_path(self): pass +class ShellCell(Cell): + + @property + def language(self): + return CellLanguage.SHELL + + def is_runnable(self) -> bool: + return True # TODO + + def build_dependency_graph(self, parent: DependencyGraph): + pass # nothing to do + + def migrate_notebook_path(self): + pass + + class PipCell(Cell): @property @@ -190,6 +206,7 @@ class CellLanguage(Enum): SQL = Language.SQL, 'sql', '--', True, SQLCell RUN = None, 'run', '', False, RunCell PIP = None, 'pip', '', False, PipCell + SHELL = None, 'sh', '', False, ShellCell # see https://spec.commonmark.org/0.31.2/#html-comment MARKDOWN = None, 'md', "", False, MarkdownCell R = Language.R, 'r', '#', True, RCell diff --git a/tests/unit/source_code/samples/notebook-with-shell-cell.py.txt b/tests/unit/source_code/samples/notebook-with-shell-cell.py.txt new file mode 100644 index 0000000000..4b6da858ea --- /dev/null +++ b/tests/unit/source_code/samples/notebook-with-shell-cell.py.txt @@ -0,0 +1,6 @@ +# Databricks notebook source +import datetime + +# COMMAND ---------- + +# MAGIC %sh "./shell-script.sh" diff --git a/tests/unit/source_code/test_notebook.py b/tests/unit/source_code/test_notebook.py index 217767ee58..8fd9111e5d 100644 --- a/tests/unit/source_code/test_notebook.py +++ b/tests/unit/source_code/test_notebook.py @@ -41,6 +41,11 @@ Language.SQL, ['md', 'sql', 'sql', 'md', 'sql', 'python', 'sql', 'sql', 'sql', 'md', 'sql', 'sql', 'md', 'sql', 'sql', 'md', 'sql'], ) +SHELL_NOTEBOOK_SAMPLE = ( + "notebook-with-shell-cell.py.txt", + Language.PYTHON, + ['python', 'sh'], +) PIP_NOTEBOOK_SAMPLE = ( "notebook-with-pip-cell.py.txt", Language.PYTHON, @@ -57,6 +62,7 @@ SCALA_NOTEBOOK_SAMPLE, R_NOTEBOOK_SAMPLE, SQL_NOTEBOOK_SAMPLE, + SHELL_NOTEBOOK_SAMPLE, PIP_NOTEBOOK_SAMPLE, ], )