diff --git a/README.md b/README.md index 4f8b4717..cbc34b7e 100644 --- a/README.md +++ b/README.md @@ -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にアクセスできます。 diff --git a/annofabapi/__version__.py b/annofabapi/__version__.py index cd5705a4..2f15b8cd 100644 --- a/annofabapi/__version__.py +++ b/annofabapi/__version__.py @@ -1 +1 @@ -__version__ = '0.19.5' +__version__ = '0.20.0' diff --git a/annofabapi/dataclass/annotation_specs.py b/annofabapi/dataclass/annotation_specs.py index df1792ad..95fdd74e 100644 --- a/annofabapi/dataclass/annotation_specs.py +++ b/annofabapi/dataclass/annotation_specs.py @@ -116,6 +116,9 @@ class AnnotationSpecsHistory: """ """ + history_id: Optional[str] + """""" + project_id: Optional[str] """プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) """ diff --git a/annofabapi/dataclass/project_member.py b/annofabapi/dataclass/project_member.py index f1ab2729..ed5b95b5 100644 --- a/annofabapi/dataclass/project_member.py +++ b/annofabapi/dataclass/project_member.py @@ -49,3 +49,6 @@ class ProjectMember: sampling_inspection_rate: Optional[int] """メンバー固有の抜取検査率。0-100のパーセント値で指定する。値が指定された場合、プロジェクトの抜取検査率を指定の値で上書きする。""" + + sampling_acceptance_rate: Optional[int] + """メンバー固有の抜取受入率。""" diff --git a/annofabapi/generated_api.py b/annofabapi/generated_api.py index d7493bf1..58d00e5f 100644 --- a/annofabapi/generated_api.py +++ b/annofabapi/generated_api.py @@ -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]: """アノテーション仕様取得 @@ -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] @@ -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]: @@ -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) @@ -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] = {} diff --git a/annofabapi/generated_api2.py b/annofabapi/generated_api2.py index 3ab88a44..288d94aa 100644 --- a/annofabapi/generated_api2.py +++ b/annofabapi/generated_api2.py @@ -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] diff --git a/annofabapi/models.py b/annofabapi/models.py index 41840345..9b52d403 100644 --- a/annofabapi/models.py +++ b/annofabapi/models.py @@ -527,6 +527,8 @@ class AnnotationDataHoldingType(Enum): Kyes of Dict +* history_id: str + * project_id: str プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) * updated_datetime: str diff --git a/annofabapi/wrapper.py b/annofabapi/wrapper.py index 3a4b8e6d..ad4e5daa 100644 --- a/annofabapi/wrapper.py +++ b/annofabapi/wrapper.py @@ -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 @@ -167,6 +168,8 @@ 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 @@ -174,6 +177,7 @@ def get_annotation_specs_from_url(self, project_id: str, url: str) -> Annotation 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}) diff --git a/generate/swagger/swagger-api-components.yaml b/generate/swagger/swagger-api-components.yaml index 3edd6011..5b074518 100644 --- a/generate/swagger/swagger-api-components.yaml +++ b/generate/swagger/swagger-api-components.yaml @@ -1506,6 +1506,8 @@ AnnotationSpecsHistory: type: object properties: + history_id: + type: string project_id: $ref: "#/components/schemas/ProjectId" updated_datetime: diff --git a/generate/swagger/swagger.v2.yaml b/generate/swagger/swagger.v2.yaml index 5fc8f934..6066e8aa 100644 --- a/generate/swagger/swagger.v2.yaml +++ b/generate/swagger/swagger.v2.yaml @@ -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" @@ -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: 正常 @@ -2065,6 +2074,8 @@ components: AnnotationSpecsHistory: type: object properties: + history_id: + type: string project_id: $ref: "#/components/schemas/ProjectId" updated_datetime: diff --git a/generate/swagger/swagger.yaml b/generate/swagger/swagger.yaml index b458741f..99be7269 100644 --- a/generate/swagger/swagger.yaml +++ b/generate/swagger/swagger.yaml @@ -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" @@ -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: 正常 @@ -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 @@ -6009,6 +6020,8 @@ components: AnnotationSpecsHistory: type: object properties: + history_id: + type: string project_id: $ref: "#/components/schemas/ProjectId" updated_datetime: diff --git a/tests/test_api.py b/tests/test_api.py index 0c0557dc..18027031 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -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(): @@ -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 diff --git a/tests/test_local_utils.py b/tests/test_local_utils.py index 8e7ea3b5..de768a81 100644 --- a/tests/test_local_utils.py +++ b/tests/test_local_utils.py @@ -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)