-
Notifications
You must be signed in to change notification settings - Fork 122
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
Migrating to pyproject.toml and Hatch #853
Changes from 12 commits
3c36cae
b090883
318cd29
ac91225
e5bc096
bcdd0e0
a3741b0
b0611f8
90637c5
e6a963b
4b9059e
3d25b43
bc10666
356c7b2
d01cc9e
d63c53c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ concurrency: | |
cancel-in-progress: true | ||
|
||
jobs: | ||
run-tox-tests-uc-cluster: | ||
run-uc-cluster-e2e-tests: | ||
runs-on: ubuntu-latest | ||
environment: azure-prod | ||
env: | ||
|
@@ -26,22 +26,26 @@ jobs: | |
TEST_PECO_UC_CLUSTER_ID: ${{ secrets.TEST_PECO_UC_CLUSTER_ID }} | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.9" | ||
|
||
- name: Get http path from environment | ||
run: python .github/workflows/build_cluster_http_path.py | ||
shell: sh | ||
- name: Install tox | ||
|
||
- name: Install Hatch | ||
id: install-dependencies | ||
run: pip install tox | ||
- name: Run integration-uc-databricks-cluster | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH=$DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET tox -e integration-databricks-uc-cluster | ||
uses: pypa/hatch@install | ||
|
||
run-tox-tests-uc-sql: | ||
- name: Run UC Cluster Functional Tests | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH=$DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET hatch -v run uc-cluster-e2e | ||
|
||
run-sqlwarehouse-e2e-tests: | ||
runs-on: ubuntu-latest | ||
environment: azure-prod | ||
env: | ||
|
@@ -54,22 +58,26 @@ jobs: | |
TEST_PECO_UC_CLUSTER_ID: ${{ secrets.TEST_PECO_UC_CLUSTER_ID }} | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.9" | ||
|
||
- name: Get http path from environment | ||
run: python .github/workflows/build_cluster_http_path.py | ||
shell: sh | ||
- name: Install tox | ||
|
||
- name: Install Hatch | ||
id: install-dependencies | ||
run: pip install tox | ||
- name: Run integration-databricks-uc-sql-endpoint | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH=$DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET tox -e integration-databricks-uc-sql-endpoint | ||
uses: pypa/hatch@install | ||
|
||
- name: Run Sql Endpoint Functional Tests | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH=$DBT_DATABRICKS_UC_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET hatch -v run sqlw-e2e | ||
|
||
run-tox-tests-non-uc: | ||
run-cluster-e2e-tests: | ||
runs-on: ubuntu-latest | ||
environment: azure-prod | ||
env: | ||
|
@@ -79,17 +87,21 @@ jobs: | |
DBT_DATABRICKS_LOCATION_ROOT: ${{ secrets.TEST_PECO_EXTERNAL_LOCATION }}test | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.9" | ||
|
||
- name: Get http path from environment | ||
run: python .github/workflows/build_cluster_http_path.py | ||
shell: sh | ||
- name: Install tox | ||
|
||
- name: Install Hatch | ||
id: install-dependencies | ||
run: pip install tox | ||
- name: Run integration-databricks-cluster | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_HTTP_PATH=$DBT_DATABRICKS_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET tox -e integration-databricks-cluster | ||
uses: pypa/hatch@install | ||
|
||
- name: Run Cluster Functional Tests | ||
run: [email protected] DBT_DATABRICKS_LOCATION_ROOT=$DBT_DATABRICKS_LOCATION_ROOT DBT_DATABRICKS_HOST_NAME=$DBT_DATABRICKS_HOST_NAME DBT_DATABRICKS_HTTP_PATH=$DBT_DATABRICKS_CLUSTER_HTTP_PATH DBT_DATABRICKS_CLIENT_ID=$DBT_DATABRICKS_CLIENT_ID DBT_DATABRICKS_CLIENT_SECRET=$DBT_DATABRICKS_CLIENT_SECRET hatch -v run cluster-e2e |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,40 +42,28 @@ defaults: | |
|
||
jobs: | ||
code-quality: | ||
name: ${{ matrix.toxenv }} | ||
name: Code Quality | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
toxenv: [linter] | ||
|
||
env: | ||
TOXENV: ${{ matrix.toxenv }} | ||
PYTEST_ADDOPTS: "-v --color=yes" | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4.3.0 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install python dependencies | ||
run: | | ||
python -m pip install --user --upgrade pip | ||
python -m pip --version | ||
python -m pip install tox | ||
tox --version | ||
- name: Install Hatch | ||
uses: pypa/hatch@install | ||
|
||
- name: Run tox | ||
run: tox | ||
- name: Run Code Quality | ||
run: hatch -v run code-quality | ||
|
||
unit: | ||
name: unit test / python ${{ matrix.python-version }} | ||
|
@@ -88,131 +76,39 @@ jobs: | |
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
|
||
env: | ||
TOXENV: "unit" | ||
PYTEST_ADDOPTS: "-v --color=yes --csv unit_results.csv" | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4.3.0 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install python dependencies | ||
run: | | ||
python -m pip install --user --upgrade pip | ||
python -m pip --version | ||
python -m pip install tox | ||
tox --version | ||
- name: Run tox | ||
run: tox | ||
|
||
- name: Get current date | ||
if: always() | ||
id: date | ||
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H_%M_%S')" #no colons allowed for artifacts | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: unit_results_${{ matrix.python-version }}-${{ steps.date.outputs.date }}.csv | ||
path: unit_results.csv | ||
- name: Install Hatch | ||
uses: pypa/hatch@install | ||
|
||
build: | ||
name: build packages | ||
- name: Run Unit Tests | ||
run: hatch run -v +py=${{ matrix.python-version }} test:unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the |
||
|
||
build: | ||
name: Build and Verify Packages | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
is_alpha: ${{ steps.check-is-alpha.outputs.is_alpha }} | ||
|
||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4.3.0 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.9" | ||
|
||
- name: Install python dependencies | ||
run: | | ||
python -m pip install --user --upgrade pip | ||
python -m pip install --upgrade setuptools wheel twine check-wheel-contents | ||
python -m pip --version | ||
- name: Build distributions | ||
run: ./scripts/build-dist.sh | ||
|
||
- name: Show distributions | ||
run: ls -lh dist/ | ||
|
||
- name: Check distribution descriptions | ||
run: | | ||
twine check dist/* | ||
- name: Check wheel contents | ||
run: | | ||
check-wheel-contents dist/*.whl --ignore W007,W008 | ||
|
||
- name: Check if this is an alpha version | ||
id: check-is-alpha | ||
run: | | ||
export is_alpha=0 | ||
if [[ "$(ls -lh dist/)" == *"a1"* ]]; then export is_alpha=1; fi | ||
echo "::set-output name=is_alpha::$is_alpha" | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
test-build: | ||
name: verify packages / python ${{ matrix.python-version }} / ${{ matrix.os }} | ||
|
||
if: needs.build.outputs.is_alpha == 0 | ||
- name: Install Hatch | ||
uses: pypa/hatch@install | ||
|
||
needs: build | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/[email protected] | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Build distributions | ||
run: hatch -v build | ||
|
||
- name: Install python dependencies | ||
run: | | ||
python -m pip install --user --upgrade pip | ||
python -m pip install --upgrade wheel | ||
python -m pip --version | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Show distributions | ||
run: ls -lh dist/ | ||
|
||
- name: Install wheel distributions | ||
run: | | ||
find ./dist/*.whl -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ | ||
- name: Check wheel distributions | ||
run: | | ||
dbt --version | ||
- name: Install source distributions | ||
run: | | ||
find ./dist/*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ | ||
- name: Check source distributions | ||
run: | | ||
dbt --version | ||
- name: Verify distributions | ||
run: hatch run verify:check-all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does the same checks as before, but I'm no longer separating build and verify as separate tasks, just separate steps. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.8.0 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
# Run the formatter. | ||
- id: ruff-format | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.13.0 | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: [types-requests] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
- Fix behavior flag use in init of DatabricksAdapter (thanks @VersusFacit!) ([836](https://github.com/databricks/dbt-databricks/pull/836)) | ||
- Restrict pydantic to V1 per dbt Labs' request ([843](https://github.com/databricks/dbt-databricks/pull/843)) | ||
- Switching to Ruff for formatting and linting ([847](https://github.com/databricks/dbt-databricks/pull/847)) | ||
- Switching to Hatch and pyproject.toml for project config ([853](https://github.com/databricks/dbt-databricks/pull/853)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you have to bump the minor version of this change/migration? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would but this version hasn't been released yet. |
||
|
||
## dbt-databricks 1.8.7 (October 10, 2024) | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version: str = "1.9.0b1" | ||
version = "1.9.0b1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to drop the type info here to satisfy Hatch |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ | |
@dataclass | ||
class DatabricksConfig(AdapterConfig): | ||
file_format: str = "delta" | ||
table_format: TableFormat = TableFormat.DEFAULT | ||
table_format: str = TableFormat.DEFAULT | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on 3.12, mypy starts complaining that these enums actually inherit str, so their values are str. |
||
location_root: Optional[str] = None | ||
include_full_name_in_path: bool = False | ||
partition_by: Optional[Union[list[str], str]] = None | ||
|
@@ -764,7 +764,7 @@ class RelationAPIBase(ABC, Generic[DatabricksRelationConfig]): | |
For the most part, these are just namespaces to group related methods together. | ||
""" | ||
|
||
relation_type: ClassVar[DatabricksRelationType] | ||
relation_type: ClassVar[str] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same str, enum issue as above. |
||
|
||
@classmethod | ||
@abstractmethod | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like Tox, installing Hatch is sufficient to install everything else