Skip to content

Commit 4b5ad93

Browse files
authored
adds TaskType information to Tasks (#938)
* adds TaskType information to Tasks * changelog * merge * revert .well-known * Merge branch 'master' into administation-task-types * less flaky test? * Merge refs/heads/master into administation-task-types
1 parent 1426ec1 commit 4b5ad93

16 files changed

+152
-129
lines changed

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616

1717
### Added
18+
- Added `task_type` property to `Task` class. [#938](https://github.com/scalableminds/webknossos-libs/pull/938)
1819

1920
### Changed
2021

webknossos/__generate_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ def iterate_request_ids_with_responses() -> Iterable[Tuple[str, bytes]]:
320320
"pending",
321321
"active",
322322
"finished",
323+
"type",
324+
##### TaskType ####
325+
"summary",
326+
"teamId",
323327
##### Annotation #####
324328
# "owner", optional
325329
"description",

webknossos/tests/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ def _tiff_cubing(out_path: Path, data_format: DataFormat) -> None:
7878
assert (out_path / "tiff" / "1").exists()
7979

8080

81+
@pytest.mark.block_network(allowed_hosts=[".*"])
82+
@pytest.mark.vcr(ignore_hosts=["webknossos.org", "data-humerus.webknossos.org"])
8183
def test_tiff_cubing_zarr_s3() -> None:
8284
"""Tests zarr support when performing tiff cubing."""
8385

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from webknossos.administration.project import Project
2-
from webknossos.administration.task import Task
2+
from webknossos.administration.task import Task, TaskType
33
from webknossos.administration.user import Team, User

webknossos/webknossos/administration/task.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@
2222
from webknossos.client._generated.models.task_info_response_200 import (
2323
TaskInfoResponse200,
2424
)
25+
from webknossos.client._generated.models.task_info_response_200_type import (
26+
TaskInfoResponse200Type,
27+
)
2528
from webknossos.client._generated.models.task_infos_by_project_id_response_200_item import (
2629
TaskInfosByProjectIdResponse200Item,
2730
)
31+
from webknossos.client._generated.models.task_infos_by_project_id_response_200_item_type import (
32+
TaskInfosByProjectIdResponse200ItemType,
33+
)
2834

2935

3036
@attr.frozen
@@ -39,6 +45,30 @@ def open_instance_count(self) -> int:
3945
return self.pending_instance_count
4046

4147

48+
@attr.frozen
49+
class TaskType:
50+
task_type_id: str
51+
name: str
52+
description: str
53+
team_id: str
54+
team_name: str
55+
56+
@classmethod
57+
def _from_generated_response(
58+
cls,
59+
response: Union[
60+
"TaskInfoResponse200Type", "TaskInfosByProjectIdResponse200ItemType"
61+
],
62+
) -> "TaskType":
63+
return cls(
64+
response.id,
65+
response.summary,
66+
response.description,
67+
response.team_id,
68+
response.team_name,
69+
)
70+
71+
4272
@attr.frozen
4373
class Task:
4474
"""Data class containing information about a WEBKNOSSOS task"""
@@ -47,6 +77,7 @@ class Task:
4777
project_id: str
4878
dataset_name: str
4979
status: TaskStatus
80+
task_type: TaskType
5081

5182
@classmethod
5283
def get_by_id(cls, task_id: str) -> "Task":
@@ -185,6 +216,7 @@ def _from_generated_response(
185216
response.status.active,
186217
response.status.finished,
187218
),
219+
TaskType._from_generated_response(response.type),
188220
)
189221

190222
def get_annotation_infos(self) -> List[AnnotationInfo]:

webknossos/webknossos/client/_generated/models/annotation_info_response_200_task.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class AnnotationInfoResponse200Task:
2626
id (str):
2727
project_id (str):
2828
team (str):
29+
type (AnnotationInfoResponse200TaskType):
2930
data_set (str):
3031
created (int):
3132
status (AnnotationInfoResponse200TaskStatus):
3233
bounding_box (str):
3334
formatted_hash (Union[Unset, str]):
3435
project_name (Union[Unset, str]):
35-
type (Union[Unset, AnnotationInfoResponse200TaskType]):
3636
needed_experience (Union[Unset, AnnotationInfoResponse200TaskNeededExperience]):
3737
script (Union[Unset, str]):
3838
tracing_time (Union[Unset, None, int]):
@@ -44,13 +44,13 @@ class AnnotationInfoResponse200Task:
4444
id: str
4545
project_id: str
4646
team: str
47+
type: "AnnotationInfoResponse200TaskType"
4748
data_set: str
4849
created: int
4950
status: "AnnotationInfoResponse200TaskStatus"
5051
bounding_box: str
5152
formatted_hash: Union[Unset, str] = UNSET
5253
project_name: Union[Unset, str] = UNSET
53-
type: Union[Unset, "AnnotationInfoResponse200TaskType"] = UNSET
5454
needed_experience: Union[
5555
Unset, "AnnotationInfoResponse200TaskNeededExperience"
5656
] = UNSET
@@ -65,17 +65,15 @@ def to_dict(self) -> Dict[str, Any]:
6565
id = self.id
6666
project_id = self.project_id
6767
team = self.team
68+
type = self.type.to_dict()
69+
6870
data_set = self.data_set
6971
created = self.created
7072
status = self.status.to_dict()
7173

7274
bounding_box = self.bounding_box
7375
formatted_hash = self.formatted_hash
7476
project_name = self.project_name
75-
type: Union[Unset, Dict[str, Any]] = UNSET
76-
if not isinstance(self.type, Unset):
77-
type = self.type.to_dict()
78-
7977
needed_experience: Union[Unset, Dict[str, Any]] = UNSET
8078
if not isinstance(self.needed_experience, Unset):
8179
needed_experience = self.needed_experience.to_dict()
@@ -98,6 +96,7 @@ def to_dict(self) -> Dict[str, Any]:
9896
"id": id,
9997
"projectId": project_id,
10098
"team": team,
99+
"type": type,
101100
"dataSet": data_set,
102101
"created": created,
103102
"status": status,
@@ -108,8 +107,6 @@ def to_dict(self) -> Dict[str, Any]:
108107
field_dict["formattedHash"] = formatted_hash
109108
if project_name is not UNSET:
110109
field_dict["projectName"] = project_name
111-
if type is not UNSET:
112-
field_dict["type"] = type
113110
if needed_experience is not UNSET:
114111
field_dict["neededExperience"] = needed_experience
115112
if script is not UNSET:
@@ -144,6 +141,8 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
144141

145142
team = d.pop("team")
146143

144+
type = AnnotationInfoResponse200TaskType.from_dict(d.pop("type"))
145+
147146
data_set = d.pop("dataSet")
148147

149148
created = d.pop("created")
@@ -156,13 +155,6 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
156155

157156
project_name = d.pop("projectName", UNSET)
158157

159-
_type = d.pop("type", UNSET)
160-
type: Union[Unset, AnnotationInfoResponse200TaskType]
161-
if isinstance(_type, Unset):
162-
type = UNSET
163-
else:
164-
type = AnnotationInfoResponse200TaskType.from_dict(_type)
165-
166158
_needed_experience = d.pop("neededExperience", UNSET)
167159
needed_experience: Union[Unset, AnnotationInfoResponse200TaskNeededExperience]
168160
if isinstance(_needed_experience, Unset):
@@ -186,13 +178,13 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
186178
id=id,
187179
project_id=project_id,
188180
team=team,
181+
type=type,
189182
data_set=data_set,
190183
created=created,
191184
status=status,
192185
bounding_box=bounding_box,
193186
formatted_hash=formatted_hash,
194187
project_name=project_name,
195-
type=type,
196188
needed_experience=needed_experience,
197189
script=script,
198190
tracing_time=tracing_time,

webknossos/webknossos/client/_generated/models/annotation_info_response_200_task_type.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ class AnnotationInfoResponse200TaskType:
1818
"""
1919
Attributes:
2020
id (str):
21+
summary (str):
2122
description (str):
23+
team_id (str):
2224
team_name (str):
23-
summary (Union[Unset, str]):
24-
team_id (Union[Unset, str]):
2525
settings (Union[Unset, AnnotationInfoResponse200TaskTypeSettings]):
2626
recommended_configuration (Union[Unset, str]):
2727
tracing_type (Union[Unset, str]):
2828
"""
2929

3030
id: str
31+
summary: str
3132
description: str
33+
team_id: str
3234
team_name: str
33-
summary: Union[Unset, str] = UNSET
34-
team_id: Union[Unset, str] = UNSET
3535
settings: Union[Unset, "AnnotationInfoResponse200TaskTypeSettings"] = UNSET
3636
recommended_configuration: Union[Unset, str] = UNSET
3737
tracing_type: Union[Unset, str] = UNSET
3838
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
3939

4040
def to_dict(self) -> Dict[str, Any]:
4141
id = self.id
42-
description = self.description
43-
team_name = self.team_name
4442
summary = self.summary
43+
description = self.description
4544
team_id = self.team_id
45+
team_name = self.team_name
4646
settings: Union[Unset, Dict[str, Any]] = UNSET
4747
if not isinstance(self.settings, Unset):
4848
settings = self.settings.to_dict()
@@ -55,14 +55,12 @@ def to_dict(self) -> Dict[str, Any]:
5555
field_dict.update(
5656
{
5757
"id": id,
58+
"summary": summary,
5859
"description": description,
60+
"teamId": team_id,
5961
"teamName": team_name,
6062
}
6163
)
62-
if summary is not UNSET:
63-
field_dict["summary"] = summary
64-
if team_id is not UNSET:
65-
field_dict["teamId"] = team_id
6664
if settings is not UNSET:
6765
field_dict["settings"] = settings
6866
if recommended_configuration is not UNSET:
@@ -81,13 +79,13 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
8179
d = src_dict.copy()
8280
id = d.pop("id")
8381

84-
description = d.pop("description")
82+
summary = d.pop("summary")
8583

86-
team_name = d.pop("teamName")
84+
description = d.pop("description")
8785

88-
summary = d.pop("summary", UNSET)
86+
team_id = d.pop("teamId")
8987

90-
team_id = d.pop("teamId", UNSET)
88+
team_name = d.pop("teamName")
9189

9290
_settings = d.pop("settings", UNSET)
9391
settings: Union[Unset, AnnotationInfoResponse200TaskTypeSettings]
@@ -102,10 +100,10 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
102100

103101
annotation_info_response_200_task_type = cls(
104102
id=id,
105-
description=description,
106-
team_name=team_name,
107103
summary=summary,
104+
description=description,
108105
team_id=team_id,
106+
team_name=team_name,
109107
settings=settings,
110108
recommended_configuration=recommended_configuration,
111109
tracing_type=tracing_type,

webknossos/webknossos/client/_generated/models/annotation_infos_by_task_id_response_200_item_task.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class AnnotationInfosByTaskIdResponse200ItemTask:
2626
id (str):
2727
project_id (str):
2828
team (str):
29+
type (AnnotationInfosByTaskIdResponse200ItemTaskType):
2930
data_set (str):
3031
created (int):
3132
status (AnnotationInfosByTaskIdResponse200ItemTaskStatus):
3233
bounding_box (str):
3334
formatted_hash (Union[Unset, str]):
3435
project_name (Union[Unset, str]):
35-
type (Union[Unset, AnnotationInfosByTaskIdResponse200ItemTaskType]):
3636
needed_experience (Union[Unset, AnnotationInfosByTaskIdResponse200ItemTaskNeededExperience]):
3737
script (Union[Unset, str]):
3838
tracing_time (Union[Unset, None, int]):
@@ -44,13 +44,13 @@ class AnnotationInfosByTaskIdResponse200ItemTask:
4444
id: str
4545
project_id: str
4646
team: str
47+
type: "AnnotationInfosByTaskIdResponse200ItemTaskType"
4748
data_set: str
4849
created: int
4950
status: "AnnotationInfosByTaskIdResponse200ItemTaskStatus"
5051
bounding_box: str
5152
formatted_hash: Union[Unset, str] = UNSET
5253
project_name: Union[Unset, str] = UNSET
53-
type: Union[Unset, "AnnotationInfosByTaskIdResponse200ItemTaskType"] = UNSET
5454
needed_experience: Union[
5555
Unset, "AnnotationInfosByTaskIdResponse200ItemTaskNeededExperience"
5656
] = UNSET
@@ -65,17 +65,15 @@ def to_dict(self) -> Dict[str, Any]:
6565
id = self.id
6666
project_id = self.project_id
6767
team = self.team
68+
type = self.type.to_dict()
69+
6870
data_set = self.data_set
6971
created = self.created
7072
status = self.status.to_dict()
7173

7274
bounding_box = self.bounding_box
7375
formatted_hash = self.formatted_hash
7476
project_name = self.project_name
75-
type: Union[Unset, Dict[str, Any]] = UNSET
76-
if not isinstance(self.type, Unset):
77-
type = self.type.to_dict()
78-
7977
needed_experience: Union[Unset, Dict[str, Any]] = UNSET
8078
if not isinstance(self.needed_experience, Unset):
8179
needed_experience = self.needed_experience.to_dict()
@@ -98,6 +96,7 @@ def to_dict(self) -> Dict[str, Any]:
9896
"id": id,
9997
"projectId": project_id,
10098
"team": team,
99+
"type": type,
101100
"dataSet": data_set,
102101
"created": created,
103102
"status": status,
@@ -108,8 +107,6 @@ def to_dict(self) -> Dict[str, Any]:
108107
field_dict["formattedHash"] = formatted_hash
109108
if project_name is not UNSET:
110109
field_dict["projectName"] = project_name
111-
if type is not UNSET:
112-
field_dict["type"] = type
113110
if needed_experience is not UNSET:
114111
field_dict["neededExperience"] = needed_experience
115112
if script is not UNSET:
@@ -144,6 +141,8 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
144141

145142
team = d.pop("team")
146143

144+
type = AnnotationInfosByTaskIdResponse200ItemTaskType.from_dict(d.pop("type"))
145+
147146
data_set = d.pop("dataSet")
148147

149148
created = d.pop("created")
@@ -158,13 +157,6 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
158157

159158
project_name = d.pop("projectName", UNSET)
160159

161-
_type = d.pop("type", UNSET)
162-
type: Union[Unset, AnnotationInfosByTaskIdResponse200ItemTaskType]
163-
if isinstance(_type, Unset):
164-
type = UNSET
165-
else:
166-
type = AnnotationInfosByTaskIdResponse200ItemTaskType.from_dict(_type)
167-
168160
_needed_experience = d.pop("neededExperience", UNSET)
169161
needed_experience: Union[
170162
Unset, AnnotationInfosByTaskIdResponse200ItemTaskNeededExperience
@@ -192,13 +184,13 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
192184
id=id,
193185
project_id=project_id,
194186
team=team,
187+
type=type,
195188
data_set=data_set,
196189
created=created,
197190
status=status,
198191
bounding_box=bounding_box,
199192
formatted_hash=formatted_hash,
200193
project_name=project_name,
201-
type=type,
202194
needed_experience=needed_experience,
203195
script=script,
204196
tracing_time=tracing_time,

0 commit comments

Comments
 (0)