Skip to content

Commit cbd1bed

Browse files
add client docs, hide unnecessary docs, add some styling (#468)
* add client docs, hide unnecessary docs, add some styling * fix pylint ignore * fix pylint ignore for real * Update webknossos/webknossos/client/context.py Co-authored-by: Philipp Otto <[email protected]>
1 parent bd766eb commit cbd1bed

File tree

65 files changed

+143
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+143
-57
lines changed

docs/mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ nav:
8686
- Graph: api/webknossos/skeleton/graph.md
8787
- Node: api/webknossos/skeleton/node.md
8888
- Annotation: api/webknossos/annotation/annotation.md
89+
- Client:
90+
- Overview: api/webknossos/client.md
91+
- Authentication & Server Context: api/webknossos/client/context.md
8992
- wkcuber CLI: wkcuber/index.md
9093

9194
plugins:

docs/overrides/css/lists.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* Unordered list <ul> symbols:
2+
* - level 1 is filled circle (default)
3+
* - level 2 is hollow circle
4+
* - level 3 is filled square
5+
*/
6+
article ul ul {
7+
list-style-type: circle !important;
8+
font-size: 0.95em;
9+
}
10+
11+
article ul ul ul {
12+
list-style-type: square !important;
13+
}

docs/overrides/main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{{ super() }}
88
<link rel="stylesheet" href="{{ base_url }}/css/lightbox.min.css">
99
<link rel="stylesheet" href="{{ base_url }}/css/image_gallery.css">
10+
<link rel="stylesheet" href="{{ base_url }}/css/lists.css">
1011
<style type="text/css">
1112
@font-face {
1213
font-family: "Titillium Web";

docs/src/webknossos-py/examples/learned_segmenter.md

Lines changed: 2 additions & 2 deletions

docs/src/webknossos-py/index.md

Lines changed: 16 additions & 13 deletions

webknossos/__generate_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
_get_project_for_url_or_path,
1515
)
1616

17-
from webknossos.client.context import get_generated_client
17+
from webknossos.client.context import _get_generated_client
1818
from webknossos.utils import snake_to_camel_case
1919

2020
SCHEMA_URL = "https://converter.swagger.io/api/convert?url=https%3A%2F%2Fwebknossos.org%2Fswagger.json"
@@ -59,7 +59,7 @@ def add_api_prefix_for_non_data_paths(openapi_schema: Dict) -> None:
5959

6060

6161
def iterate_request_ids_with_responses() -> Iterable[Tuple[str, bytes]]:
62-
from webknossos.client.generated.api.default import (
62+
from webknossos.client._generated.api.default import (
6363
annotation_info,
6464
build_info,
6565
dataset_info,
@@ -68,7 +68,7 @@ def iterate_request_ids_with_responses() -> Iterable[Tuple[str, bytes]]:
6868

6969
d = datetime.utcnow()
7070
unixtime = calendar.timegm(d.utctimetuple())
71-
client = get_generated_client(enforce_auth=True)
71+
client = _get_generated_client(enforce_auth=True)
7272

7373
annotation_info_response = annotation_info.sync_detailed(
7474
typ="Explorational",

webknossos/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -eEuo pipefail
55
# This will maybe be fixed by https://github.com/PyCQA/pylint/issues/352
66
# In the meantime, find all python files, except for the ./tests/.webknossos-server directory and lint them
77
# Inspired by https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command
8-
find . -type d \( -path ./webknossos/client/generated -o -path ./tests/.webknossos-server \) -prune -o -iname "*.py" -print | xargs poetry run python -m pylint -j4
8+
find . -type d \( -path ./webknossos/client/_generated -o -path ./tests/.webknossos-server \) -prune -o -iname "*.py" -print | xargs poetry run python -m pylint -j2

webknossos/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ disallow_untyped_defs = true
6464
no_implicit_optional = true
6565

6666
[tool.pylint.MASTER]
67-
ignore=['generated']
67+
ignore=['webknossos/client/_generated']
6868
load-plugins=['_helpers.pylint_plugins.attrs_ng_api']
6969

7070
[tool.pylint.'MESSAGES CONTROL']

webknossos/tests/test_generated_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import pytest
22

3-
from webknossos.client.context import get_generated_client
4-
from webknossos.client.defaults import DEFAULT_WEBKNOSSOS_URL
5-
from webknossos.client.generated.api.default import (
3+
from webknossos.client._defaults import DEFAULT_WEBKNOSSOS_URL
4+
from webknossos.client._generated.api.default import (
65
annotation_info,
76
build_info,
87
dataset_info,
98
datastore_list,
109
health,
1110
)
12-
from webknossos.client.generated.client import Client
13-
from webknossos.client.generated.models.datastore_list_response_200_item import (
11+
from webknossos.client._generated.client import Client
12+
from webknossos.client._generated.models.datastore_list_response_200_item import (
1413
DatastoreListResponse200Item,
1514
)
15+
from webknossos.client.context import _get_generated_client
1616
from webknossos.utils import time_since_epoch_in_ms
1717

1818

1919
@pytest.fixture
2020
def client() -> Client:
21-
return get_generated_client()
21+
return _get_generated_client()
2222

2323

2424
@pytest.fixture
2525
def auth_client() -> Client:
26-
return get_generated_client(enforce_auth=True)
26+
return _get_generated_client(enforce_auth=True)
2727

2828

2929
# pylint: disable=redefined-outer-name

webknossos/webknossos/annotation/annotation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from attr import dataclass
99
from boltons.cacheutils import cachedproperty
1010

11-
from webknossos.client.context import get_context
11+
from webknossos.client.context import _get_context
1212
from webknossos.dataset import Dataset, Layer, SegmentationLayer
1313
from webknossos.skeleton import Skeleton, open_nml
1414

@@ -95,11 +95,11 @@ def open_annotation(annotation_path: Union[str, PathLike]) -> "Annotation":
9595
), "open_annotation() must be called with a path or an annotation url, e.g. https://webknossos.org/annotations/Explorational/6114d9410100009f0096c640"
9696
webknossos_url, annotation_type_str, annotation_id = match.groups()
9797
annotation_type = AnnotationType(annotation_type_str)
98-
assert webknossos_url == get_context().url, (
99-
f"The supplied url {webknossos_url} does not match your current context {get_context().url},\n"
98+
assert webknossos_url == _get_context().url, (
99+
f"The supplied url {webknossos_url} does not match your current context {_get_context().url},\n"
100100
+ "please adapt it e.g. via 'with webknossos_context(…)'"
101101
)
102-
from webknossos.client.download_annotation import download_annotation
102+
from webknossos.client._download_annotation import download_annotation
103103

104104
return download_annotation(annotation_type, annotation_id)
105105

0 commit comments

Comments
 (0)