You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Extra Efficiency, Optional But Recommended](#extra-efficiency-optional-but-recommended)
11
+
-[Pre-commit Hooks](#pre-commit-hooks)
12
+
-[Integration Tests](#integration-tests)
13
+
-[VSCode](#vscode)
14
+
-[Jupyter Extension](#jupyter-extension)
15
+
-[Debugger](#debugger)
16
+
-[MySQL CLI](#mysql-cli)
17
+
18
+
## Contribute to DataJoint Python Documentation
19
+
20
+
> Contributions to documentations are equivalently important to any code for the community, please help us to resolve any confusions in documentations.
21
+
22
+
[Here](https://github.com/datajoint/datajoint-python/blob/master/docs/README.md) is the instructions for contributing documentations, or you can find the same instructions at `$PROJECT_DIR/docs/README.md` in the repository.
23
+
24
+
[Back to top](#table-of-contents)
25
+
26
+
## Setup Development Environment
27
+
28
+
> We have [DevContainer](https://containers.dev/) ready for contributors to develop without setting up their environment. If you are familiar with DevContainer, Docker or Github Codespace, this is the recommended development environment for you.
29
+
> If you have never used Docker, it might be easier for you to use a virtual environment through `conda/mamba/venv`, it is also very straightforward to set up.
30
+
31
+
### Prerequisites
32
+
33
+
- Clone datajoint-python repository
34
+
35
+
```bash
36
+
# If you have your SSH key set up with GitHub, you can clone using SSH
- If you don't use DevContainer, then either install Anaconda/[Miniconda](https://www.anaconda.com/docs/getting-started/miniconda/install)/Mamba, or just use Python's built-in `venv` module without install anything else.
42
+
43
+
### With Virtual Environment
44
+
45
+
```bash
46
+
# Check if you have Python 3.9 or higher, if not please upgrade
47
+
python --version
48
+
# Create a virtual environment with venv
49
+
python -m venv .venv
50
+
source .venv/bin/activate
51
+
pip install -e .[dev]
52
+
53
+
# Or create a virtual environment with conda
54
+
conda create -n dj python=3.13 # any 3.9+ is fine
55
+
conda activate dj
56
+
pip install -e .[dev]
57
+
```
58
+
59
+
[Back to top](#table-of-contents)
60
+
61
+
### With DevContainer
62
+
63
+
#### Launch Environment
6
64
7
65
Here are some options that provide a great developer experience:
8
66
@@ -26,37 +84,48 @@ Here are some options that provide a great developer experience:
26
84
- Issue the following command in the terminal to build and run the Docker container: `HOST_UID=$(id -u) PY_VER=3.11 DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py) docker compose --profile test run --rm -it djtest -- sh -c 'pip install -qe ".[dev]" && bash'`
27
85
- Issue the following command in the terminal to stop the Docker compose stack: `docker compose --profile test down`
28
86
29
-
## Features
87
+
[Back to top](#table-of-contents)
30
88
31
-
Once you've successfully launched the development environment, you'll be able to take advantage of our developer tooling to help improve productivity and quality.
89
+
## Extra Efficiency, Optional But Recommended
32
90
33
-
### Syntax Tests
91
+
### Pre-commit Hooks
34
92
35
-
The following will verify that there are no syntax errors.
93
+
We recommend using [pre-commit](https://pre-commit.com/) to automatically run linters and formatters on your code before committing.
94
+
To set up pre-commit, run the following command in your terminal:
You can manually run pre-commit on all files with the following command:
102
+
103
+
```bash
104
+
pre-commit run --all-files
39
105
```
106
+
This will run all the linters and formatters specified in the `.pre-commit-config.yaml` file. If all check passed, you can commit your code. Otherwise, you need to fix the failed checks and run the command again.
40
107
41
-
### Integration Tests
108
+
> Pre-commit will automatically run the linters and formatters on all staged files before committing. However, if your code doesn't follow the linters and formatters, the commit will fail.
109
+
> Some hooks will automatically fix your problem, and add the fixed files as git's `unstaged` files, you just need to add them(`git add .`) to git's `staged` files and commit again.
110
+
> Some hooks will not automatically fix your problem, so you need to check the pre-commit failed log to fix them manually and include the update to your `staged` files and commit again.
42
111
43
-
The following will verify there are no regression errors by running our test suite of unit and integration tests.
112
+
If you really don't want to use pre-commit, or if you don't like it, you can uninstall it with the following command:
But when you issue a pull request, the same linter and formatter check will run against your contribution, you are going to have the same failure as well. So without pre-commit, you need to **manually run these linters and formatters before committing your code**:
119
+
120
+
- Syntax tests
121
+
122
+
The following will verify that there are no syntax errors.
Jupyter notebooks are supported in this environment. This means that when you `import datajoint`, it will use the current state of the source.
170
+
### VSCode
82
171
83
-
Be sure to see the reference documentation if you are new to [running Jupyter notebooks w/ VSCode](https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook).
172
+
#### Jupyter Extension
84
173
85
-
### Debugger
174
+
Be sure to go through this documentation if you are new to [Running Jupyter Notebooks with VSCode](https://code.visualstudio.com/docs/datascience/jupyter-notebooks#_create-or-open-a-jupyter-notebook).
175
+
176
+
#### Debugger
86
177
87
178
[VSCode Debugger](https://code.visualstudio.com/docs/editor/debugging) is a powerful tool that can really accelerate fixes.
88
179
@@ -94,8 +185,12 @@ Try it as follows:
94
185
- Select the `Run and Debug` tab
95
186
- Start by clicking the button `Run and Debug`
96
187
188
+
[Back to top](#table-of-contents)
189
+
97
190
### MySQL CLI
98
191
192
+
> Installation instruction is in [here](https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-install.html)
193
+
99
194
It is often useful in development to connect to DataJoint's relational database backend directly using the MySQL CLI.
100
195
101
196
Connect as follows to the database running within your developer environment:
@@ -104,23 +199,4 @@ Connect as follows to the database running within your developer environment:
104
199
mysql -hdb -uroot -ppassword
105
200
```
106
201
107
-
### Documentation
108
-
109
-
Our documentation is built using [MkDocs Material](https://squidfunk.github.io/mkdocs-material/). The easiest way to improve the documentation is by using the `docs/docker-compose.yaml` environment. The source can be modified in `docs/src` using markdown.
110
-
111
-
The docs environment can be run using 3 modes:
112
-
113
-
-**LIVE**: (*recommended*) This serves the docs locally. It supports live reloading on saves to `docs/src` files but does not support the docs version dropdown. Useful to see changes live.
When the docs are served locally, use the VSCode `PORTS` tab (next to `TERMINAL`) to manage access to the forwarded ports. Docs are served on port `8080`.
0 commit comments