Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for %sh cells #1400

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/databricks/labs/ucx/source_code/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,22 @@
pass


class ShellCell(Cell):

@property
def language(self):
return CellLanguage.SHELL

def is_runnable(self) -> bool:
return True # TODO

Check warning on line 177 in src/databricks/labs/ucx/source_code/notebook.py

View check run for this annotation

Codecov / codecov/patch

src/databricks/labs/ucx/source_code/notebook.py#L177

Added line #L177 was not covered by tests

def build_dependency_graph(self, parent: DependencyGraph):
pass # nothing to do

Check warning on line 180 in src/databricks/labs/ucx/source_code/notebook.py

View check run for this annotation

Codecov / codecov/patch

src/databricks/labs/ucx/source_code/notebook.py#L180

Added line #L180 was not covered by tests

def migrate_notebook_path(self):
pass

Check warning on line 183 in src/databricks/labs/ucx/source_code/notebook.py

View check run for this annotation

Codecov / codecov/patch

src/databricks/labs/ucx/source_code/notebook.py#L183

Added line #L183 was not covered by tests


class PipCell(Cell):

@property
Expand All @@ -190,6 +206,7 @@
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Databricks notebook source
import datetime

# COMMAND ----------

# MAGIC %sh "./shell-script.sh"
6 changes: 6 additions & 0 deletions tests/unit/source_code/test_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -57,6 +62,7 @@
SCALA_NOTEBOOK_SAMPLE,
R_NOTEBOOK_SAMPLE,
SQL_NOTEBOOK_SAMPLE,
SHELL_NOTEBOOK_SAMPLE,
PIP_NOTEBOOK_SAMPLE,
],
)
Expand Down
Loading