Skip to content

Annofab v0.95.7対応 #230

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 8 commits into from
Oct 14, 2020
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
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.38.11"
__version__ = "0.39.0"
6 changes: 6 additions & 0 deletions annofabapi/dataclass/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class ProjectConfiguration(DataClassJsonMixin):
private_storage_aws_iam_role_arn: Optional[str]
"""AWS IAMロール。ビジネスプランでのS3プライベートストレージの認可で使います。 [S3プライベートストレージの認可の設定についてはこちら](/docs/faq/#m0b240)をご覧ください。 """

plugin_id: Optional[str]
"""プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

custom_task_assignment_plugin_id: Optional[str]
"""プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID) """


@dataclass
class Project(DataClassJsonMixin):
Expand Down
3 changes: 3 additions & 0 deletions annofabapi/dataclass/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,6 @@ class Task(DataClassJsonMixin):

sampling: Optional[str]
"""* `inspection_skipped` - このタスクが抜取検査の対象外となり、検査フェーズをスキップしたことを表す。 * `inspection_stages_skipped` - このタスクが抜取検査の対象外となり、検査フェーズのステージを一部スキップしたことを表す。 * `acceptance_skipped` - このタスクが抜取検査の対象外となり、受入フェーズをスキップしたことを表す。 * `inspection_and_acceptance_skipped` - このタスクが抜取検査の対象外となり、検査・受入フェーズをスキップしたことを表す 未指定時はこのタスクが抜取検査の対象となったことを表す。(通常のワークフローを通過する) """

metadata: Optional[Dict[str, Any]]
"""ユーザーが自由に登録できるkey-value型のメタデータです。 keyにはメタデータ名、valueには値を指定してください。 valueには文字列、数値、真偽値を指定できます。 """
35 changes: 32 additions & 3 deletions annofabapi/generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,10 @@ def get_input_data_list(
Args:
project_id (str): プロジェクトID (required)
query_params (Dict[str, Any]): Query Parameters
input_data_id (str): 入力データIDでの部分一致検索で使用。1文字以上あれば使用します。
input_data_name (str): 入力データ名での部分一致検索で使用。1文字以上あれば使用します。
input_data_id (str): 入力データIDでの部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。
input_data_name (str): 入力データ名での部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。
input_data_path (str): 入力データパスでの部分一致検索で使用。1文字以上あれば使用します。
task_id (str): 入力データが紐づくタスクIDの部分一致検索で使用。1文字以上あれば使用します。条件に合致した先頭100件のタスクに使われている入力データを検索します。
task_id (str): 入力データが紐づくタスクIDの部分一致検索で使用。1文字以上あれば使用します。大文字小文字は区別しません。条件に合致した先頭100件のタスクに使われている入力データを検索します。
_from (str): 更新日時での範囲検索で使用(ISO 8601 拡張形式)
to (str): 更新日時での範囲検索で使用(ISO 8601 拡張形式)
page (int): 検索結果のうち、取得したいページの番号(1始まり)
Expand Down Expand Up @@ -2791,6 +2791,35 @@ def operate_task(
}
return self._request_wrapper(http_method, url_path, **keyword_params)

def patch_tasks_metadata(
self, project_id: str, request_body: Optional[Any] = None, **kwargs
) -> Tuple[Any, requests.Response]:
"""タスクメタデータの一括更新
https://annofab.com/docs/api/#operation/patchTasksMetadata


authorizations: ProjectDataUser


複数の既存タスクのメタデータを一括更新します。

Args:
project_id (str): プロジェクトID (required)
request_body (Any): Request Body
request_body (dict(str, __DictStrKeyAnyValue__)): (required)

Returns:
Tuple[Message, requests.Response]


