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
+57-59
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,17 @@
1
1
## Python development setup
2
+
2
3
---
3
4
4
5
- Fork and clone the repository
5
6
6
-
- Create a new Python environment with your favourite environment manager, e.g. virtualenv or conda
7
+
- Create a new Python environment with your favourite environment manager (e.g. virtualenv or conda) and Python 3.9 (newer versions will return a library conflict in `auto_doc.py`)
7
8
8
9
- Install repository in editable mode with development dependencies:
9
10
10
-
```bash
11
-
cd python
12
-
pip install -e ".[dev]"
13
-
```
11
+
```bash
12
+
cd python
13
+
pip install -e ".[dev]"
14
+
```
14
15
15
16
- 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 [ruff](https://docs.astral.sh/ruff/). Run the following commands from the `python` directory:
16
17
@@ -37,110 +38,104 @@ We follow a few best practices for writing the Python documentation:
37
38
38
39
1. Use the google docstring style:
39
40
40
-
```python
41
-
"""[One Line Summary]
41
+
```python
42
+
"""[One Line Summary]
42
43
43
-
[Extended Summary]
44
+
[Extended Summary]
44
45
45
-
[!!! example
46
-
import xyz
47
-
]
46
+
[!!! example
47
+
import xyz
48
+
]
48
49
49
-
# Arguments
50
-
arg1: Type[, optional]. Description[, defaults to `default`]
51
-
arg2: Type[, optional]. Description[, defaults to `default`]
50
+
# Arguments
51
+
arg1: Type[, optional]. Description[, defaults to `default`]
52
+
arg2: Type[, optional]. Description[, defaults to `default`]
52
53
53
-
# Returns
54
-
Type. Description.
54
+
# Returns
55
+
Type. Description.
55
56
56
-
# Raises
57
-
Exception. Description.
58
-
"""
59
-
```
60
-
61
-
If Python 3 type annotations are used, they are inserted automatically.
57
+
# Raises
58
+
Exception. Description.
59
+
"""
60
+
```
62
61
62
+
If Python 3 type annotations are used, they are inserted automatically.
63
63
64
64
2. Hopsworks entity engine methods (e.g. ExecutionEngine etc.) only require a single line docstring.
65
-
3. Private REST Api implementations (e.g. GitRemoteApi etc.) should be fully documented with docstrings without defaults.
66
-
4. Public Api such as metadata objects and public REST Api implementations should be fully documented with defaults.
65
+
3. Private REST API implementations (e.g. FeatureGroupApi etc.) should be fully documented with docstrings without defaults.
66
+
4. Public API such as metadata objects and public REST API implementations should be fully documented with defaults.
67
67
68
68
#### Setup and Build Documentation
69
69
70
70
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.
71
71
72
72
**Background about `mike`:**
73
-
`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
+
`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.
74
74
75
-
1. Currently we are using our own version of `keras-autodoc`
2. To build the docs, first run the auto doc script:
86
82
87
-
3. To build the docs, first run the auto doc script:
88
-
89
-
```bash
90
-
cd ..
91
-
python auto_doc.py
92
-
```
83
+
```bash
84
+
python auto_doc.py
85
+
```
93
86
94
87
##### Option 1: Build only current version of docs
95
88
96
-
4. Either build the docs, or serve them dynamically:
89
+
3. Either build the docs, or serve them dynamically:
97
90
98
-
Note: Links and pictures might not resolve properly later on when checking with this build.
99
-
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
100
-
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
101
-
Using relative links should not be affected by this, however, building the docs with version
102
-
(Option 2) is recommended.
91
+
Note: Links and pictures might not resolve properly later on when checking with this build.
92
+
The reason for that is that the docs are deployed with versioning on docs.hopsworks.ai and
93
+
therefore another level is added to all paths, e.g. `docs.hopsworks.ai/[version-or-alias]`.
94
+
Using relative links should not be affected by this, however, building the docs with version
95
+
(Option 2) is recommended.
103
96
104
-
```bash
105
-
mkdocs build
106
-
# or
107
-
mkdocs serve
108
-
```
97
+
```bash
98
+
mkdocs build
99
+
# or
100
+
mkdocs serve
101
+
```
109
102
110
103
##### Option 2 (Preferred): Build multi-version doc with `mike`
111
104
112
105
###### Versioning on docs.hopsworks.ai
113
106
114
107
On docs.hopsworks.ai we implement the following versioning scheme:
115
108
116
-
- current master branches (e.g. of hopsworks corresponding to master of Hopsworks): rendered as current Hopsworks snapshot version, e.g. **3.1.0-SNAPSHOT [dev]**, where `dev` is an alias to indicate that this is an unstable version.
117
-
- the latest release: rendered with full current version, e.g. **3.0.1 [latest]** with `latest`alias to indicate that this is the latest stable release.
118
-
- previous stable releases: rendered without alias, e.g. **3.0.0**.
109
+
- current master branches (e.g. of hopsworks corresponding to master of Hopsworks): rendered as current Hopsworks snapshot version, e.g. **4.0.0-SNAPSHOT [dev]**, where `dev` is an alias to indicate that this is an unstable version.
110
+
- the latest release: rendered with full current version, e.g. **3.8.0[latest]** with `latest` alias to indicate that this is the latest stable release.
111
+
- previous stable releases: rendered without alias, e.g. **3.4.4**.
119
112
120
113
###### Build Instructions
121
114
122
-
4. For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where
123
-
`mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
115
+
4. For this you can either checkout and make a local copy of the `upstream/gh-pages` branch, where `mike` maintains the current state of docs.hopsworks.ai, or just build documentation for the branch you are updating:
124
116
125
117
Building *one* branch:
126
118
127
119
Checkout your dev branch with modified docs:
120
+
128
121
```bash
129
122
git checkout [dev-branch]
130
123
```
131
124
132
125
Generate API docs if necessary:
126
+
133
127
```bash
134
128
python auto_doc.py
135
129
```
136
130
137
131
Build docs with a version and alias
132
+
138
133
```bash
139
134
mike deploy [version] [alias] --update-alias
140
135
141
136
# for example, if you are updating documentation to be merged to master,
142
137
# which will become the new SNAPSHOT version:
143
-
mike deploy 3.1.0-SNAPSHOT dev --update-alias
138
+
mike deploy 4.0.0-SNAPSHOT dev --update-alias
144
139
145
140
# if you are updating docs of the latest stable release branch
146
141
mike deploy [version] latest --update-alias
@@ -158,17 +153,20 @@ On docs.hopsworks.ai we implement the following versioning scheme:
158
153
```
159
154
160
155
You can now checkout the gh-pages branch and serve:
156
+
161
157
```bash
162
158
git checkout gh-pages
163
159
mike serve
164
160
```
165
161
166
162
You can also list all available versions/aliases:
163
+
167
164
```bash
168
165
mike list
169
166
```
170
167
171
168
Delete and reset your local gh-pages branch:
169
+
172
170
```bash
173
171
mike delete --all
174
172
@@ -194,7 +192,7 @@ PAGES = {
194
192
195
193
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:
196
194
197
-
```
195
+
````
198
196
## The XYZ package
199
197
200
198
{{module}}
@@ -207,7 +205,7 @@ Some extra content here.
207
205
```
208
206
209
207
{{xyz.asd}}
210
-
```
208
+
````
211
209
212
210
Finally, run the `auto_doc.py` script, as decribed above, to update the documentation.
0 commit comments