Skip to content

Commit 265a398

Browse files
authored
Annofab v0.95.7対応 (#230)
* update annofab api * add test method * version up * support python 3.9 * update poetry * update test data * update pypi classification * python3.9にtravisが対応していなかったので、もとに戻す
1 parent cb0d2f0 commit 265a398

File tree

13 files changed

+289
-69
lines changed

13 files changed

+289
-69
lines changed

annofabapi/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.38.11"
1+
__version__ = "0.39.0"

annofabapi/dataclass/project.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ class ProjectConfiguration(DataClassJsonMixin):
6060
private_storage_aws_iam_role_arn: Optional[str]
6161
"""AWS IAMロール。ビジネスプランでのS3プライベートストレージの認可で使います。 [S3プライベートストレージの認可の設定についてはこちら](/docs/faq/#m0b240)をご覧ください。 """
6262

63+
plugin_id: Optional[str]
64+
"""プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
65+
66+
custom_task_assignment_plugin_id: Optional[str]
67+
"""プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
68+
6369

6470
@dataclass
6571
class Project(DataClassJsonMixin):

annofabapi/dataclass/task.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,6 @@ class Task(DataClassJsonMixin):
113113

114114
sampling: Optional[str]
115115
"""* `inspection_skipped` - このタスクが抜取検査の対象外となり、検査フェーズをスキップしたことを表す。 * `inspection_stages_skipped` - このタスクが抜取検査の対象外となり、検査フェーズのステージを一部スキップしたことを表す。 * `acceptance_skipped` - このタスクが抜取検査の対象外となり、受入フェーズをスキップしたことを表す。 * `inspection_and_acceptance_skipped` - このタスクが抜取検査の対象外となり、検査・受入フェーズをスキップしたことを表す 未指定時はこのタスクが抜取検査の対象となったことを表す。(通常のワークフローを通過する) """
116+
117+
metadata: Optional[Dict[str, Any]]
118+
"""ユーザーが自由に登録できるkey-value型のメタデータです。 keyにはメタデータ名、valueには値を指定してください。 valueには文字列、数値、真偽値を指定できます。 """

annofabapi/generated_api.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ def get_input_data_list(
711711
Args:
712712
project_id (str): プロジェクトID (required)
713713
query_params (Dict[str, Any]): Query Parameters
714-
input_data_id (str): 入力データIDでの部分一致検索で使用。1文字以上あれば使用します。
715-
input_data_name (str): 入力データ名での部分一致検索で使用。1文字以上あれば使用します。
714+
input_data_id (str): 入力データIDでの部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。
715+
input_data_name (str): 入力データ名での部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。
716716
input_data_path (str): 入力データパスでの部分一致検索で使用。1文字以上あれば使用します。
717-
task_id (str): 入力データが紐づくタスクIDの部分一致検索で使用。1文字以上あれば使用します。条件に合致した先頭100件のタスクに使われている入力データを検索します。
717+
task_id (str): 入力データが紐づくタスクIDの部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。条件に合致した先頭100件のタスクに使われている入力データを検索します。
718718
_from (str): 更新日時での範囲検索で使用(ISO 8601 拡張形式)
719719
to (str): 更新日時での範囲検索で使用(ISO 8601 拡張形式)
720720
page (int): 検索結果のうち、取得したいページの番号(1始まり)
@@ -2791,6 +2791,35 @@ def operate_task(
27912791
}
27922792
return self._request_wrapper(http_method, url_path, **keyword_params)
27932793

2794+
def patch_tasks_metadata(
2795+
self, project_id: str, request_body: Optional[Any] = None, **kwargs
2796+
) -> Tuple[Any, requests.Response]:
2797+
"""タスクメタデータの一括更新
2798+
https://annofab.com/docs/api/#operation/patchTasksMetadata
2799+
2800+
2801+
authorizations: ProjectDataUser
2802+
2803+
2804+
複数の既存タスクのメタデータを一括更新します。
2805+
2806+
Args:
2807+
project_id (str): プロジェクトID (required)
2808+
request_body (Any): Request Body
2809+
request_body (dict(str, __DictStrKeyAnyValue__)): (required)
2810+
2811+
Returns:
2812+
Tuple[Message, requests.Response]
2813+
2814+
2815+
"""
2816+
url_path = f"/projects/{project_id}/tasks/metadata"
2817+
http_method = "PATCH"
2818+
keyword_params: Dict[str, Any] = {
2819+
"request_body": request_body,
2820+
}
2821+
return self._request_wrapper(http_method, url_path, **keyword_params)
2822+
27942823
def put_task(
27952824
self, project_id: str, task_id: str, request_body: Optional[Any] = None, **kwargs
27962825
) -> Tuple[Any, requests.Response]:

annofabapi/models.py

Lines changed: 36 additions & 5 deletions
Large diffs are not rendered by default.

generate/swagger/swagger-api-components.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ components:
627627
required:
628628
- organization_id
629629
- plugin_id
630+
- plugin_type
630631
- compatible_input_data_types
631632
- created_datetime
632633
- updated_datetime
@@ -635,12 +636,16 @@ components:
635636
$ref: "#/components/schemas/OrganizationId"
636637
plugin_id:
637638
$ref: "#/components/schemas/PluginId"
639+
plugin_type:
640+
$ref: "#/components/schemas/PluginType"
638641
plugin_name:
639642
$ref: "#/components/schemas/PluginName"
640643
description:
641644
$ref: "#/components/schemas/PluginDescription"
642645
annotation_editor_url:
643646
$ref: "#/components/schemas/AnnotationEditorUrl"
647+
task_assignment_url:
648+
$ref: "#/components/schemas/TaskAssignmentUrl"
644649
compatible_input_data_types:
645650
$ref: "#/components/schemas/PluginCompatibleInputDataTypes"
646651
created_datetime:
@@ -652,14 +657,19 @@ components:
652657
PutOrganizationPluginRequest:
653658
type: object
654659
required:
660+
- plugin_type
655661
- compatible_input_data_types
656662
properties:
663+
plugin_type:
664+
$ref: "#/components/schemas/PluginType"
657665
plugin_name:
658666
$ref: "#/components/schemas/PluginName"
659667
description:
660668
$ref: "#/components/schemas/PluginDescription"
661669
annotation_editor_url:
662670
$ref: "#/components/schemas/AnnotationEditorUrl"
671+
task_assignment_url:
672+
$ref: "#/components/schemas/TaskAssignmentUrl"
663673
compatible_input_data_types:
664674
$ref: "#/components/schemas/PluginCompatibleInputDataTypes"
665675
last_updated_datetime:
@@ -669,6 +679,15 @@ components:
669679
example: "12345678-abcd-1234-abcd-1234abcd5678"
670680
description: |
671681
プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID)
682+
PluginType:
683+
type: string
684+
enum:
685+
- custom_annotation_editor
686+
- custom_task_assignment
687+
description: |
688+
プラグイン種別。
689+
* `custom_annotation_editor` - カスタムアノテーションエディタ用のプラグインを表します。
690+
* `custom_task_assignment` - カスタムタスク割当用のプラグインを表します。
672691
PluginName:
673692
type: string
674693
example: "foo-bar"
@@ -688,12 +707,14 @@ components:
688707
example: ["custom"]
689708
description: |
690709
プラグインが対応している入力データです。
710+
プラグイン種別がカスタムアノテーションエディタの場合のみ有効です。
691711
AnnotationEditorUrl:
692712
type: string
693713
example: "https://example.com/my/editors?p={projectId}&t={taskId}"
694714
description: |
695715
カスタムアノテーションエディタでタスクを開くための URL です。
696716
プラグインを使用するプロジェクトのタスク一覧などで使用されます。
717+
プラグイン種別がカスタムアノテーションエディタの場合のみ有効です。
697718
698719
この URL には、タスクを特定するための以下のパラメータを必ず埋め込んでください。
699720
@@ -704,6 +725,57 @@ components:
704725
705726
* `{inputDataId}`: アノテーション一覧などから、特定の入力データにフォーカスした状態でタスクを開くときなどに指定します。
706727
* `{annotationId}`: アノテーション一覧などから、特定のアノテーションにフォーカスした状態でタスクを開くときなどに指定します。
728+
TaskAssignmentUrl:
729+
type: string
730+
example: "https://example.com/my/editors?p={projectId}&t={taskId}"
731+
description: |
732+
「カスタムタスク割当API」のURLです。
733+
プラグイン種別がカスタムタスク割当の場合のみ有効です。
734+
735+
#### カスタムタスク割当APIについて。
736+
737+
* 独自のアルゴリズムで作業者にタスクを割当するAPIです。
738+
* AnnoFabから提供されるものではなく、第三者 (ユーザー様) が用意します。
739+
* 作業者がタスク一覧やアノテーションエディタのタスク取得ボタンを押すと、指定したURLに複数の情報 (※1) と共にHTTPリクエスト (POST) が送られます。
740+
* カスタムタスク割当APIでは、AnnoFabで提供しているAPI (※2) を使用して作業者にタスクを割当してください。
741+
* タスクの割当に成功した場合は以下のHTTPレスポンスを返却してください。
742+
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
743+
* レスポンスボディ: 割当した単一のタスク
744+
* ステータスコード: 200
745+
* 作業者に割当できるタスクがない場合は以下のHTTPレスポンスを返却してください。
746+
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
747+
* レスポンスボディ: `{"errors": [{"error_code": "MISSING_RESOURCE"}]}`
748+
* ステータスコード: 404
749+
* 作業者の認証トークンの期限が切れている場合があります。その場合は以下のHTTPレスポンスを返却してください。
750+
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
751+
* レスポンスボディ: `{"errors": [{"error_code": "EXPIRED_TOKEN"}]}`
752+
* ステータスコード: 401
753+
754+
#### Preflightリクエストについて。
755+
756+
* AnnoFabからカスタムタスク割当APIへCross-OriginなHTTPリクエストを送信するより前に、ブラウザの仕様により「Preflightリクエスト」と呼ばれるHTTPリクエストが送られます。
757+
* カスタムタスク割当を利用するためには、カスタムタスク割当APIとは別に「Preflightリクエスト対応API」を用意する必要があります。
758+
* 以下の要件を満たす「Preflightリクエスト対応API」を用意してください。
759+
* URL: カスタムタスク割当APIと同じURL
760+
* HTTPメソッド: OPTIONS
761+
* レスポンスヘッダ:
762+
* `Access-Control-Allow-Origin: https://annofab.com`
763+
* `Access-Control-Allow-Headers: Content-Type`
764+
* レスポンスボディ: 空(から)
765+
* ステータスコード: 200
766+
767+
※1 以下の情報が送られます。
768+
769+
* HTTPボディ (JSON形式)
770+
* `authorization_token` : 作業者の認証トークン。AnnoFabのAPIを利用する際に使用します。
771+
* `project_id` : タスクの割当リクエストが行われたプロジェクトのID。
772+
* `phase` : 作業者が割当を要求したタスクフェーズ。このフェーズのタスクを割当してください。
773+
774+
※2 例えば以下のAPIがあります。(詳しい情報はAPIドキュメントを参照してください)
775+
776+
* `getMyAccount` : 作業者のアカウント情報を取得できます。
777+
* `getTasks` : プロジェクトのタスクを取得できます。
778+
* `assignTasks` : 作業者にタスクを割当することができます。
707779
708780
MyOrganization:
709781
type: object
@@ -1011,6 +1083,14 @@ components:
10111083
AWS IAMロール。ビジネスプランでのS3プライベートストレージの認可で使います。
10121084
[S3プライベートストレージの認可の設定についてはこちら](/docs/faq/#m0b240)をご覧ください。
10131085
example: "arn:aws:iam::123456789012:role/AnnoFabPrivateStorageAccessor"
1086+
plugin_id:
1087+
$ref: "#/components/schemas/PluginId"
1088+
description: |
1089+
カスタムアノテーションエディタのプラグインID。カスタムプロジェクトの場合は必須です。
1090+
custom_task_assignment_plugin_id:
1091+
$ref: "#/components/schemas/PluginId"
1092+
description: |
1093+
`task_assignment_type`に`custom`を設定している場合のみ、カスタムタスク割当のプラグインIDを設定してください。
10141094
ProjectSummary:
10151095
type: object
10161096
properties:
@@ -1025,12 +1105,14 @@ components:
10251105
- random
10261106
- selection
10271107
- random_and_selection
1108+
- custom
10281109
description: |
10291110
プロジェクトで使用するタスクの割当方式。
10301111
10311112
* `random` - タスクフェーズのみを指定してランダムにタスクを自身に割当する方式です。
10321113
* `selection` - 担当者とタスクを明示的に指定してタスクを割当する方式です。プロジェクトオーナーもしくはチェッカーのみ、自身以外のプロジェクトメンバーを担当者に指定できます。
10331114
* `random_and_selection` - ランダム割当と選択割当の両機能を使用する方式です。
1115+
* `custom` - タスク割当アルゴリズム (API) を独自に定義してタスクを割当する方式です。
10341116
JobInfo:
10351117
type: object
10361118
properties:
@@ -1608,6 +1690,12 @@ components:
16081690
}
16091691
no_label:
16101692
$ref: "#/components/schemas/InspectionStatisticsPhrases"
1693+
PatchTasksMetadataRequest:
1694+
type: object
1695+
description: タスクIDとメタデータのkey-valueペア(Dictionary)です。
1696+
additionalProperties: {
1697+
$ref: "#/components/schemas/TaskMetadata"
1698+
}
16111699
InspectionStatisticsPhrases:
16121700
type: object
16131701
description: ラベル外指摘の集計結果
@@ -2490,6 +2578,8 @@ components:
24902578
* `inspection_and_acceptance_skipped` - このタスクが抜取検査の対象外となり、検査・受入フェーズをスキップしたことを表す
24912579
24922580
未指定時はこのタスクが抜取検査の対象となったことを表す。(通常のワークフローを通過する)
2581+
metadata:
2582+
$ref: "#/components/schemas/TaskMetadata"
24932583
TaskPhase:
24942584
type: string
24952585
enum:
@@ -2521,15 +2611,24 @@ components:
25212611
* `complete` - 完了。次のフェーズへ進む
25222612
* `rejected` - 差戻し。修正のため、`annotation`フェーズへ戻る。[operateTask](#operation/operateTask) APIのリクエストボディに渡すときのみ利用する。その他のAPIのリクエストやレスポンスには使われない。
25232613
* `cancelled` - 提出取消し。修正のため、前フェーズへ戻る。[operateTask](#operation/operateTask) APIのリクエストボディに渡すときのみ利用する。その他のAPIのリクエストやレスポンスには使われない。
2614+
TaskMetadata:
2615+
type: object
2616+
description: |
2617+
ユーザーが自由に登録できるkey-value型のメタデータです。
2618+
keyにはメタデータ名、valueには値を指定してください。
2619+
valueには文字列、数値、真偽値を指定できます。
25242620
TaskRequest:
25252621
type: object
25262622
required:
25272623
- input_data_id_list
2624+
- metadata
25282625
properties:
25292626
input_data_id_list:
25302627
type: array
25312628
items:
25322629
$ref: "#/components/schemas/InputDataId"
2630+
metadata:
2631+
$ref: "#/components/schemas/TaskMetadata"
25332632
TaskGenerateRequest:
25342633
type: object
25352634
required:

generate/swagger/swagger.v2.yaml

Lines changed: 1 addition & 1 deletion
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.94.7
118+
version: 0.95.7
119119
title: AnnoFab Web API
120120
x-logo:
121121
url: "https://annofab.com/images/logo_landscape.png"

0 commit comments

Comments
 (0)