Skip to content

AnnoFab 0.64.1に対応 #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* 現在、APIは開発途上版です。予告なく互換性のない変更がある可能性をご了承ください。
* put, post, delete系のメソッドを間違えて実行してしまわないよう、注意してください。特に「プロジェクト削除」や「アノテーション仕様更新」のAPIには十分注意してください。


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

# Features
cURLやPostmanなどよりも簡単にAnnoFab Web APIにアクセスできます。
Expand Down
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.19.5'
__version__ = '0.20.0'
3 changes: 3 additions & 0 deletions annofabapi/dataclass/annotation_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ class AnnotationSpecsHistory:
"""

"""
history_id: Optional[str]
""""""

project_id: Optional[str]
"""プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

Expand Down
3 changes: 3 additions & 0 deletions annofabapi/dataclass/project_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ class ProjectMember:

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

sampling_acceptance_rate: Optional[int]
"""メンバー固有の抜取受入率。"""
13 changes: 10 additions & 3 deletions annofabapi/generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ def put_annotation(self, project_id: str, task_id: str, input_data_id: str, requ
# NOTE: This method is auto generated by OpenAPI Generator
#########################################

def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests.Response]:
def get_annotation_specs(self, project_id: str, query_params: Optional[Dict[str, Any]] = None,
**kwargs) -> Tuple[Any, requests.Response]:
"""アノテーション仕様取得


Expand All @@ -508,6 +509,8 @@ def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests

Args:
project_id (str): プロジェクトID (required)
query_params (Dict[str, Any]): Query Parameters
history_id (str): 過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。 未指定時は最新のアノテーション仕様を取得します。

