Skip to content

Commit

Permalink
Rename Open Tasks to Pending Tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
fm3 committed Jul 24, 2023
1 parent b5c639a commit 9cba216
Show file tree
Hide file tree
Showing 58 changed files with 1,386 additions and 365 deletions.
2 changes: 1 addition & 1 deletion webknossos/__generate_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def iterate_request_ids_with_responses() -> Iterable[Tuple[str, bytes]]:
"projectId",
"dataSet",
"status",
"open",
"pending",
"active",
"finished",
##### Annotation #####
Expand Down
4 changes: 2 additions & 2 deletions webknossos/examples/annotation_project_administration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ def main() -> None:
sample_project = Project.get_by_name("sampleProject")
tasks = sample_project.get_tasks()
total_active_instances = sum([task.status.active_instance_count for task in tasks])
total_open_instances = sum([task.status.open_instance_count for task in tasks])
total_pending_instances = sum([task.status.pending_instance_count for task in tasks])
print(
f"There are {total_active_instances} active and {total_open_instances} open task instances."
f"There are {total_active_instances} active and {total_pending_instances} pending task instances."
)

# Find and download all of the project’s annotations that are already finished by annotators
Expand Down
59 changes: 23 additions & 36 deletions webknossos/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webknossos/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ boltons = "~21.0.0"
cattrs = "^22.2.0"
cluster_tools = { path = "../cluster_tools/", develop = true }
fsspec = "^2022.2.0"
httpx = ">=0.15.4,<0.19.0"
httpx = ">=0.20.0,<=0.24.1"
loxun = "^2.0"
natsort = "^6.2.0"
networkx = "^2.6.2"
Expand Down
6 changes: 3 additions & 3 deletions webknossos/webknossos/administration/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@attr.frozen
class TaskStatus:
open_instance_count: int
pending_instance_count: int
active_instance_count: int
finished_instance_count: int

Expand Down Expand Up @@ -78,7 +78,7 @@ def create_from_annotations(
"domain": needed_experience_domain,
"value": needed_experience_value,
},
"openInstances": instances,
"pendingInstances": instances,
"projectName": project_name,
"scriptId": script_id,
"boundingBox": bounding_box.to_wkw_dict()
Expand Down Expand Up @@ -131,7 +131,7 @@ def create(
"domain": needed_experience_domain,
"value": needed_experience_value,
},
"openInstances": instances,
"pendingInstances": instances,
"projectName": project_name,
"scriptId": script_id,
"dataSet": dataset_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from http import HTTPStatus
from typing import Any, Dict, Union
from typing import Any, Dict, Optional, Union

import httpx

from ... import errors
from ...client import Client
from ...models.dataset_cancel_upload_json_body import DatasetCancelUploadJsonBody
from ...types import UNSET, Response, Unset
Expand Down Expand Up @@ -32,17 +33,29 @@ def _get_kwargs(
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"json": json_json_body,
"params": params,
}


def _build_response(*, response: httpx.Response) -> Response[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if response.status_code == HTTPStatus.BAD_REQUEST:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=None,
parsed=_parse_response(client=client, response=response),
)


Expand All @@ -63,6 +76,10 @@ def sync_detailed(
token (Union[Unset, None, str]):
json_body (DatasetCancelUploadJsonBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Any]
"""
Expand All @@ -78,7 +95,7 @@ def sync_detailed(
**kwargs,
)

return _build_response(response=response)
return _build_response(client=client, response=response)


async def asyncio_detailed(
Expand All @@ -98,6 +115,10 @@ async def asyncio_detailed(
token (Union[Unset, None, str]):
json_body (DatasetCancelUploadJsonBody):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Any]
"""
Expand All @@ -111,4 +132,4 @@ async def asyncio_detailed(
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)

return _build_response(response=response)
return _build_response(client=client, response=response)
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from http import HTTPStatus
from typing import Any, Dict, Union
from typing import Any, Dict, Optional, Union

import httpx

from ... import errors
from ...client import Client
from ...types import UNSET, Response, Unset

Expand Down Expand Up @@ -63,16 +64,28 @@ def _get_kwargs(
"headers": headers,
"cookies": cookies,
"timeout": client.get_timeout(),
"follow_redirects": client.follow_redirects,
"params": params,
}


def _build_response(*, response: httpx.Response) -> Response[Any]:
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if response.status_code == HTTPStatus.BAD_REQUEST:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=None,
parsed=_parse_response(client=client, response=response),
)


Expand Down Expand Up @@ -110,6 +123,10 @@ def sync_detailed(
half_byte (Union[Unset, None, bool]):
mapping_name (Union[Unset, None, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Any]
"""
Expand All @@ -136,7 +153,7 @@ def sync_detailed(
**kwargs,
)

return _build_response(response=response)
return _build_response(client=client, response=response)


async def asyncio_detailed(
Expand Down Expand Up @@ -173,6 +190,10 @@ async def asyncio_detailed(
half_byte (Union[Unset, None, bool]):
mapping_name (Union[Unset, None, str]):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[Any]
"""
Expand All @@ -197,4 +218,4 @@ async def asyncio_detailed(
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
response = await _client.request(**kwargs)

return _build_response(response=response)
return _build_response(client=client, response=response)
Loading

0 comments on commit 9cba216

Please sign in to comment.