-
Notifications
You must be signed in to change notification settings - Fork 66
linting, type safety, and CI pipeline #265
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4733458
add check_snake_case.py lint script and pre-commit hook
domino-blake 0ff6ae9
Updated flake8 config so that it works
domino-blake 5aa6ed4
pep8/ruff fixing some incosistencies
domino-blake 5d76de0
update pre-commit hook versions to latest
domino-blake ee1ea1d
resolve all flake8,isort,black errors across the codebase
domino-blake c37140a
resolve all 38 pre-existing mypy type errors
domino-blake 4e5012c
add GitHub Actions workflow and update test infrastructure
domino-blake dc8ebb0
Updated to correct package
domino-blake 1bc21d5
linting
domino-blake 420a97c
linting
domino-blake 2f3722f
reapply mypy type fixes lost during cherry-pick conflict resolution
domino-blake c62bd5e
linting
domino-blake 16f6925
reapply mypy fixes and remove snake_case CI check
domino-blake 95999da
#265 Addressing comments in PR
domino-blake File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,26 @@ | ||
| [flake8] | ||
| max-complexity = 33 | ||
| # Default plus E266 - There should be only one leading # for a block comment | ||
| max-complexity = 34 | ||
| ignore = | ||
| E121, # A line is less indented than it should be for hanging indents | ||
| E123, # Closing brackets should match the same indentation level of the line that their opening bracket started on | ||
| E126, # A continuation line is indented farther than it should be for a hanging indent | ||
| E226, # There should be one space before and after an arithmetic operator (+, -, /, and *) | ||
| E704, # Multiple statements of a function definition should be on their own separate lines | ||
| W503, # Line breaks should occur after the binary operator to keep all variable names aligned | ||
| W504, # Line breaks should occur before the binary operator to keep all operators aligned | ||
| E266, # There should be only one leading # for a block comment | ||
| E203, # Colons should not have any space before them | ||
| E501, # Line lengths are recommended to be no greater than 79 characters | ||
| # A line is less indented than it should be for hanging indents | ||
| E121, | ||
| # Closing brackets should match the same indentation level | ||
| E123, | ||
| # A continuation line is indented farther than it should be | ||
| E126, | ||
| # There should be one space before and after an arithmetic operator | ||
| E226, | ||
| # Multiple statements of a function definition should be on their own lines | ||
| E704, | ||
| # Line breaks should occur after the binary operator | ||
| W503, | ||
| # Line breaks should occur before the binary operator | ||
| W504, | ||
| # There should be only one leading # for a block comment | ||
| E266, | ||
| # Colons should not have any space before them | ||
| E203, | ||
| # Line lengths are recommended to be no greater than 79 characters | ||
| E501, | ||
| per-file-ignores = | ||
| # Auto-generated OpenAPI client — forward-reference annotations flagged as undefined | ||
| domino/_impl/custommetrics/*.py: F821 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install lint tools | ||
| run: pip install black==25.1.0 isort==5.13.2 "flake8==7.2.0" | ||
|
|
||
| - name: black | ||
| run: black --check . | ||
|
|
||
| - name: isort | ||
| run: isort --check . | ||
|
|
||
| - name: flake8 | ||
| run: flake8 . | ||
|
|
||
|
|
||
| typecheck: | ||
| name: Type check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install package and type stubs | ||
| run: | | ||
| pip install -e . | ||
| pip install "mypy==1.15.0" \ | ||
| types-pyyaml \ | ||
| types-requests \ | ||
| types-retry \ | ||
| types-pytz \ | ||
| types-tabulate \ | ||
| types-python-dateutil \ | ||
| types-redis \ | ||
| types-protobuf \ | ||
| types-frozendict \ | ||
| types-urllib3 | ||
|
|
||
| - name: mypy | ||
| run: | | ||
| mypy domino/ \ | ||
| --no-warn-no-return \ | ||
| --namespace-packages \ | ||
| --explicit-package-bases \ | ||
| --ignore-missing-imports \ | ||
| --follow-imports=silent \ | ||
| --python-version=3.10 | ||
|
|
||
| test: | ||
| name: Test (Python ${{ matrix.python-version }}) | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install -e . | ||
| pip install pytest pytest-cov requests-mock docker pytest-mock | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| pytest tests/ \ | ||
| --ignore=tests/agents \ | ||
| --ignore=tests/integration \ | ||
| --ignore=tests/scripts \ | ||
| --ignore=tests/test_operator.py \ | ||
| --ignore=tests/test_spark_operator.py \ | ||
| -v --tb=short \ | ||
| --cov=domino \ | ||
| --cov-report=xml \ | ||
| --cov-report=term-missing | ||
|
|
||
| - name: Upload coverage report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: coverage-${{ matrix.python-version }} | ||
| path: coverage.xml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Contributing | ||
|
|
||
| ## Running checks locally | ||
|
|
||
| The CI pipeline runs four categories of checks. You can run all of them locally before pushing. | ||
|
|
||
| ### Formatting (auto-fixable) | ||
|
|
||
| `black` and `isort` can reformat your code in place: | ||
|
|
||
| ```bash | ||
| pip install black==25.1.0 isort==5.13.2 | ||
|
|
||
| # auto-fix | ||
| black . | ||
| isort . | ||
|
|
||
| # check only (what CI does) | ||
| black --check . | ||
| isort --check . | ||
| ``` | ||
|
|
||
| ### Linting | ||
|
|
||
| ```bash | ||
| pip install "flake8==7.2.0" | ||
| flake8 . | ||
| ``` | ||
|
|
||
| flake8 does not auto-fix. Check `.flake8` for project-specific rules (ignored codes, max line length, complexity threshold). | ||
|
|
||
| ### Type checking | ||
|
|
||
| ```bash | ||
| pip install -e . | ||
| pip install "mypy==1.15.0" \ | ||
| types-pyyaml types-requests types-retry types-pytz \ | ||
| types-tabulate types-python-dateutil types-redis \ | ||
| types-protobuf types-frozendict types-urllib3 | ||
|
|
||
| mypy domino/ \ | ||
| --no-warn-no-return \ | ||
| --namespace-packages \ | ||
| --explicit-package-bases \ | ||
| --ignore-missing-imports \ | ||
| --follow-imports=silent \ | ||
| --python-version=3.10 | ||
| ``` | ||
|
|
||
| ### Snake case (new parameters only) | ||
|
|
||
| A lightweight AST check ensures new parameters in `domino/` use `snake_case`: | ||
|
|
||
| ```bash | ||
| python scripts/check_snake_case.py domino/domino.py | ||
| ``` | ||
|
|
||
| This check is scoped to `domino/` source files only and ignores existing camelCase parameters that are kept for backwards compatibility. | ||
|
|
||
| ### Tests | ||
|
|
||
| ```bash | ||
| pip install pytest pytest-cov requests-mock docker pytest-mock | ||
| pytest tests/ \ | ||
| --ignore=tests/agents \ | ||
| --ignore=tests/integration \ | ||
| --ignore=tests/scripts \ | ||
| --ignore=tests/test_operator.py \ | ||
| --ignore=tests/test_spark_operator.py \ | ||
| -v --tb=short | ||
| ``` | ||
|
|
||
| The ignored paths either require a live Domino deployment (`tests/integration`) or optional dependencies not installed by default (`tests/agents`, `tests/test_operator.py`, and `tests/test_spark_operator.py` require `apache-airflow` or the tracing extras). | ||
|
|
||
| ### Pre-commit (optional) | ||
|
|
||
| You can run all checks automatically on every commit by installing the pre-commit hooks: | ||
|
|
||
| ```bash | ||
| pip install pre-commit | ||
| pre-commit install | ||
| ``` | ||
|
|
||
| To run them manually against all files: | ||
|
|
||
| ```bash | ||
| pre-commit run --all-files | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.