Skip to content

Commit d7bf7d9

Browse files
authored
Merge pull request #13 from frizzleqq/fix_test_notebook
Fix test notebook
2 parents 3e37836 + e479d9e commit d7bf7d9

17 files changed

Lines changed: 35 additions & 29 deletions

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The project is configured using `pyproject.toml` (Python specifics) and `databri
99
| Directory | Description |
1010
|-----------|-------------|
1111
| `.github/workflows` | CI/CD jobs to test and deploy bundle |
12-
| `dab_project` | Python project (Used in Databricks Workflow as Python-Wheel-Task) |
12+
| `src/dab_project` | Python project (Used in Databricks Workflow as Python-Wheel-Task) |
1313
| `dbt` | [dbt](https://github.com/dbt-labs/dbt-core) project<br/>* Used in Databricks Workflow as dbt-Task<br/>* dbt-Models used from https://github.com/dbt-labs/jaffle_shop_duckdb |
1414
| `resources` | Resources such as Databricks Workflows or Databricks Volumes/Schemas<br/>* Python-based workflow: https://docs.databricks.com/aws/en/dev-tools/bundles/python<br/>* YAML-based Workflow: https://docs.databricks.com/aws/en/dev-tools/bundles/resources#job |
1515
| `scripts` | Python script to setup groups, service principals and catalogs used in a Databricks (Free Edition) workspace |
@@ -131,19 +131,6 @@ uv run ./scripts/setup_workspace.py
131131
132132
## FAQ
133133
134-
* Why no `src` directory?
135-
136-
Working in Databricks Git Repos automatically adds the root of the Git Repo to Python `sys.path`.
137-
138-
This way Notebooks in the Git Repo can run `import dab_project` to import the local Python package during development without explicitly installing the package on the Cluster.
139-
140-
A Notebook outside the Git Repo can do `import os; os.chdir("/Workspace/Users/...")` to act like it is within the Git Repo.
141-
142-
Using a `src` directory requires changing the `sys.path` during development (without package installed) in a Databricks Git Repo.
143-
```python
144-
import sys
145-
sys.path.append("../src")
146-
```
147134
* Service Principals
148135
149136
For this example, the targets `test` and `prod` use a group and service principals.

databricks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ include:
1818

1919
sync:
2020
paths:
21-
- dab_project/
2221
- dbt/
2322
- resources/
23+
- src/
2424
- typings/
2525
- databricks.yml
2626
- pyproject.toml

pyproject.toml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,30 @@ dev = [
3838
[project.scripts]
3939
dab-project = "dab_project.cli:main"
4040

41-
[tool.uv.build-backend]
42-
module-name = "dab_project"
43-
module-root = ""
44-
4541
[[tool.mypy.overrides]]
4642
ignore_missing_imports = true
4743

4844
[tool.ruff]
4945
line-length = 100
5046
include = [
5147
"pyproject.toml",
52-
"dab_project/**/*.py",
48+
"src/**/*.py",
5349
"resources/**/*.py",
5450
"scripts/**/*.py",
5551
"tests/**/*.py",
5652
]
53+
exclude = [
54+
"tests/notebook_run_pytest.py"
55+
]
5756

5857
[tool.ruff.format]
5958
docstring-code-format = true
6059

6160
[tool.ruff.lint]
62-
exclude = ["scratch/**/*.py"]
61+
exclude = [
62+
"scratch/**/*.py",
63+
"tests/notebook_run_pytest.py"
64+
]
6365
select = [
6466
"E", # pycodestyle
6567
"W", # pycodestyle
@@ -82,6 +84,7 @@ line-length = 100
8284
target-version = ['py312']
8385

8486
[tool.pytest.ini_options]
87+
pythonpath = "src"
8588
addopts = "-ra -q"
8689
testpaths = [
8790
"tests",

scratch/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
# Notebooks
1+
# Scratch
22

3-
This folder contains Databricks Notebook style files (as `.py`).
3+
This folder is reserved for personal, exploratory notebooks.
4+
By default these are not committed to Git, as 'scratch' is listed in .gitignore.
45

5-
They access `dab_project` Python project, so it can be used as:
6-
* Databricks Git Repo
7-
* Local IDE (Project installed as 'editable')
6+
Using the `src` directory requires appending to the `sys.path`:
7+
8+
```python
9+
import sys
10+
sys.path.append("../src")
11+
```

0 commit comments

Comments
 (0)