Skip to content

Commit ba997ea

Browse files
authored
Publish docs for webknossos and wkcuber (#403)
* publish both docs to s3 * rewrite docs links * ci * ci * ci * ci * ci * ci
1 parent 1c4f2a6 commit ba997ea

File tree

13 files changed

+94
-243
lines changed

13 files changed

+94
-243
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,6 @@ jobs:
106106
- name: CLI tests
107107
run: tests/scripts/all_tests.sh
108108

109-
- name: Generate Docs
110-
if: matrix.python-version == '3.8'
111-
run: |
112-
docs/api.sh --persist
113-
114-
- name: Push docs (for branch)
115-
if: startsWith(github.event.ref, 'refs/heads') && matrix.python-version == '3.8'
116-
env:
117-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
118-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
119-
AWS_DEFAULT_REGION: "eu-west-1"
120-
run: |
121-
CI_BRANCH=${GITHUB_REF##*/}
122-
NORMALIZED_CI_BRANCH=${CI_BRANCH//[\/-]/_}
123-
aws s3 sync --acl public-read docs/api s3://static.webknossos.org/lib-docs/${NORMALIZED_CI_BRANCH}
124-
125-
- name: Push docs (for tag)
126-
if: startsWith(github.event.ref, 'refs/tags') && matrix.python-version == '3.8'
127-
env:
128-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
129-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
130-
AWS_DEFAULT_REGION: "eu-west-1"
131-
run: |
132-
CI_TAG=$(git describe --tags)
133-
aws s3 sync --acl public-read docs/api s3://static.webknossos.org/lib-docs/${CI_TAG}
134-
135109
- name: Check if git is dirty
136110
run: |
137111
git diff --no-ext-diff --quiet --exit-code
@@ -265,6 +239,58 @@ jobs:
265239
docker push scalableminds/webknossos-cuber:latest
266240
fi
267241
242+
docs:
243+
needs: [webknossos_linux, wkcuber_linux, wkcuber_win, wkcuber_mac]
244+
runs-on: ubuntu-latest
245+
if: |
246+
always() &&
247+
!contains(needs.*.result, 'failure') &&
248+
!contains(needs.*.result, 'cancelled')
249+
250+
steps:
251+
- uses: actions/checkout@v2
252+
- name: Set up Python 3.8
253+
uses: actions/setup-python@v1
254+
with:
255+
python-version: 3.8
256+
architecture: 'x64'
257+
258+
- name: Install dependencies
259+
run: |
260+
pip3 install -r requirements.txt
261+
pushd webknossos
262+
poetry install
263+
popd
264+
pushd wkcuber
265+
poetry install
266+
popd
267+
268+
- name: Build Docs
269+
run: |
270+
docs/api.sh --persist
271+
272+
- name: Push docs (for branch)
273+
if: startsWith(github.event.ref, 'refs/heads')
274+
env:
275+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
276+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
277+
AWS_DEFAULT_REGION: "eu-west-1"
278+
run: |
279+
CI_BRANCH=${GITHUB_REF##*/}
280+
NORMALIZED_CI_BRANCH=${CI_BRANCH//[\/-]/_}
281+
aws s3 sync --acl public-read docs/api s3://static.webknossos.org/lib-docs/${NORMALIZED_CI_BRANCH}
282+
283+
- name: Push docs (for tag)
284+
if: startsWith(github.event.ref, 'refs/tags')
285+
env:
286+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
287+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
288+
AWS_DEFAULT_REGION: "eu-west-1"
289+
run: |
290+
CI_TAG=$(git describe --tags)
291+
aws s3 sync --acl public-read docs/api s3://static.webknossos.org/lib-docs/${CI_TAG}
292+
293+
268294
pypi:
269295
needs: [webknossos_linux, wkcuber_linux, wkcuber_win, wkcuber_mac]
270296
if: |
@@ -292,7 +318,7 @@ jobs:
292318
run: ./publish.sh
293319

294320
success:
295-
needs: [webknossos_linux, wkcuber_linux, wkcuber_win, wkcuber_mac, wkcuber_docker]
321+
needs: [webknossos_linux, wkcuber_linux, wkcuber_win, wkcuber_mac, wkcuber_docker, docs]
296322
if: |
297323
always() &&
298324
!contains(needs.*.result, 'failure') &&

wkcuber/docs/api.sh renamed to docs/api.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ PROJECT_DIR="$(dirname "$(dirname "$0")")"
66
cd "$PROJECT_DIR/."
77

88
if [ $# -eq 1 ] && [ "$1" = "--persist" ]; then
9-
pdoc ./wkcuber -o docs/api
9+
pdoc ./webknossos/webknossos ./wkcuber/wkcuber -o docs/api
1010
else
11-
pdoc ./wkcuber -p 8095 -h 0.0.0.0
11+
pdoc ./webknossos/webknossos ./wkcuber/wkcuber -p 8095 -h 0.0.0.0
1212
fi

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dunamai==1.6.0
22
poetry==1.1.8
3+
pdoc==7.4.0

webknossos/webknossos/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
# webknossos
3+
4+
This module providess methods to modify or interact with webKnossos resources.
5+
Check out `webknossos.dataset` for detailed API documentation.
6+
"""

webknossos/webknossos/dataset/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
44
The high-level dataset API automatically reads and writes meta information for any dataset and updates them if necessary, such as the `datasource-properties.json`.
55
6-
A dataset (`wkcuber.api.dataset.Dataset`) is the entry-point for this API.
6+
A dataset (`webknossos.dataset.dataset.Dataset`) is the entry-point for this API.
77
The dataset stores the data on disk in `.wkw`-files (see [webknossos-wrap (wkw)](https://github.com/scalableminds/webknossos-wrap)).
88
9-
Each dataset consists of one or more layers (wkcuber.api.layer.Layer), which themselves can comprise multiple magnifications (wkcuber.api.mag_view.MagView).
9+
Each dataset consists of one or more layers (webknossos.dataset.layer.Layer), which themselves can comprise multiple magnifications (webknossos.dataset.mag_view.MagView).
1010
1111
## Examples
1212
### Opening Datasets
1313
```python
14-
from wkcuber.api import Dataset
14+
from webknossos.dataset import Dataset
1515
1616
dataset = Dataset(<path_to_dataset>)
1717
# Assuming that the dataset has a layer called 'color' and the layer has the magnification "1"
@@ -21,8 +21,8 @@
2121
2222
### Creating Datasets
2323
```python
24-
from wkcuber.api import Dataset
25-
from wkcuber.api import Layer
24+
from webknossos.dataset import Dataset
25+
from webknossos.dataset import Layer
2626
2727
dataset = Dataset.create(<path_to_new_dataset>, scale=(1, 1, 1))
2828
layer = dataset.add_layer(
@@ -37,7 +37,7 @@
3737
3838
### Reading Datasets
3939
```python
40-
from wkcuber.api import Dataset
40+
from webknossos.dataset import Dataset
4141
4242
dataset = Dataset(<path_to_dataset>)
4343
# Assuming that the dataset has a layer called 'color' and the layer has the magnification "1" and "2"
@@ -54,7 +54,7 @@
5454
5555
### Writing Datasets
5656
```python
57-
from wkcuber.api import Dataset
57+
from webknossos.dataset import Dataset
5858
5959
dataset = Dataset(<path_to_dataset>)
6060
# Assuming that the dataset has a layer called 'color' and the layer has the magnification "1" and "2"

webknossos/webknossos/dataset/dataset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Dataset:
5858
5959
### Creating Datasets
6060
```python
61-
from wkcuber.api.dataset import Dataset
61+
from webknossos.dataset.dataset import Dataset
6262
6363
dataset = Dataset.create(<path_to_new_dataset>, scale=(1, 1, 1))
6464
# Adds a new layer
@@ -74,7 +74,7 @@ class Dataset:
7474
7575
### Opening Datasets
7676
```python
77-
from wkcuber.api.dataset import Dataset
77+
from webknossos.dataset.dataset import Dataset
7878
7979
dataset = Dataset(<path_to_dataset>)
8080
# Assuming that the dataset has a layer called 'color'
@@ -83,7 +83,7 @@ class Dataset:
8383
8484
### Copying Datasets
8585
```python
86-
from wkcuber.api.dataset import Dataset
86+
from webknossos.dataset.dataset import Dataset
8787
8888
dataset = Dataset(<path_to_dataset>)
8989
# Copying the dataset with different block_len and file_len
@@ -149,7 +149,7 @@ def layers(self) -> Dict[str, Layer]:
149149

150150
def get_layer(self, layer_name: str) -> Layer:
151151
"""
152-
Returns the layer called `layer_name` of this dataset. The return type is `wkcuber.api.layer.Layer`.
152+
Returns the layer called `layer_name` of this dataset. The return type is `webknossos.dataset.layer.Layer`.
153153
154154
This function raises an `IndexError` if the specified `layer_name` does not exist.
155155
"""
@@ -177,7 +177,7 @@ def add_layer(
177177
178178
Creates the folder `layer_name` in the directory of `self.path`.
179179
180-
The return type is `wkcuber.api.layer.Layer`.
180+
The return type is `webknossos.dataset.layer.Layer`.
181181
182182
This function raises an `IndexError` if the specified `layer_name` already exists.
183183
"""

webknossos/webknossos/dataset/layer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ def _element_class_to_dtype_per_channel(
140140

141141
class Layer:
142142
"""
143-
A `Layer` consists of multiple `wkcuber.api.mag_view.MagView`s, which store the same data in different magnifications.
143+
A `Layer` consists of multiple `webknossos.dataset.mag_view.MagView`s, which store the same data in different magnifications.
144144
145145
## Examples
146146
147147
### Adding layer to dataset
148148
```python
149-
from wkcuber.api.dataset import Dataset
149+
from webknossos.dataset.dataset import Dataset
150150
151151
dataset = Dataset(<path_to_dataset>)
152152
# Adds a new layer
@@ -158,7 +158,7 @@ class Layer:
158158

159159
def __init__(self, dataset: "Dataset", properties: LayerProperties) -> None:
160160
"""
161-
Do not use this constructor manually. Instead use `wkcuber.api.layer.Dataset.add_layer()` to create a `Layer`.
161+
Do not use this constructor manually. Instead use `webknossos.dataset.layer.Dataset.add_layer()` to create a `Layer`.
162162
"""
163163
# It is possible that the properties on disk do not contain the number of channels.
164164
# Therefore, the parameter is optional. However at this point, 'num_channels' was already inferred.
@@ -258,7 +258,7 @@ def mags(self) -> Dict[Mag, MagView]:
258258

259259
def get_mag(self, mag: Union[int, str, list, tuple, np.ndarray, Mag]) -> MagView:
260260
"""
261-
Returns the MagDataset called `mag` of this layer. The return type is `wkcuber.api.MagDataset`.
261+
Returns the `MagView` called `mag` of this layer. The return type is `webknossos.dataset.mag_view.MagView`.
262262
263263
This function raises an `IndexError` if the specified `mag` does not exist.
264264
"""
@@ -284,7 +284,7 @@ def add_mag(
284284
diminished performance, as full blocks will automatically be read to pad the write actions. Alternatively,
285285
you can call mag.compress() after all the data was written
286286
287-
The return type is `wkcuber.api.mag_view.MagView`.
287+
The return type is `webknossos.dataset.mag_view.MagView`.
288288
289289
Raises an IndexError if the specified `mag` already exists.
290290
"""
@@ -348,7 +348,7 @@ def get_or_add_mag(
348348

349349
def delete_mag(self, mag: Union[int, str, list, tuple, np.ndarray, Mag]) -> None:
350350
"""
351-
Deletes the MagDataset from the `datasource-properties.json` and the data from disk.
351+
Deletes the MagView from the `datasource-properties.json` and the data from disk.
352352
353353
This function raises an `IndexError` if the specified `mag` does not exist.
354354
"""
@@ -499,7 +499,7 @@ def downsample(
499499
500500
Example:
501501
```python
502-
from wkcuber.downsampling_utils import SamplingModes
502+
from webknossos.dataset.downsampling_utils import SamplingModes
503503
504504
# ...
505505
# let 'layer' be a `Layer` with only `Mag(1)`
@@ -858,7 +858,7 @@ class LayerCategories:
858858
There are two different types of layers.
859859
This class can be used to specify the type of a layer during creation:
860860
```python
861-
from wkcuber.api.dataset import Dataset
861+
from webknossos.dataset.dataset import Dataset
862862
863863
dataset = Dataset(<path_to_dataset>)
864864
# Adds a new layer

webknossos/webknossos/dataset/mag_view.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def _convert_mag1_offset(
4444

4545
class MagView(View):
4646
"""
47-
A `MagView` contains all information about the data of a single magnification of a `wkcuber.api.layer.Layer`.
48-
`MagView` inherits from `wkcuber.api.view.View`.
47+
A `MagView` contains all information about the data of a single magnification of a `webknossos.dataset.layer.Layer`.
48+
`MagView` inherits from `webknossos.dataset.view.View`.
4949
Therefore, the main difference between them is that a `MagView` handles the whole magnification,
5050
whereas the `View` only handles a sub-region.
5151
5252
A `MagView` can read/write outside the specified bounding box (unlike a normal `View`).
5353
If necessary, the properties are automatically updated (e.g. if the bounding box changed).
54-
This is possible because a `MagView` does have a reference to the `wkcuber.api.layer.Layer`.
54+
This is possible because a `MagView` does have a reference to the `webknossos.dataset.layer.Layer`.
5555
5656
The `global_offset` of a `MagView` is always `(0, 0, 0)` and its `size` is chosen so that the bounding box from the properties is fully inside this View.
5757
"""
@@ -66,7 +66,7 @@ def __init__(
6666
create: bool = False,
6767
) -> None:
6868
"""
69-
Do not use this constructor manually. Instead use `wkcuber.api.layer.Layer.add_mag()` to create a `MagView`.
69+
Do not use this constructor manually. Instead use `webknossos.dataset.layer.Layer.add_mag()` to create a `MagView`.
7070
"""
7171
header = wkw.Header(
7272
voxel_type=layer.dtype_per_channel,
@@ -122,7 +122,7 @@ def mag(self) -> Mag:
122122

123123
def write(self, data: np.ndarray, offset: Vec3 = (0, 0, 0)) -> None:
124124
"""
125-
Writes the `data` at the specified `offset` to disk (like `wkcuber.api.view.View.write()`).
125+
Writes the `data` at the specified `offset` to disk (like `webknossos.dataset.view.View.write()`).
126126
127127
The `offset` refers to the absolute position, regardless of the offset in the properties (because the global_offset is set to (0, 0, 0)).
128128
If the data exceeds the original bounding box, the properties are updated.

webknossos/webknossos/dataset/view.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class View:
2020
A `View` is essentially a bounding box to a region of a specific `wkw.Dataset` that also provides functionality.
2121
Read- and write-operations are restricted to the bounding box.
2222
`View`s are designed to be easily passed around as parameters.
23-
A `View`, in its most basic form, does not have a reference to the `wkcuber.api.dataset.Dataset`.
23+
A `View`, in its most basic form, does not have a reference to the `webknossos.dataset.dataset.Dataset`.
2424
"""
2525

2626
def __init__(
@@ -34,7 +34,7 @@ def __init__(
3434
mag_view_bbox_at_creation: Optional[BoundingBox] = None,
3535
):
3636
"""
37-
Do not use this constructor manually. Instead use `wkcuber.api.mag_view.MagView.get_view()` to get a `View`.
37+
Do not use this constructor manually. Instead use `webknossos.dataset.mag_view.MagView.get_view()` to get a `View`.
3838
"""
3939
self._dataset: Optional[Dataset] = None
4040
self._path = path_to_mag_view
@@ -310,7 +310,7 @@ def for_each_chunk(
310310
311311
Example:
312312
```python
313-
from wkcuber.utils import get_executor_for_args, named_partial
313+
from webknossos.utils import get_executor_for_args, named_partial
314314
315315
def some_work(args: Tuple[View, int], some_parameter: int) -> None:
316316
view_of_single_chunk, i = args

0 commit comments

Comments
 (0)