Skip to content

Commit 5156621

Browse files
authored
Merge pull request #74 from kurusugawa-computer/fix/v0.20.0
AnnoFab 0.64.1に対応
2 parents 807ce0f + 1f2d6ee commit 5156621

13 files changed

+59
-17
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
* 現在、APIは開発途上版です。予告なく互換性のない変更がある可能性をご了承ください。
1616
* put, post, delete系のメソッドを間違えて実行してしまわないよう、注意してください。特に「プロジェクト削除」や「アノテーション仕様更新」のAPIには十分注意してください。
1717

18-
18+
## 廃止予定
19+
* `wraapper.py get_annotation_specs_from_url`
20+
* 廃止理由:過去のアノテーション仕様を`get_annotation_specs`メソッドから取得できるようになったため
21+
* 廃止予定日:2019/11/01以降
1922

2023
# Features
2124
cURLやPostmanなどよりも簡単にAnnoFab Web APIにアクセスできます。

annofabapi/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.19.5'
1+
__version__ = '0.20.0'

annofabapi/dataclass/annotation_specs.py

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ class AnnotationSpecsHistory:
116116
"""
117117
118118
"""
119+
history_id: Optional[str]
120+
""""""
121+
119122
project_id: Optional[str]
120123
"""プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
121124

annofabapi/dataclass/project_member.py

+3
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ class ProjectMember:
4949

5050
sampling_inspection_rate: Optional[int]
5151
"""メンバー固有の抜取検査率。0-100のパーセント値で指定する。値が指定された場合、プロジェクトの抜取検査率を指定の値で上書きする。"""
52+
53+
sampling_acceptance_rate: Optional[int]
54+
"""メンバー固有の抜取受入率。"""

annofabapi/generated_api.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ def put_annotation(self, project_id: str, task_id: str, input_data_id: str, requ
498498
# NOTE: This method is auto generated by OpenAPI Generator
499499
#########################################
500500

501-
def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests.Response]:
501+
def get_annotation_specs(self, project_id: str, query_params: Optional[Dict[str, Any]] = None,
502+
**kwargs) -> Tuple[Any, requests.Response]:
502503
"""アノテーション仕様取得
503504
504505
@@ -508,6 +509,8 @@ def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests
508509
509510
Args:
510511
project_id (str): プロジェクトID (required)
512+
query_params (Dict[str, Any]): Query Parameters
513+
history_id (str): 過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。 未指定時は最新のアノテーション仕様を取得します。
511514
512515
Returns:
513516
Tuple[AnnotationSpecs, requests.Response]
@@ -516,7 +519,9 @@ def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests
516519
"""
517520
url_path = f'/projects/{project_id}/annotation-specs'
518521
http_method = 'GET'
519-
keyword_params: Dict[str, Any] = {}
522+
keyword_params: Dict[str, Any] = {
523+
'query_params': query_params,
524+
}
520525
return self._request_wrapper(http_method, url_path, **keyword_params)
521526

522527
def get_annotation_specs_histories(self, project_id: str, **kwargs) -> Tuple[Any, requests.Response]:
@@ -2189,11 +2194,12 @@ def get_task_histories(self, project_id: str, task_id: str, **kwargs) -> Tuple[A
21892194
def get_task_validation(self, project_id: str, task_id: str, **kwargs) -> Tuple[Any, requests.Response]:
21902195
"""タスク自動検査
21912196
2197+
.. deprecated:: X
21922198
21932199
authorizations: AllProjectMember
21942200
21952201
2196-
指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。
2202+
指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。 [タスクの状態遷移](#operation/operateTask)の際に検査を行うようになったので、本APIは非推奨となります。
21972203
21982204
Args:
21992205
project_id (str): プロジェクトID (required)
@@ -2204,6 +2210,7 @@ def get_task_validation(self, project_id: str, task_id: str, **kwargs) -> Tuple[
22042210
22052211
22062212
"""
2213+
warnings.warn("deprecated", DeprecationWarning)
22072214
url_path = f'/projects/{project_id}/tasks/{task_id}/validation'
22082215
http_method = 'GET'
22092216
keyword_params: Dict[str, Any] = {}

annofabapi/generated_api2.py

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_annotation_specs_v2(self, project_id: str, query_params: Optional[Dict[s
4444
project_id (str): プロジェクトID (required)
4545
query_params (Dict[str, Any]): Query Parameters
4646
cache (str): CACHE TIMESTAMP
47+
history_id (str): 過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。 未指定時は最新のアノテーション仕様を取得します。
4748
4849
Returns:
4950
Tuple[AnnotationSpecs, requests.Response]

annofabapi/models.py

+2
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ class AnnotationDataHoldingType(Enum):
527527
528528
Kyes of Dict
529529
530+
* history_id: str
531+
530532
* project_id: str
531533
プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID)
532534
* updated_datetime: str

annofabapi/wrapper.py

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55
import urllib
66
import urllib.parse
7+
import warnings
78
from typing import Any, Callable, Dict, List, Optional, Tuple # pylint: disable=unused-import
89

910
import requests
@@ -167,13 +168,16 @@ def get_annotation_specs_from_url(self, project_id: str, url: str) -> Annotation
167168
"""
168169
アノテーション仕様の履歴から取得したURLから、アノテーション仕様を取得する
169170
171+
.. deprecated:: `get_annotation_specs`から過去のアノテーション仕様を取得できるようになったので、廃止する。2019/11/01以降に廃止する予定。
172+
170173
Args:
171174
project_id: プロジェクトID
172175
url: アノテーション仕様の履歴から取得したURL
173176
174177
Returns:
175178
put_annotation_specsのContent
176179
"""
180+
warnings.warn("deprecated", DeprecationWarning)
177181
cookies, _ = self.api._get_signed_cookie(project_id)
178182
kwargs = self.api._create_kwargs()
179183
kwargs.update({"cookies": cookies})

generate/swagger/swagger-api-components.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,8 @@
15061506
AnnotationSpecsHistory:
15071507
type: object
15081508
properties:
1509+
history_id:
1510+
type: string
15091511
project_id:
15101512
$ref: "#/components/schemas/ProjectId"
15111513
updated_datetime:

generate/swagger/swagger.v2.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ info:
7575
検査ID | プロジェクト内で一意
7676
WebhookID | プロジェクト内で一意
7777
78-
version: 0.64.0
78+
version: 0.64.1
7979
title: AnnoFab Web API
8080
x-logo:
8181
url: "https://annofab.com/images/logo_landscape.png"
@@ -543,6 +543,15 @@ paths:
543543
schema:
544544
type: string
545545
example: "123456789"
546+
- name: history_id
547+
in: query
548+
description: |
549+
過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。
550+
未指定時は最新のアノテーション仕様を取得します。
551+
required: false
552+
schema:
553+
type: string
554+
example: "123456789"
546555
responses:
547556
200:
548557
description: 正常
@@ -2065,6 +2074,8 @@ components:
20652074
AnnotationSpecsHistory:
20662075
type: object
20672076
properties:
2077+
history_id:
2078+
type: string
20682079
project_id:
20692080
$ref: "#/components/schemas/ProjectId"
20702081
updated_datetime:

generate/swagger/swagger.yaml

+14-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ info:
9898
9999
アノテーションは、各プロジェクトのトップページでダウンロードできます。また、上記リンク先のAPIでも取得できます。
100100
101-
version: 0.64.0
101+
version: 0.64.1
102102
title: AnnoFab Web API
103103
x-logo:
104104
url: "https://annofab.com/images/logo_landscape.png"
@@ -2265,6 +2265,15 @@ paths:
22652265
required: true
22662266
schema:
22672267
$ref: "#/components/schemas/ProjectId"
2268+
- name: history_id
2269+
in: query
2270+
description: |
2271+
過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。
2272+
未指定時は最新のアノテーション仕様を取得します。
2273+
required: false
2274+
schema:
2275+
type: string
2276+
example: "123456789"
22682277
responses:
22692278
200:
22702279
description: 正常
@@ -3008,11 +3017,13 @@ paths:
30083017
$ref: "#/components/responses/ErrorUnderMaintenance"
30093018
/projects/{project_id}/tasks/{task_id}/validation:
30103019
get:
3020+
deprecated: true
30113021
tags:
30123022
- af-task
30133023
summary: タスク自動検査
30143024
description: |
30153025
指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。
3026+
[タスクの状態遷移](#operation/operateTask)の際に検査を行うようになったので、本APIは非推奨となります。
30163027
security:
30173028
- AllProjectMember: []
30183029
operationId: getTaskValidation
@@ -6009,6 +6020,8 @@ components:
60096020
AnnotationSpecsHistory:
60106021
type: object
60116022
properties:
6023+
history_id:
6024+
type: string
60126025
project_id:
60136026
$ref: "#/components/schemas/ProjectId"
60146027
updated_datetime:

tests/test_api.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def test_annotation_specs():
134134
annotation_specs_histories = api.get_annotation_specs_histories(project_id)[0]
135135
assert type(annotation_specs_histories) == list
136136

137-
old_annotation_specs_url = annotation_specs_histories[0]["url"]
138-
old_annotation_specs = wrapper.get_annotation_specs_from_url(project_id, old_annotation_specs_url)
139-
assert type(old_annotation_specs) == dict
137+
old_annotation_spec, _ = api.get_annotation_specs(
138+
project_id, query_params={"history_id": annotation_specs_histories[1]["history_id"]})
139+
assert type(old_annotation_spec) == dict
140140

141141

142142
def test_login():
@@ -356,9 +356,6 @@ def test_task():
356356
print(f"get_task_histories")
357357
assert len(api.get_task_histories(project_id, test_task_id)[0]) > 0
358358

359-
print(f"get_task_validation")
360-
assert type(api.get_task_validation(project_id, test_task_id)[0]) == dict
361-
362359
print(f"delete_task")
363360
assert type(api.delete_task(project_id, test_task_id)[0]) == dict
364361

tests/test_local_utils.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import datetime
2-
3-
from annofabapi.utils import to_iso8601_extension
4-
51
# timezonが異なる場所だとテストに失敗するので、コメントアウトする
62
# def test_to_iso8601_extension():
73
# d = datetime.datetime(2019, 10, 8, 16, 20, 8, 241762)

0 commit comments

Comments
 (0)