Skip to content

Commit 5aa34f9

Browse files
committed
Dev Container environment
Signed-off-by: Malo Jaffré <[email protected]>
1 parent a59f08d commit 5aa34f9

File tree

4 files changed

+80
-13
lines changed

4 files changed

+80
-13
lines changed

.devcontainer/devcontainer.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "dbt-databricks",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers-extra/features/hatch:2": {}
9+
},
10+
"postStartCommand": "./.devcontainer/initialize.sh",
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"ms-python.python",
15+
"charliermarsh.ruff",
16+
"ms-python.mypy-type-checker"
17+
],
18+
"settings": {
19+
"editor.formatOnSave": true,
20+
"editor.formatOnType": true,
21+
"editor.rulers": [
22+
100
23+
],
24+
"files.exclude": {
25+
".hatch": true,
26+
".mypy_cache": true,
27+
".pytest_cache": true,
28+
"**/__pycache__": true
29+
},
30+
"python.analysis.diagnosticMode": "workspace",
31+
"python.analysis.enablePytestSupport": true,
32+
"python.defaultInterpreterPath": ".hatch/bin/python",
33+
"python.envFile": "test.env",
34+
"python.testing.pytestEnabled": true,
35+
"python.languageServer": "Pylance",
36+
"ruff.fixAll": true,
37+
"ruff.format.args": [
38+
"--config=pyproject.toml"
39+
],
40+
"ruff.lint.args": [
41+
"--config=pyproject.toml"
42+
],
43+
"[python]": {
44+
"editor.defaultFormatter": "charliermarsh.ruff",
45+
"editor.codeActionsOnSave": {
46+
"source.organizeImports": "always",
47+
"source.fixAll": "always"
48+
}
49+
},
50+
}
51+
}
52+
},
53+
"containerEnv": {
54+
"WORKSPACE_FOLDER": "${containerWorkspaceFolder}"
55+
}
56+
}

.devcontainer/initialize.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -x
3+
4+
# Create the Hatch environment
5+
hatch env create
6+
7+
# Install pre-commit
8+
(hatch run setup-precommit && pre-commit gc) &
9+
10+
# Set up test.env file if it does not already exist
11+
if test -f ${WORKSPACE_FOLDER}/test.env; then
12+
cp ${WORKSPACE_FOLDER}/test.env.example ${WORKSPACE_FOLDER}/test.env
13+
fi
14+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ logs/
2020
*.sublime*
2121
.python-version
2222
.hatch
23+
databricks_demo

CONTRIBUTING.MD

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ We follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) with one exception:
5050

5151
### Linting
5252

53-
This project uses [Black](https://pypi.org/project/black/), [flake8](https://flake8.pycqa.org/en/latest/), and [mypy](https://www.mypy-lang.org/) for linting and static type checks. Run all three with the `linter` command and commit before opening your pull request.
54-
55-
```
56-
tox -e linter
57-
```
53+
This project uses [Ruff](https://docs.astral.sh/ruff/) and [mypy](https://www.mypy-lang.org/) for linting and static type checks.
5854

5955
To simplify reviews you can commit any format changes in a separate commit.
6056

@@ -118,21 +114,21 @@ If you set your `user.name` and `user.email` git configs, you can sign your comm
118114
Unit tests do not require a Databricks account. Please confirm that your pull request passes our unit test suite before opening a pull request.
119115

120116
```bash
121-
tox -e unit
117+
hatch run unit
122118
```
123119

124120
## Functional Tests
125121

126122
Functional tests require a Databricks account with access to a workspace containing three specific compute resources as detailed below.
127-
The `tox` commands to run each set of these tests appear below:
123+
The `hatch` commands to run each set of these tests appear below:
128124

129-
| Compute Type | Unity Catalog | Command |
130-
| ------------------- | ------------- | ----------------------------------------------- |
131-
| SQL Warehouse | Yes | `tox -e integration-databricks-uc-sql-endpoint` |
132-
| All Purpose Cluster | Yes | `tox -e integration-databricks-uc-cluster` |
133-
| All Purpose | No | `tox -e integration-databricks-cluster` |
125+
| Compute Type | Unity Catalog | Command |
126+
| ------------------- | ------------- | -------------------------- |
127+
| SQL Warehouse | Yes | `hatch run sqlw-e2e` |
128+
| All Purpose Cluster | Yes | `hatch run uc-cluster-e2e` |
129+
| All Purpose | No | `hatch run cluster-e2e` |
134130

135-
These tests are configured with environment variables that `tox` reads from a file called [test.env](/test.env.example) which you can copy from the example:
131+
These tests are configured with environment variables that `hatch` reads from a file called [test.env](/test.env.example) which you can copy from the example:
136132

137133
```sh
138134
cp test.env.example test.env

0 commit comments

Comments
 (0)