Skip to content

Commit d533397

Browse files
authored
Ignore DBTITLE magic comments in .py "notebooks" (#1609)
## Changes Ignore DBTITLE magic comments in `.py` "notebooks" Fixes #1604 ## Tests Updated e2e tests
1 parent 062bc78 commit d533397

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/databricks-vscode/resources/python/00-databricks-init.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,8 @@ def parse_line_for_databricks_magics(lines: List[str]):
338338
if len(lines) == 0:
339339
return lines
340340

341-
lines = [line for line in lines
342-
if line.strip() != "# Databricks notebook source" and \
343-
line.strip() != "# COMMAND ----------"
344-
]
341+
lines_to_ignore = ("# Databricks notebook source", "# COMMAND ----------", "# DBTITLE")
342+
lines = [line for line in lines if not line.strip().startswith(lines_to_ignore)]
345343
lines = ''.join(lines).strip().splitlines(keepends=True)
346344
lines = strip_hash_magic(lines)
347345

packages/databricks-vscode/src/test/e2e/run_notebooks_py.e2e.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe("Run py notebooks", async function () {
3232
"# Databricks notebook source",
3333
`spark.sql('SELECT "hello world"').show()`,
3434
"# COMMAND ----------",
35+
"# DBTITLE 1,My cell title",
3536
"# MAGIC %sh pwd",
3637
].join("\n")
3738
);

0 commit comments

Comments
 (0)