"""
url_path = f"/projects/{project_id}/tasks/metadata"
http_method = "PATCH"
keyword_params: Dict[str, Any] = {
"request_body": request_body,
}
return self._request_wrapper(http_method, url_path, **keyword_params)

def put_task(
self, project_id: str, task_id: str, request_body: Optional[Any] = None, **kwargs
) -> Tuple[Any, requests.Response]:
Expand Down
41 changes: 36 additions & 5 deletions annofabapi/models.py

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions generate/swagger/swagger-api-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ components:
required:
- organization_id
- plugin_id
- plugin_type
- compatible_input_data_types
- created_datetime
- updated_datetime
Expand All @@ -635,12 +636,16 @@ components:
$ref: "#/components/schemas/OrganizationId"
plugin_id:
$ref: "#/components/schemas/PluginId"
plugin_type:
$ref: "#/components/schemas/PluginType"
plugin_name:
$ref: "#/components/schemas/PluginName"
description:
$ref: "#/components/schemas/PluginDescription"
annotation_editor_url:
$ref: "#/components/schemas/AnnotationEditorUrl"
task_assignment_url:
$ref: "#/components/schemas/TaskAssignmentUrl"
compatible_input_data_types:
$ref: "#/components/schemas/PluginCompatibleInputDataTypes"
created_datetime:
Expand All @@ -652,14 +657,19 @@ components:
PutOrganizationPluginRequest:
type: object
required:
- plugin_type
- compatible_input_data_types
properties:
plugin_type:
$ref: "#/components/schemas/PluginType"
plugin_name:
$ref: "#/components/schemas/PluginName"
description:
$ref: "#/components/schemas/PluginDescription"
annotation_editor_url:
$ref: "#/components/schemas/AnnotationEditorUrl"
task_assignment_url:
$ref: "#/components/schemas/TaskAssignmentUrl"
compatible_input_data_types:
$ref: "#/components/schemas/PluginCompatibleInputDataTypes"
last_updated_datetime:
Expand All @@ -669,6 +679,15 @@ components:
example: "12345678-abcd-1234-abcd-1234abcd5678"
description: |
プラグインID。[値の制約についてはこちら。](#section/API-Convention/APIID)
PluginType:
type: string
enum:
- custom_annotation_editor
- custom_task_assignment
description: |
プラグイン種別。
* `custom_annotation_editor` - カスタムアノテーションエディタ用のプラグインを表します。
* `custom_task_assignment` - カスタムタスク割当用のプラグインを表します。
PluginName:
type: string
example: "foo-bar"
Expand All @@ -688,12 +707,14 @@ components:
example: ["custom"]
description: |
プラグインが対応している入力データです。
プラグイン種別がカスタムアノテーションエディタの場合のみ有効です。
AnnotationEditorUrl:
type: string
example: "https://example.com/my/editors?p={projectId}&t={taskId}"
description: |
カスタムアノテーションエディタでタスクを開くための URL です。
プラグインを使用するプロジェクトのタスク一覧などで使用されます。
プラグイン種別がカスタムアノテーションエディタの場合のみ有効です。

この URL には、タスクを特定するための以下のパラメータを必ず埋め込んでください。

Expand All @@ -704,6 +725,57 @@ components:

* `{inputDataId}`: アノテーション一覧などから、特定の入力データにフォーカスした状態でタスクを開くときなどに指定します。
* `{annotationId}`: アノテーション一覧などから、特定のアノテーションにフォーカスした状態でタスクを開くときなどに指定します。
TaskAssignmentUrl:
type: string
example: "https://example.com/my/editors?p={projectId}&t={taskId}"
description: |
「カスタムタスク割当API」のURLです。
プラグイン種別がカスタムタスク割当の場合のみ有効です。

#### カスタムタスク割当APIについて。

* 独自のアルゴリズムで作業者にタスクを割当するAPIです。
* AnnoFabから提供されるものではなく、第三者 (ユーザー様) が用意します。
* 作業者がタスク一覧やアノテーションエディタのタスク取得ボタンを押すと、指定したURLに複数の情報 (※1) と共にHTTPリクエスト (POST) が送られます。
* カスタムタスク割当APIでは、AnnoFabで提供しているAPI (※2) を使用して作業者にタスクを割当してください。
* タスクの割当に成功した場合は以下のHTTPレスポンスを返却してください。
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
* レスポンスボディ: 割当した単一のタスク
* ステータスコード: 200
* 作業者に割当できるタスクがない場合は以下のHTTPレスポンスを返却してください。
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
* レスポンスボディ: `{"errors": [{"error_code": "MISSING_RESOURCE"}]}`
* ステータスコード: 404
* 作業者の認証トークンの期限が切れている場合があります。その場合は以下のHTTPレスポンスを返却してください。
* レスポンスヘッダ: `Access-Control-Allow-Origin: https://annofab.com`
* レスポンスボディ: `{"errors": [{"error_code": "EXPIRED_TOKEN"}]}`
* ステータスコード: 401

#### Preflightリクエストについて。

* AnnoFabからカスタムタスク割当APIへCross-OriginなHTTPリクエストを送信するより前に、ブラウザの仕様により「Preflightリクエスト」と呼ばれるHTTPリクエストが送られます。
* カスタムタスク割当を利用するためには、カスタムタスク割当APIとは別に「Preflightリクエスト対応API」を用意する必要があります。
* 以下の要件を満たす「Preflightリクエスト対応API」を用意してください。
* URL: カスタムタスク割当APIと同じURL
* HTTPメソッド: OPTIONS
* レスポンスヘッダ:
* `Access-Control-Allow-Origin: https://annofab.com`
* `Access-Control-Allow-Headers: Content-Type`
* レスポンスボディ: 空(から)
* ステータスコード: 200

※1 以下の情報が送られます。

* HTTPボディ (JSON形式)
* `authorization_token` : 作業者の認証トークン。AnnoFabのAPIを利用する際に使用します。
* `project_id` : タスクの割当リクエストが行われたプロジェクトのID。
* `phase` : 作業者が割当を要求したタスクフェーズ。このフェーズのタスクを割当してください。

※2 例えば以下のAPIがあります。(詳しい情報はAPIドキュメントを参照してください)

* `getMyAccount` : 作業者のアカウント情報を取得できます。
* `getTasks` : プロジェクトのタスクを取得できます。
* `assignTasks` : 作業者にタスクを割当することができます。

MyOrganization:
type: object
Expand Down Expand Up @@ -1011,6 +1083,14 @@ components:
AWS IAMロール。ビジネスプランでのS3プライベートストレージの認可で使います。
[S3プライベートストレージの認可の設定についてはこちら](/docs/faq/#m0b240)をご覧ください。
example: "arn:aws:iam::123456789012:role/AnnoFabPrivateStorageAccessor"
plugin_id:
$ref: "#/components/schemas/PluginId"
description: |
カスタムアノテーションエディタのプラグインID。カスタムプロジェクトの場合は必須です。
custom_task_assignment_plugin_id:
$ref: "#/components/schemas/PluginId"
description: |
`task_assignment_type`に`custom`を設定している場合のみ、カスタムタスク割当のプラグインIDを設定してください。
ProjectSummary:
type: object
properties:
Expand All @@ -1025,12 +1105,14 @@ components:
- random
- selection
- random_and_selection
- custom
description: |
プロジェクトで使用するタスクの割当方式。

* `random` - タスクフェーズのみを指定してランダムにタスクを自身に割当する方式です。
* `selection` - 担当者とタスクを明示的に指定してタスクを割当する方式です。プロジェクトオーナーもしくはチェッカーのみ、自身以外のプロジェクトメンバーを担当者に指定できます。
* `random_and_selection` - ランダム割当と選択割当の両機能を使用する方式です。
* `custom` - タスク割当アルゴリズム (API) を独自に定義してタスクを割当する方式です。
JobInfo:
type: object
properties:
Expand Down Expand Up @@ -1608,6 +1690,12 @@ components:
}
no_label:
$ref: "#/components/schemas/InspectionStatisticsPhrases"
PatchTasksMetadataRequest:
type: object
description: タスクIDとメタデータのkey-valueペア(Dictionary)です。
additionalProperties: {
$ref: "#/components/schemas/TaskMetadata"
}
InspectionStatisticsPhrases:
type: object
description: ラベル外指摘の集計結果
Expand Down Expand Up @@ -2490,6 +2578,8 @@ components:
* `inspection_and_acceptance_skipped` - このタスクが抜取検査の対象外となり、検査・受入フェーズをスキップしたことを表す

未指定時はこのタスクが抜取検査の対象となったことを表す。(通常のワークフローを通過する)
metadata:
$ref: "#/components/schemas/TaskMetadata"
TaskPhase:
type: string
enum:
Expand Down Expand Up @@ -2521,15 +2611,24 @@ components:
* `complete` - 完了。次のフェーズへ進む
* `rejected` - 差戻し。修正のため、`annotation`フェーズへ戻る。[operateTask](#operation/operateTask) APIのリクエストボディに渡すときのみ利用する。その他のAPIのリクエストやレスポンスには使われない。
* `cancelled` - 提出取消し。修正のため、前フェーズへ戻る。[operateTask](#operation/operateTask) APIのリクエストボディに渡すときのみ利用する。その他のAPIのリクエストやレスポンスには使われない。
TaskMetadata:
type: object
description: |
ユーザーが自由に登録できるkey-value型のメタデータです。
keyにはメタデータ名、valueには値を指定してください。
valueには文字列、数値、真偽値を指定できます。
TaskRequest:
type: object
required:
- input_data_id_list
- metadata
properties:
input_data_id_list:
type: array
items:
$ref: "#/components/schemas/InputDataId"
metadata:
$ref: "#/components/schemas/TaskMetadata"
TaskGenerateRequest:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion generate/swagger/swagger.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ info:

上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。

version: 0.94.7
version: 0.95.7
title: AnnoFab Web API
x-logo:
url: "https://annofab.com/images/logo_landscape.png"
Expand Down
Loading