Skip to content

Commit cf0e015

Browse files
committed
Merge CONTRIBUTING
1 parent 13fd742 commit cf0e015

File tree

3 files changed

+57
-494
lines changed

3 files changed

+57
-494
lines changed

CONTRIBUTING.md

+57-59
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
## Python development setup
2+
23
---
34

45
- Fork and clone the repository
56

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`)
78

89
- Install repository in editable mode with development dependencies:
910

10-
```bash
11-
cd python
12-
pip install -e ".[dev]"
13-
```
11+
```bash
12+
cd python
13+
pip install -e ".[dev]"
14+
```
1415

1516
- 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:
1617

@@ -37,110 +38,104 @@ We follow a few best practices for writing the Python documentation:
3738

3839
1. Use the google docstring style:
3940

40-
```python
41-
"""[One Line Summary]
41+
```python
42+
"""[One Line Summary]
4243
43-
[Extended Summary]
44+
[Extended Summary]
4445
45-
[!!! example
46-
import xyz
47-
]
46+
[!!! example
47+
import xyz
48+
]
4849
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`]
5253
53-
# Returns
54-
Type. Description.
54+
# Returns
55+
Type. Description.
5556
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+
```
6261

62+
If Python 3 type annotations are used, they are inserted automatically.
6363

6464
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.
6767

6868
#### Setup and Build Documentation
6969

7070
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.
7171

7272
**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.
7474

75-
1. Currently we are using our own version of `keras-autodoc`
75+
1. Install Hopsworks with `dev-docs` extras:
7676

77-
```bash
78-
pip install git+https://github.com/logicalclocks/keras-autodoc
79-
```
77+
```bash
78+
pip install -e ".[dev-docs]"
79+
```
8080

81-
2. Install HOPSWORKS with `docs` extras:
82-
83-
```bash
84-
pip install -e .[dev,docs]
85-
```
81+
2. To build the docs, first run the auto doc script:
8682

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+
```
9386

9487
##### Option 1: Build only current version of docs
9588

96-
4. Either build the docs, or serve them dynamically:
89+
3. Either build the docs, or serve them dynamically:
9790

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.
10396

104-
```bash
105-
mkdocs build
106-
# or
107-
mkdocs serve
108-
```
97+
```bash
98+
mkdocs build
99+
# or
100+
mkdocs serve
101+
```
109102

110103
##### Option 2 (Preferred): Build multi-version doc with `mike`
111104

112105
###### Versioning on docs.hopsworks.ai
113106

114107
On docs.hopsworks.ai we implement the following versioning scheme:
115108

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**.
119112

120113
###### Build Instructions
121114

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:
124116

125117
Building *one* branch:
126118

127119
Checkout your dev branch with modified docs:
120+
128121
```bash
129122
git checkout [dev-branch]
130123
```
131124

132125
Generate API docs if necessary:
126+
133127
```bash
134128
python auto_doc.py
135129
```
136130

137131
Build docs with a version and alias
132+
138133
```bash
139134
mike deploy [version] [alias] --update-alias
140135
141136
# for example, if you are updating documentation to be merged to master,
142137
# 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
144139
145140
# if you are updating docs of the latest stable release branch
146141
mike deploy [version] latest --update-alias
@@ -158,17 +153,20 @@ On docs.hopsworks.ai we implement the following versioning scheme:
158153
```
159154

160155
You can now checkout the gh-pages branch and serve:
156+
161157
```bash
162158
git checkout gh-pages
163159
mike serve
164160
```
165161

166162
You can also list all available versions/aliases:
163+
167164
```bash
168165
mike list
169166
```
170167

171168
Delete and reset your local gh-pages branch:
169+
172170
```bash
173171
mike delete --all
174172
@@ -194,7 +192,7 @@ PAGES = {
194192

195193
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:
196194

197-
```
195+
````
198196
## The XYZ package
199197

200198
{{module}}
@@ -207,7 +205,7 @@ Some extra content here.
207205
```
208206

209207
{{xyz.asd}}
210-
```
208+
````
211209

212210
Finally, run the `auto_doc.py` script, as decribed above, to update the documentation.
213211

0 commit comments

Comments
 (0)