Returns:
Tuple[AnnotationSpecs, requests.Response]
Expand All @@ -516,7 +519,9 @@ def get_annotation_specs(self, project_id: str, **kwargs) -> Tuple[Any, requests
"""
url_path = f'/projects/{project_id}/annotation-specs'
http_method = 'GET'
keyword_params: Dict[str, Any] = {}
keyword_params: Dict[str, Any] = {
'query_params': query_params,
}
return self._request_wrapper(http_method, url_path, **keyword_params)

def get_annotation_specs_histories(self, project_id: str, **kwargs) -> Tuple[Any, requests.Response]:
Expand Down Expand Up @@ -2189,11 +2194,12 @@ def get_task_histories(self, project_id: str, task_id: str, **kwargs) -> Tuple[A
def get_task_validation(self, project_id: str, task_id: str, **kwargs) -> Tuple[Any, requests.Response]:
"""タスク自動検査

.. deprecated:: X

authorizations: AllProjectMember


指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。
指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。 [タスクの状態遷移](#operation/operateTask)の際に検査を行うようになったので、本APIは非推奨となります。

Args:
project_id (str): プロジェクトID (required)
Expand All @@ -2204,6 +2210,7 @@ def get_task_validation(self, project_id: str, task_id: str, **kwargs) -> Tuple[


"""
warnings.warn("deprecated", DeprecationWarning)
url_path = f'/projects/{project_id}/tasks/{task_id}/validation'
http_method = 'GET'
keyword_params: Dict[str, Any] = {}
Expand Down
1 change: 1 addition & 0 deletions annofabapi/generated_api2.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_annotation_specs_v2(self, project_id: str, query_params: Optional[Dict[s
project_id (str): プロジェクトID (required)
query_params (Dict[str, Any]): Query Parameters
cache (str): CACHE TIMESTAMP
history_id (str): 過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。 未指定時は最新のアノテーション仕様を取得します。

Returns:
Tuple[AnnotationSpecs, requests.Response]
Expand Down
2 changes: 2 additions & 0 deletions annofabapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ class AnnotationDataHoldingType(Enum):

Kyes of Dict

* history_id: str

* project_id: str
プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID)
* updated_datetime: str
Expand Down
4 changes: 4 additions & 0 deletions annofabapi/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import urllib
import urllib.parse
import warnings
from typing import Any, Callable, Dict, List, Optional, Tuple # pylint: disable=unused-import

import requests
Expand Down Expand Up @@ -167,13 +168,16 @@ def get_annotation_specs_from_url(self, project_id: str, url: str) -> Annotation
"""
アノテーション仕様の履歴から取得したURLから、アノテーション仕様を取得する

.. deprecated:: `get_annotation_specs`から過去のアノテーション仕様を取得できるようになったので、廃止する。2019/11/01以降に廃止する予定。

Args:
project_id: プロジェクトID
url: アノテーション仕様の履歴から取得したURL

Returns:
put_annotation_specsのContent
"""
warnings.warn("deprecated", DeprecationWarning)
cookies, _ = self.api._get_signed_cookie(project_id)
kwargs = self.api._create_kwargs()
kwargs.update({"cookies": cookies})
Expand Down
2 changes: 2 additions & 0 deletions generate/swagger/swagger-api-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,8 @@
AnnotationSpecsHistory:
type: object
properties:
history_id:
type: string
project_id:
$ref: "#/components/schemas/ProjectId"
updated_datetime:
Expand Down
13 changes: 12 additions & 1 deletion generate/swagger/swagger.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ info:
検査ID | プロジェクト内で一意
WebhookID | プロジェクト内で一意

version: 0.64.0
version: 0.64.1
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -543,6 +543,15 @@ paths:
schema:
type: string
example: "123456789"
- name: history_id
in: query
description: |
過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。
未指定時は最新のアノテーション仕様を取得します。
required: false
schema:
type: string
example: "123456789"
responses:
200:
description: 正常
Expand Down Expand Up @@ -2065,6 +2074,8 @@ components:
AnnotationSpecsHistory:
type: object
properties:
history_id:
type: string
project_id:
$ref: "#/components/schemas/ProjectId"
updated_datetime:
Expand Down
15 changes: 14 additions & 1 deletion generate/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ info:

アノテーションは、各プロジェクトのトップページでダウンロードできます。また、上記リンク先のAPIでも取得できます。

version: 0.64.0
version: 0.64.1
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down Expand Up @@ -2265,6 +2265,15 @@ paths:
required: true
schema:
$ref: "#/components/schemas/ProjectId"
- name: history_id
in: query
description: |
過去のアノテーション仕様を取得する場合、[アノテーション仕様履歴取得](#operation/getAnnotationSpecsHistories)APIで取得した `history_id` の値を指定します。
未指定時は最新のアノテーション仕様を取得します。
required: false
schema:
type: string
example: "123456789"
responses:
200:
description: 正常
Expand Down Expand Up @@ -3008,11 +3017,13 @@ paths:
$ref: "#/components/responses/ErrorUnderMaintenance"
/projects/{project_id}/tasks/{task_id}/validation:
get:
deprecated: true
tags:
- af-task
summary: タスク自動検査
description: |
指定したタスクの自動検査で見つかった警告やエラーを一括で取得します。
[タスクの状態遷移](#operation/operateTask)の際に検査を行うようになったので、本APIは非推奨となります。
security:
- AllProjectMember: []
operationId: getTaskValidation
Expand Down Expand Up @@ -6009,6 +6020,8 @@ components:
AnnotationSpecsHistory:
type: object
properties:
history_id:
type: string
project_id:
$ref: "#/components/schemas/ProjectId"
updated_datetime:
Expand Down
9 changes: 3 additions & 6 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def test_annotation_specs():
annotation_specs_histories = api.get_annotation_specs_histories(project_id)[0]
assert type(annotation_specs_histories) == list

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


def test_login():
Expand Down Expand Up @@ -356,9 +356,6 @@ def test_task():
print(f"get_task_histories")
assert len(api.get_task_histories(project_id, test_task_id)[0]) > 0

print(f"get_task_validation")
assert type(api.get_task_validation(project_id, test_task_id)[0]) == dict

print(f"delete_task")
assert type(api.delete_task(project_id, test_task_id)[0]) == dict

Expand Down
4 changes: 0 additions & 4 deletions tests/test_local_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import datetime

from annofabapi.utils import to_iso8601_extension

# timezonが異なる場所だとテストに失敗するので、コメントアウトする
# def test_to_iso8601_extension():
# d = datetime.datetime(2019, 10, 8, 16, 20, 8, 241762)
Expand Down