-
Notifications
You must be signed in to change notification settings - Fork 17
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
Implement hatch #21
Implement hatch #21
Changes from all commits
285b65b
bfcafc1
5c4602e
f60c8da
29930d8
b6eeeb8
d09a638
67e14c8
642838d
d4b7873
c0a2afc
a307556
6155bcf
430bd5a
9b40c70
9c1c1da
6c251e2
96d673c
7dc2172
98cbd78
0cbbf70
8a282c6
3cc8d27
56af7ea
47c223a
4bbd60b
d11d66a
3340a3c
735000d
9f16407
415b794
e41d60f
cc28c49
293c02c
2462ea1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Setup Python env | ||
description: Install Python & Hatch | ||
inputs: | ||
python-version: | ||
description: 'Version of Python to Install' | ||
required: true | ||
default: '3.9' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: "Set up Python ${{ inputs.python-version }}" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "${{ inputs.python-version }}" | ||
|
||
- name: Install Hatch | ||
shell: bash | ||
run: | | ||
python -m pip install --user --upgrade pip | ||
python -m pip install hatch |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ There are some tools that will be helpful to you in developing locally. While th | |
|
||
These are the tools used in `dbt-common` development and testing: | ||
|
||
- [`hatch`](https://hatch.pypa.io/latest/) for project management | ||
- [`flake8`](https://flake8.pycqa.org/en/latest/) for code linting | ||
- [`black`](https://github.com/psf/black) for code formatting | ||
- [`mypy`](https://mypy.readthedocs.io/en/stable/) for static type checking | ||
|
@@ -62,31 +63,15 @@ These are the tools used in `dbt-common` development and testing: | |
|
||
A deep understanding of these tools in not required to effectively contribute to `dbt-common`, but we recommend checking out the attached documentation if you're interested in learning more about each one. | ||
|
||
#### Virtual environments | ||
|
||
We strongly recommend using virtual environments when developing code in `dbt-common`. We recommend creating this virtualenv | ||
in the root of the `dbt-common` repository. To create a new virtualenv, run: | ||
```sh | ||
python3 -m venv env | ||
source env/bin/activate | ||
``` | ||
|
||
This will create and activate a new Python virtual environment. | ||
|
||
## Running `dbt-common` in development | ||
|
||
### Installation | ||
|
||
First make sure that you set up your `virtualenv` as described in [Setting up an environment](#setting-up-an-environment). Also ensure you have the latest version of pip installed with `pip install --upgrade pip`. Next, install `dbt-common` (and its dependencies): | ||
|
||
```sh | ||
git | ||
pre-commit install | ||
``` | ||
Ensure you have the latest version of pip installed with `pip install --upgrade pip` as well as [hatch](https://hatch.pypa.io/latest/install/). | ||
mikealfare marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Running `dbt-common` | ||
|
||
This repository is just a template and cannot be run. | ||
This repository cannot be run on its own. | ||
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'm not sure that this is entirely true. I think it just has very specific use cases that make it less valuable outside of the dbt ecosystem. I'm arguing semantics, but I think the distinction we're looking for is that between a library and an application. |
||
|
||
## Testing | ||
|
||
|
@@ -98,29 +83,31 @@ Once you're able to manually test that your code change is working as expected, | |
|
||
### Initial setup | ||
|
||
None needed. | ||
|
||
### Test commands | ||
- [Install pre-commit](https://pre-commit.com/#usage) | ||
emmyoop marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- [Install hatch](https://hatch.pypa.io/1.7/install/#pip) | ||
|
||
No tests included. | ||
- Nothing needed to set up your environments. hatch will create your environment as defined in the `pyproject.toml` when you run. | ||
|
||
### Hatch Commands | ||
|
||
### Unit, Integration, Functional? | ||
See the pyproject.toml for a complete list of custom commands. See the h[atch docs](https://hatch.pypa.io/latest/cli/reference/) for a description of built in commands and flags. | ||
|
||
Here are some general rules for adding tests: | ||
* unit tests (`tests/unit`) don’t need to access a database; "pure Python" tests should be written as unit tests | ||
* functional tests (`tests/functional`) cover anything that interacts with a database, namely adapter | ||
Run `hatch env show` to view a list of all envoronments and all commands available within them. | ||
|
||
## Debugging | ||
Example uses: | ||
|
||
1. The logs for a `dbt run` have stack traces and other information for debugging errors (in `logs/dbt.log` in your project directory). | ||
2. Try using a debugger, like `ipdb`. For pytest: `--pdb --pdbcls=IPython.terminal.debugger:pdb` | ||
3. | ||
|Type|Command|Description| | ||
emmyoop marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|---|---|---| | ||
|Utility|`hatch run proto`|regenerate protobuf definitions| | ||
|Testing|`hatch run test:unit`|run all tests| | ||
|Code Quality|`hatch run lint:all`|run black, flake8 and mypy checks| | ||
|Code Quality|`hatch run lint:black`|run black| | ||
|Shell|`hatch shell`|Drops you into the default shell with project + dev requirements installed. Use `exit` to leave the shell, _not_ `deactivate`.| | ||
|Shell|`hatch -e <environment-name> shell`|Drops you into a shell of the specified environment. Use `exit` to leave the shell, _not_ `deactivate`.| | ||
|
||
### Assorted development tips | ||
* Append `# type: ignore` to the end of a line if you need to disable `mypy` on that line. | ||
* Sometimes flake8 complains about lines that are actually fine, in which case you can put a comment on the line such as: # noqa or # noqa: ANNN, where ANNN is the error code that flake8 issues. | ||
* To collect output for `CProfile`, run dbt with the `-r` option and the name of an output file, i.e. `dbt -r dbt.cprof run`. If you just want to profile parsing, you can do: `dbt -r dbt.cprof parse`. `pip` install `snakeviz` to view the output. Run `snakeviz dbt.cprof` and output will be rendered in a browser window. | ||
|
||
## Adding or modifying a CHANGELOG Entry | ||
|
||
|
This file was deleted.
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.
Why would we install pre-commit in CI? I'm probably answering my own question, but is it to catch the eof and trailing whitespace issues?
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.
You are indeed answering your own question.