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
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+96-96
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
1
## Python development setup
2
-
3
2
---
4
3
5
4
- Fork and clone the repository
@@ -8,57 +7,58 @@
8
7
9
8
- Install repository in editable mode with development dependencies:
10
9
11
-
```bash
12
-
cd python
13
-
pip install -e ".[dev]"
14
-
```
10
+
```bash
11
+
cd python
12
+
pip install -e ".[dev]"
13
+
```
15
14
16
15
- Install [pre-commit](https://pre-commit.com/) and then activate its hooks. pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. The library uses pre-commit to ensure code-style and code formatting through [black](https://github.com/psf/black) and [flake8](https://gitlab.com/pycqa/flake8). Run the following commands from the `python` directory:
17
16
18
-
```bash
19
-
cd python
20
-
pip install --user pre-commit
21
-
pre-commit install
22
-
```
17
+
```bash
18
+
cd python
19
+
pip install --user pre-commit
20
+
pre-commit install
21
+
```
23
22
24
23
Afterwards, pre-commit will run whenever you commit.
25
24
26
25
- To run formatting and code-style separately, you can configure your IDE, such as VSCode, to use black and flake8, or run them via the command line:
27
26
28
-
```bash
29
-
cd python
30
-
flake8 hopsworks
31
-
black hopsworks
32
-
```
27
+
```bash
28
+
cd python
29
+
flake8 hopsworks
30
+
black hopsworks
31
+
```
33
32
34
33
### Python documentation
35
34
36
35
We follow a few best practices for writing the Python documentation:
37
36
38
37
1. Use the google docstring style:
39
38
40
-
```python
41
-
"""[One Line Summary]
39
+
```python
40
+
"""[One Line Summary]
42
41
43
-
[Extended Summary]
42
+
[Extended Summary]
44
43
45
-
[!!! example
46
-
import xyz
47
-
]
44
+
[!!! example
45
+
import xyz
46
+
]
48
47
49
-
# Arguments
50
-
arg1: Type[, optional]. Description[, defaults to `default`]
51
-
arg2: Type[, optional]. Description[, defaults to `default`]
48
+
# Arguments
49
+
arg1: Type[, optional]. Description[, defaults to `default`]
50
+
arg2: Type[, optional]. Description[, defaults to `default`]
52
51
53
-
# Returns
54
-
Type. Description.
52
+
# Returns
53
+
Type. Description.
55
54
56
-
# Raises
57
-
Exception. Description.
58
-
"""
59
-
```
55
+
# Raises
56
+
Exception. Description.
57
+
"""
58
+
```
59
+
60
+
If Python 3 type annotations are used, they are inserted automatically.
60
61
61
-
If Python 3 type annotations are used, they are inserted automatically.
62
62
63
63
2. Hopsworks entity engine methods (e.g. ExecutionEngine etc.) only require a single line docstring.
64
64
3. Private REST Api implementations (e.g. GitRemoteApi etc.) should be fully documented with docstrings without defaults.
@@ -69,42 +69,42 @@ We follow a few best practices for writing the Python documentation:
69
69
We use `mkdocs` together with `mike` ([for versioning](https://github.com/jimporter/mike/)) to build the documentation and a plugin called `keras-autodoc` to auto generate Python API documentation from docstrings.
70
70
71
71
**Background about `mike`:**
72
-
`mike` builds the documentation and commits it as a new directory to the gh-pages branch. Each directory corresponds to one version of the documentation. Additionally, `mike` maintains a json in the root of gh-pages with the mappings of versions/aliases for each of the directories available. With aliases you can define extra names like `dev` or `latest`, to indicate stable and unstable releases.
72
+
`mike` builds the documentation and commits it as a new directory to the gh-pages branch. Each directory corresponds to one version of the documentation. Additionally, `mike` maintains a json in the root of gh-pages with the mappings of versions/aliases for each of the directories available. With aliases you can define extra names like `dev` or `latest`, to indicate stable and unstable releases.
73
73
74
74
1. Currently we are using our own version of `keras-autodoc`
3. To build the docs, first run the auto doc script:
87
87
88
-
```bash
89
-
cd ..
90
-
python auto_doc.py
91
-
```
88
+
```bash
89
+
cd ..
90
+
python auto_doc.py
91
+
```
92
92
93
93
##### Option 1: Build only current version of docs
94
94
95
95
4. Either build the docs, or serve them dynamically:
96
96
97
-
Note: Links and pictures might not resolve properly later on when checking with this build.
98
-
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
99
-
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
100
-
Using relative links should not be affected by this, however, building the docs with version
101
-
(Option 2) is recommended.
97
+
Note: Links and pictures might not resolve properly later on when checking with this build.
98
+
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
99
+
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
100
+
Using relative links should not be affected by this, however, building the docs with version
101
+
(Option 2) is recommended.
102
102
103
-
```bash
104
-
mkdocs build
105
-
# or
106
-
mkdocs serve
107
-
```
103
+
```bash
104
+
mkdocs build
105
+
# or
106
+
mkdocs serve
107
+
```
108
108
109
109
##### Option 2 (Preferred): Build multi-version doc with `mike`
110
110
@@ -118,62 +118,62 @@ On docs.hopsworks.ai we implement the following versioning scheme:
118
118
119
119
###### Build Instructions
120
120
121
-
4.For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where
122
-
`mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
121
+
4. For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where
122
+
`mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
123
123
124
-
Building *one* branch:
124
+
Building *one* branch:
125
125
126
-
Checkout your dev branch with modified docs:
127
-
```bash
128
-
git checkout [dev-branch]
129
-
```
126
+
Checkout your dev branch with modified docs:
127
+
```bash
128
+
git checkout [dev-branch]
129
+
```
130
130
131
-
Generate API docs if necessary:
132
-
```bash
133
-
python auto_doc.py
134
-
```
131
+
Generate API docs if necessary:
132
+
```bash
133
+
python auto_doc.py
134
+
```
135
135
136
-
Build docs with a version and alias
137
-
```bash
138
-
mike deploy [version] [alias] --update-alias
136
+
Build docs with a version and alias
137
+
```bash
138
+
mike deploy [version] [alias] --update-alias
139
139
140
-
# for example, if you are updating documentation to be merged to master,
141
-
# which will become the new SNAPSHOT version:
142
-
mike deploy 3.1.0-SNAPSHOT dev --update-alias
140
+
# for example, if you are updating documentation to be merged to master,
141
+
# which will become the new SNAPSHOT version:
142
+
mike deploy 3.1.0-SNAPSHOT dev --update-alias
143
143
144
-
# if you are updating docs of the latest stable release branch
145
-
mike deploy [version] latest --update-alias
144
+
# if you are updating docs of the latest stable release branch
145
+
mike deploy [version] latest --update-alias
146
146
147
-
# if you are updating docs of a previous stable release branch
148
-
mike deploy [version]
149
-
```
147
+
# if you are updating docs of a previous stable release branch
148
+
mike deploy [version]
149
+
```
150
150
151
-
If no gh-pages branch existed in your local repository, this will have created it.
151
+
If no gh-pages branch existed in your local repository, this will have created it.
152
152
153
-
**Important**: If no previous docs were built, you will have to choose a version as default to be loaded as index, as follows
153
+
**Important**: If no previous docs were built, you will have to choose a version as default to be loaded as index, as follows
154
154
155
-
```bash
156
-
mike set-default [version-or-alias]
157
-
```
155
+
```bash
156
+
mike set-default [version-or-alias]
157
+
```
158
158
159
-
You can now checkout the gh-pages branch and serve:
160
-
```bash
161
-
git checkout gh-pages
162
-
mike serve
163
-
```
159
+
You can now checkout the gh-pages branch and serve:
160
+
```bash
161
+
git checkout gh-pages
162
+
mike serve
163
+
```
164
164
165
-
You can also list all available versions/aliases:
166
-
```bash
167
-
mike list
168
-
```
165
+
You can also list all available versions/aliases:
166
+
```bash
167
+
mike list
168
+
```
169
169
170
-
Delete and reset your local gh-pages branch:
171
-
```bash
172
-
mike delete --all
170
+
Delete and reset your local gh-pages branch:
171
+
```bash
172
+
mike delete --all
173
173
174
-
# or delete single version
175
-
mike delete [version-or-alias]
176
-
```
174
+
# or delete single version
175
+
mike delete [version-or-alias]
176
+
```
177
177
178
178
#### Adding new API documentation
179
179
@@ -193,7 +193,7 @@ PAGES = {
193
193
194
194
Now you can add a template markdown file to the `docs/templates` directory with the name you specified in the auto-doc script. The `new_template.md` file should contain a tag to identify the place at which the API documentation should be inserted:
195
195
196
-
````
196
+
```
197
197
## The XYZ package
198
198
199
199
{{module}}
@@ -206,7 +206,7 @@ Some extra content here.
206
206
```
207
207
208
208
{{xyz.asd}}
209
-
````
209
+
```
210
210
211
211
Finally, run the `auto_doc.py` script, as decribed above, to update the documentation.
0 commit comments