Skip to content

Commit ec31f3e

Browse files
authored
Annofab v0.90.2 (#181)
* AnnoFan v0.90.2 (delete_project_job) * format * update version
1 parent a1daf97 commit ec31f3e

11 files changed

+83
-13
lines changed

annofabapi/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.35.0"
1+
__version__ = "0.36.0"

annofabapi/generated_api.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,9 @@ def put_instruction(
10001000
# NOTE: This method is auto generated by OpenAPI Generator
10011001
#########################################
10021002

1003-
def delete_project_job(self, project_id: str, job_id: str, **kwargs) -> Tuple[Any, requests.Response]:
1003+
def delete_project_job(
1004+
self, project_id: str, job_type: str, job_id: str, **kwargs
1005+
) -> Tuple[Any, requests.Response]:
10041006
"""バックグラウンドジョブ情報削除
10051007
10061008
@@ -1011,14 +1013,15 @@ def delete_project_job(self, project_id: str, job_id: str, **kwargs) -> Tuple[An
10111013
10121014
Args:
10131015
project_id (str): プロジェクトID (required)
1016+
job_type (JobType): ジョブの種別。[詳細はこちら](#section/JobType)。 (required)
10141017
job_id (str): ジョブID (required)
10151018
10161019
Returns:
10171020
Tuple[, requests.Response]
10181021
10191022
10201023
"""
1021-
url_path = f"/projects/{project_id}/jobs/gen-inputs/{job_id}"
1024+
url_path = f"/projects/{project_id}/jobs/{job_type}/{job_id}"
10221025
http_method = "DELETE"
10231026
keyword_params: Dict[str, Any] = {}
10241027
return self._request_wrapper(http_method, url_path, **keyword_params)

annofabapi/models.py

+17
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,8 @@ class AssigneeRuleOfResubmittedTask(Enum):
12361236
複数の集約を区別するための名前です。 `(フィールド名)_(集約内容)` のように命名されます。例えば `account_id` フィールドを `count` する場合、`account_id_count` となります。
12371237
* field: str
12381238
集約に使われたリソースのフィールド名です。 リソースの属性のさらに属性を参照するときは、`foo.bar.buz` のようにドット区切りになります。
1239+
* doc_count: int
1240+
集約の件数です。
12391241
* items: List[Count]
12401242
集約結果の値です。
12411243
@@ -2685,6 +2687,21 @@ class OrganizationMemberStatus(Enum):
26852687
26862688
"""
26872689

2690+
OverlappedRangeAnnotation = Dict[str, Any]
2691+
"""
2692+
区間が重複しているアノテーションが存在している場合に発生するエラー
2693+
2694+
Kyes of Dict
2695+
2696+
* label_id: str
2697+
2698+
* annotation_id: str
2699+
2700+
* type: str
2701+
OverlappedRangeAnnotation
2702+
2703+
"""
2704+
26882705
PasswordResetRequest = Dict[str, Any]
26892706
"""
26902707

annofabapi/wrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ def delete_all_succeeded_job(self, project_id: str, job_type: JobType) -> List[J
12571257
for job in jobs:
12581258
if job["job_status"] == "succeeded":
12591259
logger.debug("job_id=%s のジョブを削除します。", job["job_id"])
1260-
self.api.delete_project_job(project_id, job["job_id"])
1260+
self.api.delete_project_job(project_id, job_type=job_type.value, job_id=job["job_id"])
12611261
deleted_jobs.append(job)
12621262

12631263
return deleted_jobs

generate/generate.sh

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ docker run --rm -u `id -u`:`id -g` -v ${PWD}:/local -w /local -e JAVA_OPTS=$
6565
--ignore-file-override=/local/.openapi-generator-ignore_v1
6666

6767
cat partial-header/generated_api_partial_header_v1.py out/openapi_client/api/*_api.py > ../annofabapi/generated_api.py
68+
# job_typeの型がJobTypeだとEnumのため都合が悪いので、型をstrに変換する
69+
sed -e "s/job_type: JobType/job_type: str/g" ../annofabapi/generated_api.py --in-place
70+
6871
rm -Rf out/openapi_client
6972

7073
# v2 apiを生成
@@ -231,6 +234,7 @@ sed -e "s/__DictStrKeyAnyValue__/Dict[str,Any]/g" ../annofabapi/dataclass/*.py
231234
sed -E -e "s/dict\((.*)\)/Dict\[\1\]/g" ../annofabapi/dataclass/*.py --in-place
232235

233236

237+
234238
rm -Rf out/openapi_client
235239

236240

generate/swagger/swagger-api-components.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -3941,6 +3941,10 @@ components:
39413941
集約に使われたリソースのフィールド名です。
39423942
39433943
リソースの属性のさらに属性を参照するときは、`foo.bar.buz` のようにドット区切りになります。
3944+
doc_count:
3945+
type: integer
3946+
description: |
3947+
集約の件数です。
39443948
items:
39453949
type: array
39463950
items:
@@ -4029,6 +4033,7 @@ components:
40294033
- $ref: "#/components/schemas/Duplicated"
40304034
- $ref: "#/components/schemas/UnknownAdditionalData"
40314035
- $ref: "#/components/schemas/OutOfImageBounds"
4036+
- $ref: "#/components/schemas/OverlappedRangeAnnotation"
40324037
- $ref: "#/components/schemas/UnknownLabel"
40334038
discriminator:
40344039
propertyName: "_type"
@@ -4042,6 +4047,7 @@ components:
40424047
Duplicated: "#/components/schemas/Duplicated"
40434048
UnknownAdditionalData: "#/components/schemas/UnknownAdditionalData"
40444049
OutOfImageBounds: "#/components/schemas/OutOfImageBounds"
4050+
OverlappedRangeAnnotation: "#/components/schemas/OverlappedRangeAnnotation"
40454051
UnknownLabel: "#/components/schemas/UnknownLabel"
40464052
InvalidAnnotationData:
40474053
type: object
@@ -4167,6 +4173,18 @@ components:
41674173
type: string
41684174
description: OutOfImageBounds
41694175
example: "OutOfImageBounds"
4176+
OverlappedRangeAnnotation:
4177+
type: object
4178+
description: 区間が重複しているアノテーションが存在している場合に発生するエラー
4179+
properties:
4180+
labelId:
4181+
type: string
4182+
annotationId:
4183+
type: string
4184+
_type:
4185+
type: string
4186+
description: OverlappedRangeAnnotation
4187+
example: "OverlappedRangeAnnotation"
41704188
UnknownLabel:
41714189
type: object
41724190
description: 何らかの原因で、アノテーション仕様にないラベルがついているエラー

generate/swagger/swagger.v2.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ info:
115115
116116
上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。
117117
118-
version: 0.90.0
118+
version: 0.90.2
119119
title: AnnoFab Web API
120120
x-logo:
121121
url: "https://annofab.com/images/logo_landscape.png"

generate/swagger/swagger.yaml

+10-2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ info:
102102
"_type": "CountResult",
103103
"name": "account_id_count",
104104
"field": "account_id",
105+
"docCount": 15,
105106
"items": [
106107
{"key":"c5eee002", "count":9, "aggregations":[], "_type":"..."},
107108
{"key":"9f110e48", "count":5, "aggregations":[], "_type":"..."},
@@ -113,8 +114,9 @@ info:
113114
```
114115
115116
上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。
117+
また、AggregationResultの集約の件数は、合計で10000件以下に制限されており、それを超える件数がある場合は上位10000件が取得されます。もし、省略された部分を取得したい場合は、検索条件を縛って結果に上る集約の数を減らしてください。
116118
117-
version: 0.90.0
119+
version: 0.90.2
118120
title: AnnoFab Web API
119121
x-logo:
120122
url: "https://annofab.com/images/logo_landscape.png"
@@ -2592,7 +2594,7 @@ paths:
25922594
$ref: "swagger-api-components.yaml#/components/responses/ErrorMissingResource"
25932595
"503":
25942596
$ref: "swagger-api-components.yaml#/components/responses/ErrorUnderMaintenance"
2595-
/projects/{project_id}/jobs/gen-inputs/{job_id}:
2597+
/projects/{project_id}/jobs/{job_type}/{job_id}:
25962598
delete:
25972599
tags:
25982600
- af-job
@@ -2611,6 +2613,12 @@ paths:
26112613
required: true
26122614
schema:
26132615
$ref: "swagger-api-components.yaml#/components/schemas/ProjectId"
2616+
- name: job_type
2617+
in: path
2618+
description: ジョブの種別。[詳細はこちら](#section/JobType)。
2619+
required: true
2620+
schema:
2621+
$ref: "swagger-api-components.yaml#/components/schemas/JobType"
26142622
- name: job_id
26152623
in: path
26162624
description: ジョブID

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "annofabapi"
3-
version = "0.35.0"
3+
version = "0.36.0"
44
description = "Python Clinet Library of AnnoFab WebAPI (https://annofab.com/docs/api/)"
55
authors = ["yuji38kwmt <[email protected]>"]
66
maintainers = ["yuji38kwmt <[email protected]>"]

tests/conftest.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@
55

66
def pytest_addoption(parser):
77
parser.addoption("--run_submitting_job", action="store_true", default=False, help="ジョブを投げるテストを実行する。")
8+
parser.addoption("--run_side_effect", action="store_true", default=False, help="副作用のあるテストを実行する。")
89
parser.addoption("--print_log_annofabapi", action="store_true", default=False, help="annofabapiモジュールのログを表示する。")
910

1011

1112
def pytest_configure(config):
1213
config.addinivalue_line("markers", "submitting_job: mark test with submitting job")
14+
config.addinivalue_line("markers", "side_effect: mark test with side effect")
1315

1416

1517
def pytest_collection_modifyitems(config, items):
16-
if config.getoption("--run_submitting_job"):
17-
return
18-
skip_slow = pytest.mark.skip(reason="need --sun_submitting_job option to run")
18+
run_submitting_job = config.getoption("--run_submitting_job")
19+
run_side_effect = config.getoption("--run_side_effect")
20+
21+
skip_slow_submitting_job = pytest.mark.skip(reason="need --run_submitting_job option to run")
22+
skip_slow_side_effect = pytest.mark.skip(reason="need --run_side_effect option to run")
1923
for item in items:
20-
if "submitting_job" in item.keywords:
21-
item.add_marker(skip_slow)
24+
if not run_submitting_job and "submitting_job" in item.keywords:
25+
item.add_marker(skip_slow_submitting_job)
26+
if not run_side_effect and "side_effect" in item.keywords:
27+
item.add_marker(skip_slow_side_effect)
2228

2329

2430
def pytest_cmdline_main(config):

tests/test_api.py

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import pytest
1515
import requests
16+
from more_itertools import first_true
1617

1718
import annofabapi
1819
import annofabapi.utils
@@ -178,6 +179,18 @@ def test_delete_all_succeeded_job(self):
178179
def test_job_in_progress(self):
179180
assert type(wrapper.job_in_progress(project_id, JobType.GEN_TASKS)) == bool
180181

182+
@pytest.mark.submitting_job
183+
def test_delete_project_job(self):
184+
content, _ = api.post_project_tasks_update(project_id, {"v": "2"})
185+
job = content["job"]
186+
job_type = job["job_type"]
187+
job_id = job["job_id"]
188+
job_list = wrapper.get_all_project_job(project_id, {"type": job_type})
189+
assert first_true(job_list, pred=lambda e: e["job_id"] == job_id) is not None
190+
api.delete_project_job(project_id, job_type=job["job_type"], job_id=job["job_id"])
191+
job_list = wrapper.get_all_project_job(project_id, {"type": job_type})
192+
assert first_true(job_list, pred=lambda e: e["job_id"] == job_id) is None
193+
181194

182195
class TestLogin:
183196
def test_login(self):
@@ -367,6 +380,7 @@ def test_put_task_and_delete_task(self):
367380

368381
assert type(api.delete_task(project_id, test_task_id)[0]) == dict
369382

383+
@pytest.mark.side_effect
370384
def test_assign_task(self):
371385
request_body = {"request_type": {"phase": "annotation", "_type": "Random"}}
372386
assert type(api.assign_tasks(project_id, request_body=request_body)[0]) == list

0 commit comments

Comments
 (0)