From 35b97b6290adb91f8251826f773380ecbb36e217 Mon Sep 17 00:00:00 2001 From: yuji38kwmt Date: Fri, 27 Nov 2026 15:25:06 +0900 Subject: [PATCH] feat: Update annotation type field definitions and descriptions - Modified `AnnotationTypeFieldValueVertexCountMinMax` to enforce minimum vertex counts for `Polyline2d` and `Polygon2d`. - Enhanced descriptions in `BatchAnnotationV1`, `SingleAnnotationDetailV1`, and other models for clarity on attribute properties. - Updated `DefaultAnnotationType` documentation to use consistent terminology for annotation types. - Improved descriptions in Swagger API components for user-defined annotation types and field definitions. - Changed version number in Swagger files to 0.214.0. --- annofabapi/dataclass/annotation.py | 6 +- annofabapi/dataclass/annotation_specs.py | 14 +- annofabapi/generated_api.py | 6 +- annofabapi/models.py | 61 ++++---- .../additional_data_default_type.py | 2 +- .../additional_data_definition_type.py | 4 +- .../additional_data_restriction_condition.py | 2 +- .../pydantic_models/additional_data_v1.py | 2 +- .../pydantic_models/annotation_detail_v1.py | 2 +- .../pydantic_models/annotation_query.py | 2 +- annofabapi/pydantic_models/annotation_type.py | 2 +- .../annotation_type_field_min_warn_rule.py | 74 ++++++++-- .../annotation_type_field_value.py | 2 +- ...e_field_value_margin_of_error_tolerance.py | 2 +- ...nnotation_type_field_value_minimum_size.py | 9 +- ...mum_size2d_with_default_insert_position.py | 16 +- ...n_type_field_value_vertex_count_min_max.py | 21 ++- .../pydantic_models/batch_annotation_v1.py | 2 +- .../default_annotation_type.py | 2 +- annofabapi/pydantic_models/label_v3.py | 2 +- ...plugin_detail_extended_annotation_specs.py | 2 +- .../single_annotation_detail_v1.py | 2 +- .../user_defined_annotation_data_type.py | 2 +- ...efined_annotation_type_field_definition.py | 2 +- generate/swagger/swagger-api-components.yaml | 139 ++++++++++++------ generate/swagger/swagger.v2.yaml | 2 +- generate/swagger/swagger.yaml | 20 ++- 27 files changed, 272 insertions(+), 130 deletions(-) diff --git a/annofabapi/dataclass/annotation.py b/annofabapi/dataclass/annotation.py index c4836e3..1e0a7ff 100644 --- a/annofabapi/dataclass/annotation.py +++ b/annofabapi/dataclass/annotation.py @@ -144,7 +144,7 @@ class AdditionalDataV1(DataClassJsonMixin): """`additional_data_definition`の`type`が`integer`のときの属性値。 """ comment: str | None - """`additional_data_definition`の`type`が`text`,`comment`,`link` または `tracking`のときの属性値。 """ + """`additional_data_definition`の`type`が`comment`,`text`,`link` または `tracking`のときの属性値。 """ choice: str | None """選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """ @@ -324,7 +324,7 @@ class SingleAnnotationDetailV1(DataClassJsonMixin): """data_holding_typeがouterの場合のみ存在し、データへの一時URLが格納される""" additional_data_list: list[AdditionalDataV1] - """属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | """ + """属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | """ created_datetime: str """作成日時""" @@ -433,7 +433,7 @@ class AnnotationDetailV1(DataClassJsonMixin): """外部ファイルに保存されたアノテーションの認証済み一時URL。`data_holding_type`が`inner`の場合、または[putAnnotation](#operation/putAnnotation) APIのリクエストボディに渡す場合は未指定です。""" additional_data_list: list[AdditionalDataV1] - """属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | """ + """属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | """ created_datetime: str | None """作成日時""" diff --git a/annofabapi/dataclass/annotation_specs.py b/annofabapi/dataclass/annotation_specs.py index 7bb5385..62027dd 100644 --- a/annofabapi/dataclass/annotation_specs.py +++ b/annofabapi/dataclass/annotation_specs.py @@ -316,10 +316,10 @@ class AnnotationTypeFieldValueMinimumSize2dWithDefaultInsertPosition(DataClassJs """""" min_width: int - """""" + """最小の幅。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 """ min_height: int - """""" + """最小の高さ。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 """ position_for_minimum_bounding_box_insertion: list[int] | None """最小矩形の挿入位置を、要素が2の配列で指定します。 """ @@ -347,11 +347,11 @@ class AnnotationTypeFieldValueVertexCountMinMax(DataClassJsonMixin): type: str """""" - min: int - """""" + min: int | None + """頂点数の最小値。データ型が `Polyline2d` の場合は2以上、`Polygon2d` の場合は3以上を指定します。 """ - max: int - """""" + max: int | None + """頂点数の最大値。標準種別ではポリラインは2以上、ポリゴンは3以上を指定します。ユーザー定義種別では、`max` のみ指定した場合、下限は検証されません。 """ @dataclass @@ -610,7 +610,7 @@ class LabelV3(DataClassJsonMixin): """""" field_values: dict[str, AnnotationTypeFieldValue] - """KeyがフィールドIdであるDictionaryです。 カスタムの[組織プラグイン](#operation/putOrganizationPlugin)で利用される[UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition).`field_definitions`で定義されます。 """ + """ラベルごとの制約や設定値を保持するオブジェクトです。 キーには設定項目を識別するフィールドIDを指定し、値にはそのフィールドに設定する制約やオプションを表すオブジェクトを指定します。 例えば頂点数制約は、`\"vertex_count_min_max\": {\"_type\": \"VertexCountMinMax\", \"max\": 20}` のように指定します。 Annofabの標準エディタでは、アノテーション種別ごとに、使用可能なフィールドIDと設定値の構造があらかじめ決まっています。設定値の構造は、値オブジェクトの `_type` に設定値の構造を示す名前を指定することで示します。以下の表に、フィールドIDと設定値の構造を示す名前を示します。 | エディタ | アノテーション種別(`annotation_type`) | フィールドID → 設定値の構造を示す名前 | | --- | --- | --- | | 画像 | 矩形(`bounding_box`) | `minimum_size_2d_with_default_insert_position` → `MinimumSize2dWithDefaultInsertPosition`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリゴン(`polygon`) | `minimum_size_2d` → `MinimumSize2d`
`minimum_area_2d` → `MinimumArea2d`
`vertex_count_min_max` → `VertexCountMinMax`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリライン(`polyline`) | `minimum_size_2d` → `MinimumSize2d`
`vertex_count_min_max` → `VertexCountMinMax`
`display_line_direction` → `DisplayLineDirection`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 点(`point`) | `margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 塗りつぶし(`segmentation`)・塗りつぶしv2(`segmentation_v2`) | `minimum_size_2d` → `MinimumSize2d`
`margin_of_error_tolerance` → `MarginOfErrorTolerance`
`annotation_editor_feature` → `AnnotationEditorFeature` | | 画像・動画 | 全体(`classification`) | なし | | 動画 | 区間(`range`) | なし | ユーザー定義アノテーション種別では、[組織プラグイン](#operation/putOrganizationPlugin)の [UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition) の `field_definitions` で定義されたフィールドIDをキーに指定します。値オブジェクトの `_type` には、設定値の構造を示す名前を指定します。指定する名前は、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)を参照してください。 """ additional_data_definitions: list[str] """ラベルに所属する属性のID""" diff --git a/annofabapi/generated_api.py b/annofabapi/generated_api.py index 53a7f16..8005a2e 100644 --- a/annofabapi/generated_api.py +++ b/annofabapi/generated_api.py @@ -429,10 +429,10 @@ def put_annotation_specs( https://annofab.com/docs/api/#operation/putAnnotationSpecs - authorizations: ProjectOwner + authorizations: ProjectAccepter - アノテーション仕様を更新します。 + アノテーション仕様を更新します。 プロジェクトのチェッカーロールを持つユーザーは、以下の項目のみ変更できます。 * ラベルの色 * ラベル・属性・選択肢のショートカットキー * ラベル・属性・選択肢の表示順 * 定型指摘 チェッカーロールを持つユーザーがそれ以外の項目を変更しようとした場合、`403 Forbidden`(エラーコード`FORBIDDEN_FEATURE`)になります。 Args: project_id (str): プロジェクトID (required) @@ -3147,7 +3147,7 @@ def put_task(self, project_id: str, task_id: str, *, request_body: Any | None = authorizations: ProjectOwner - タスクを作成または更新します。 大量のタスクを一括で生成する場合は、[initiateTasksGeneration](#operation/initiateTasksGeneration) APIの使用を検討してください。 + タスクを作成または更新します。 一度でもタスクが作業中になっている場合は、タスクの入力データを更新することはできません。入力データを更新したい場合は、新しくタスクを作成してください。 大量のタスクを一括で生成する場合は、[initiateTasksGeneration](#operation/initiateTasksGeneration) APIの使用を検討してください。 Args: project_id (str): プロジェクトID (required) diff --git a/annofabapi/models.py b/annofabapi/models.py index 70e1675..6f45d55 100644 --- a/annofabapi/models.py +++ b/annofabapi/models.py @@ -231,7 +231,7 @@ AdditionalDataDefaultType = dict[str, Any] """ -属性の初期値です。 初期値を設定する場合、属性の種類に応じて次の値を指定してください。 属性の種類に対して有効でない初期値を指定した場合、その初期値は無視されます。 |属性の種類(`type`) | 指定できる初期値| |-----------------|----------| | flag | 真偽値(`true` or `false`)| | integer | 整数値 | | text | 文字列 | | comment | 文字列| | choice | 選択肢(`choices`)の `choice_id` | | select | 選択肢(`choices`)の`choice_id`| 属性の種類が`tracking`または`link`の場合、初期値を設定できません。 初期値を設定しない場合は、nullまたは空文字を指定してください。 +属性の初期値です。 初期値を設定する場合、属性の種類に応じて次の値を指定してください。 属性の種類に対して有効でない初期値を指定した場合、その初期値は無視されます。 |属性の種類(`type`) | 指定できる初期値| |-----------------|----------| | flag | 真偽値(`true` or `false`)| | integer | 整数値 | | comment | 文字列| | text | 文字列 | | choice | 選択肢(`choices`)の `choice_id` | | select | 選択肢(`choices`)の`choice_id`| 属性の種類が`tracking`または`link`の場合、初期値を設定できません。 初期値を設定しない場合は、nullまたは空文字を指定してください。 Keys of dict @@ -241,13 +241,13 @@ class AdditionalDataDefinitionType(Enum): """ - 属性の種類 * `flag` - 真偽値 * `integer` - 整数値 * `text` - 自由記述(1行) * `comment` - 自由記述(複数行) * `choice` - 選択肢(ラジオボタン式) * `select` - 選択肢(ドロップダウン式) * `tracking` - トラッキングID * `link` - アノテーションリンク + 属性の種類 * `flag` - 真偽値 * `integer` - 整数値 * `comment` - 自由記述(1行) * `text` - 自由記述(複数行) * `choice` - 選択肢(ラジオボタン式) * `select` - 選択肢(ドロップダウン式) * `tracking` - トラッキングID * `link` - アノテーションリンク """ FLAG = "flag" INTEGER = "integer" - TEXT = "text" COMMENT = "comment" + TEXT = "text" CHOICE = "choice" SELECT = "select" TRACKING = "tracking" @@ -340,7 +340,7 @@ class AdditionalDataDefinitionType(Enum): AdditionalDataRestrictionCondition = dict[str, Any] """ -属性の制約 * `AdditionalDataRestrictionConditionCanInput`: 属性値の入力を許可するかどうか * `AdditionalDataRestrictionConditionEquals`: 指定した値に等しい * `AdditionalDataRestrictionConditionNotEquals`: 指定した値に等しくない * `AdditionalDataRestrictionConditionMatches`: 指定した正規表現に一致する * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 * `AdditionalDataRestrictionConditionNotMatches`: 指定した正規表現に一致しない * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 * `AdditionalDataRestrictionConditionHasLabel`: 指定したラベルIDに一致する(アノテーションリンク属性限定) * `AdditionalDataDefinitionType`が`link`のときのみ利用可能 * `AdditionalDataRestrictionConditionImply`: 指定した前提条件を満たすときのみ、制約を満たすかどうか 以下のJSONは、「属性IDが`attr2`の属性値が`true`ならば、属性IDが`attr1`の属性値は`choice1`である」という制約を表しています。 ``` { \"additional_data_definition_id\": \"attr1\", \"condition\": { \"_type\": \"Imply\", \"premise\": { \"additional_data_definition_id\": \"attr2\", \"condition\": { \"_type\": \"Equals\", \"value\": \"true\" } }, \"condition\": { \"_type\": \"Equals\", \"value\": \"choice1\" } } } ``` +属性の制約 * `AdditionalDataRestrictionConditionCanInput`: 属性値の入力を許可するかどうか * `AdditionalDataRestrictionConditionEquals`: 指定した値に等しい * `AdditionalDataRestrictionConditionNotEquals`: 指定した値に等しくない * `AdditionalDataRestrictionConditionMatches`: 指定した正規表現に一致する * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionNotMatches`: 指定した正規表現に一致しない * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionHasLabel`: 指定したラベルIDに一致する(アノテーションリンク属性限定) * `AdditionalDataDefinitionType`が`link`のときのみ利用可能 * `AdditionalDataRestrictionConditionImply`: 指定した前提条件を満たすときのみ、制約を満たすかどうか 以下のJSONは、「属性IDが`attr2`の属性値が`true`ならば、属性IDが`attr1`の属性値は`choice1`である」という制約を表しています。 ``` { \"additional_data_definition_id\": \"attr1\", \"condition\": { \"_type\": \"Imply\", \"premise\": { \"additional_data_definition_id\": \"attr2\", \"condition\": { \"_type\": \"Equals\", \"value\": \"true\" } }, \"condition\": { \"_type\": \"Equals\", \"value\": \"choice1\" } } } ``` Keys of dict @@ -465,7 +465,7 @@ class AdditionalDataDefinitionType(Enum): * integer: int `additional_data_definition`の`type`が`integer`のときの属性値。 * comment: str - `additional_data_definition`の`type`が`text`,`comment`,`link` または `tracking`のときの属性値。 + `additional_data_definition`の`type`が`comment`,`text`,`link` または `tracking`のときの属性値。 * choice: str 選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) @@ -789,7 +789,7 @@ class AnnotationDataHoldingType(Enum): * url: str 外部ファイルに保存されたアノテーションの認証済み一時URL。`data_holding_type`が`inner`の場合、または[putAnnotation](#operation/putAnnotation) APIのリクエストボディに渡す場合は未指定です。 * additional_data_list: list[AdditionalDataV1] - 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | + 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | * created_datetime: str 作成日時 * updated_datetime: str @@ -1051,7 +1051,7 @@ class AnnotationDataHoldingType(Enum): * label_id: str ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) * attributes: list[AdditionalDataV1] - 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | + 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | * updated_from: str 開始日・終了日を含む区間[updated_from, updated_to]でアノテーションの更新日を絞り込むときに使用する、開始日(ISO 8601 拡張形式または基本形式)。 `updated_to` より後の日付が指定された場合、期間指定は開始日・終了日を含む区間[updated_to, updated_from]となる。未指定の場合、API実行日(JST)の日付が指定されたものとして扱われる。 * updated_to: str @@ -1588,19 +1588,20 @@ class AnnotationDataHoldingType(Enum): """ +AnnotationTypeFieldMinWarnRule = dict[str, Any] +""" +最小の幅(min_width)と最小の高さ(min_height)に対する判定条件を指定します。 * `And` - min_width、min_heightの両方が最小値未満の場合に最小サイズ違反となります。 * `Or` - min_width、min_heightのいずれかが最小値未満の場合に最小サイズ違反となります。 -class AnnotationTypeFieldMinWarnRule(Enum): - """ - 最小の幅(min_width)と最小の高さ(min_height)がどのような状態になったときにエラーとするかを指定します。 * `and` - min_width、min_heightの両方が最小値未満の場合にエラーとなります。 * `or` - min_width、min_heightのいずれかが最小値未満の場合にエラーとなります。 - """ +Keys of dict - AND = "and" - OR = "or" +* type: str + +""" AnnotationTypeFieldValue = dict[str, Any] """ -ユーザー定義アノテーション種別のフィールドに設定される値です。 アノテーション種別のフィールド定義と対応するフィールド値のみ登録を許可されます。 +フィールドに設定する制約やオプションを表すオブジェクトです。 Annofabの標準エディタで使用するアノテーション種別では、[LabelV3 の `field_values`](#tag/x-data-types/LabelV3) に記載された、設定値の構造を示す名前を `_type` に指定します。 ユーザー定義アノテーション種別では、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)に示す、設定値オブジェクトの `_type` を指定します。 Keys of dict @@ -1609,17 +1610,17 @@ class AnnotationTypeFieldMinWarnRule(Enum): * min_warn_rule: AnnotationTypeFieldMinWarnRule * min_width: int - + 最小の幅。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 * min_height: int - + 最小の高さ。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 * position_for_minimum_bounding_box_insertion: list[int] 最小矩形の挿入位置を、要素が2の配列で指定します。 * max_pixel: int * min: int - + 頂点数の最小値。データ型が `Polyline2d` の場合は2以上、`Polygon2d` の場合は3以上を指定します。 * max: int - + 頂点数の最大値。標準種別ではポリラインは2以上、ポリゴンは3以上を指定します。ユーザー定義種別では、`max` のみ指定した場合、下限は検証されません。 * min_area: int * has_direction: bool @@ -1742,9 +1743,9 @@ class AnnotationTypeFieldMinWarnRule(Enum): * min_warn_rule: AnnotationTypeFieldMinWarnRule * min_width: int - + 最小の幅。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 * min_height: int - + 最小の高さ。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 * position_for_minimum_bounding_box_insertion: list[int] 最小矩形の挿入位置を、要素が2の配列で指定します。 @@ -1798,9 +1799,9 @@ class AnnotationTypeFieldMinWarnRule(Enum): * type: str * min: int - + 頂点数の最小値。データ型が `Polyline2d` の場合は2以上、`Polygon2d` の場合は3以上を指定します。 * max: int - + 頂点数の最大値。標準種別ではポリラインは2以上、ポリゴンは3以上を指定します。ユーザー定義種別では、`max` のみ指定した場合、下限は検証されません。 """ @@ -1977,7 +1978,7 @@ class AssigneeRuleOfResubmittedTask(Enum): * label_id: str ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) * additional_data_list: list[AdditionalDataV1] - 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | + 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | * updated_datetime: str アノテーション取得時の更新日時。更新時の楽観ロックに利用されます。 AnnotationDetailのものではなく、それを格納するAnnotationV2Outputなどが保持する更新時刻であることに注意してください。 @@ -2464,7 +2465,7 @@ class CommentType(Enum): class DefaultAnnotationType(Enum): """ - アノテーションの種類 * `bounding_box` - 矩形 * `segmentation` - 塗りつぶし(インスタンスセグメンテーション用) * `segmentation_v2` - 塗りつぶしv2(セマンティックセグメンテーション用) * `polygon` - ポリゴン(閉じた頂点集合) * `polyline` - ポリライン(開いた頂点集合) * `point` - 点 * `classification` - 全体 * `range` - 動画の区間 * `custom` - カスタム プロジェクトの種類によって、使用できるアノテーションの種類は決まっています。アノテーションの種類が使用できるかどうかを、以下の表に記載しました。 * `○`:使用できる * `×`:使用できない |アノテーションの種類 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | |-----------------|:----------:|:----:|:------:| | bounding_box | 〇 | × | × | | segmentation | 〇 | × | × | | segmentation_v2 | 〇 | × | × | | polygon | 〇 | × | × | | polyline | 〇 | × | × | | point | 〇 | × | × | | classification | 〇 | 〇 | × | | range | × | 〇 | × | | custom | × | × | 〇 | + アノテーション種別 * `bounding_box` - 矩形 * `segmentation` - 塗りつぶし(インスタンスセグメンテーション用) * `segmentation_v2` - 塗りつぶしv2(セマンティックセグメンテーション用) * `polygon` - ポリゴン(閉じた頂点集合) * `polyline` - ポリライン(開いた頂点集合) * `point` - 点 * `classification` - 全体 * `range` - 動画の区間 * `custom` - カスタム プロジェクトの種類によって、使用できるアノテーション種別は決まっています。アノテーション種別が使用できるかどうかを、以下の表に記載しました。 * `○`:使用できる * `×`:使用できない |アノテーション種別 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | |-----------------|:----------:|:----:|:------:| | bounding_box | 〇 | × | × | | segmentation | 〇 | × | × | | segmentation_v2 | 〇 | × | × | | polygon | 〇 | × | × | | polyline | 〇 | × | × | | point | 〇 | × | × | | classification | 〇 | 〇 | × | | range | × | 〇 | × | | custom | × | × | 〇 | """ BOUNDING_BOX = "bounding_box" @@ -3835,7 +3836,7 @@ class KeyLayout(Enum): * annotation_type: AnnotationType * field_values: dict(str, AnnotationTypeFieldValue) - KeyがフィールドIdであるDictionaryです。 カスタムの[組織プラグイン](#operation/putOrganizationPlugin)で利用される[UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition).`field_definitions`で定義されます。 + ラベルごとの制約や設定値を保持するオブジェクトです。 キーには設定項目を識別するフィールドIDを指定し、値にはそのフィールドに設定する制約やオプションを表すオブジェクトを指定します。 例えば頂点数制約は、`\"vertex_count_min_max\": {\"_type\": \"VertexCountMinMax\", \"max\": 20}` のように指定します。 Annofabの標準エディタでは、アノテーション種別ごとに、使用可能なフィールドIDと設定値の構造があらかじめ決まっています。設定値の構造は、値オブジェクトの `_type` に設定値の構造を示す名前を指定することで示します。以下の表に、フィールドIDと設定値の構造を示す名前を示します。 | エディタ | アノテーション種別(`annotation_type`) | フィールドID → 設定値の構造を示す名前 | | --- | --- | --- | | 画像 | 矩形(`bounding_box`) | `minimum_size_2d_with_default_insert_position` → `MinimumSize2dWithDefaultInsertPosition`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリゴン(`polygon`) | `minimum_size_2d` → `MinimumSize2d`
`minimum_area_2d` → `MinimumArea2d`
`vertex_count_min_max` → `VertexCountMinMax`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリライン(`polyline`) | `minimum_size_2d` → `MinimumSize2d`
`vertex_count_min_max` → `VertexCountMinMax`
`display_line_direction` → `DisplayLineDirection`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 点(`point`) | `margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 塗りつぶし(`segmentation`)・塗りつぶしv2(`segmentation_v2`) | `minimum_size_2d` → `MinimumSize2d`
`margin_of_error_tolerance` → `MarginOfErrorTolerance`
`annotation_editor_feature` → `AnnotationEditorFeature` | | 画像・動画 | 全体(`classification`) | なし | | 動画 | 区間(`range`) | なし | ユーザー定義アノテーション種別では、[組織プラグイン](#operation/putOrganizationPlugin)の [UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition) の `field_definitions` で定義されたフィールドIDをキーに指定します。値オブジェクトの `_type` には、設定値の構造を示す名前を指定します。指定する名前は、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)を参照してください。 * additional_data_definitions: list[str] ラベルに所属する属性のID * color: Color @@ -4669,7 +4670,7 @@ class OrganizationMemberStatus(Enum): * annotation_types: list[AnnotationType] プラグインを使用したプロジェクトで選択可能なアノテーション種別のリストです。 同じ種別を重複して設定することはできません。 * user_defined_annotation_type_definitions: dict(str, UserDefinedAnnotationTypeDefinition) - Keyが[アノテーションの種類(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 + Keyが[アノテーション種別(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 """ @@ -4722,7 +4723,7 @@ class OrganizationMemberStatus(Enum): * annotation_types: list[AnnotationType] プラグインを使用したプロジェクトで選択可能なアノテーション種別のリストです。 同じ種別を重複して設定することはできません。 * user_defined_annotation_type_definitions: dict(str, UserDefinedAnnotationTypeDefinition) - Keyが[アノテーションの種類(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 + Keyが[アノテーション種別(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 * compatible_input_data_types: list[InputDataType] プラグインが対応している入力データです。 プラグイン種別がカスタムアノテーションエディタ、またはカスタムアノテーション仕様の場合のみ有効です。 * type: str @@ -5955,7 +5956,7 @@ class ProjectStatus(Enum): * url: str data_holding_typeがouterの場合のみ存在し、データへの一時URLが格納される * additional_data_list: list[AdditionalDataV1] - 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | + 属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | * created_datetime: str 作成日時 * updated_datetime: str @@ -6813,7 +6814,7 @@ class TaskStatus(Enum): Keys of dict * type: str - ユーザー定義アノテーション種別の型を指定します。 指定可能な値と、その意味は下記の通りです。 * `BoundingBox2d` - 2次元の矩形 * `Polygon2d` - 2次元のポリゴン * `Polyline2d` - 2次元のポリライン * `SinglePoint2d` - 2次元の点 * `SemanticSegmentation2d` - 2次元のセマンティックセグメンテーション * `InstanceSegmentation2d` - 2次元のインスタンスセグメンテーション * `Range1d` - 1次元の範囲 * `Classification` - 全体アノテーション * `Unknown` - その他のアノテーション種別 下記のフィールド定義は、すべてのアノテーション種別の型に対して使用可能です。 * `OneIntegerField` * `OneStringField` * `OneBooleanField` その他のフィールド定義は、使用可能なアノテーション種別の型に制限があります。 ユーザー定義アノテーション種別の型ごとの、使用可能なフィールド定義を下記の表で示します。 |ユーザー定義アノテーション種別の型 | 使用可能なフィールド定義 | |-----------------|:----------:| | BoundingBox2d | MinimumSize2dWithDefaultInsertPosition, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polygon2d | MinimumSize2d, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polyline2d | VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | | SinglePoint2d | MarginOfErrorTolerance | | SemanticSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | | InstanceSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | | Range1d | MarginOfErrorTolerance | | Classification | MarginOfErrorTolerance | | Unknown | - | + ユーザー定義アノテーション種別が扱うデータ型を指定します。 指定可能な値と、その意味は下記の通りです。 * `BoundingBox2d` - 2次元の矩形 * `Polygon2d` - 2次元のポリゴン * `Polyline2d` - 2次元のポリライン * `SinglePoint2d` - 2次元の点 * `SemanticSegmentation2d` - 2次元のセマンティックセグメンテーション * `InstanceSegmentation2d` - 2次元のインスタンスセグメンテーション * `Range1d` - 1次元の範囲 * `Classification` - 全体アノテーション * `Unknown` - その他のアノテーション種別 下記のフィールド定義は、すべてのデータ型に対して使用可能です。 * `OneIntegerField` * `OneStringField` * `OneBooleanField` その他のフィールド定義は、使用可能なデータ型に制限があります。 データ型ごとの、使用可能なフィールド定義を下記の表で示します。 |データ型 | 使用可能なフィールド定義 | |-----------------|:----------:| | BoundingBox2d | MinimumSize2d, MinimumSize2dWithDefaultInsertPosition, MinimumArea2d, MarginOfErrorTolerance | | Polygon2d | MinimumSize2d, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polyline2d | MinimumSize2d, VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | | SinglePoint2d | MarginOfErrorTolerance | | SemanticSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | | InstanceSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | | Range1d | なし | | Classification | なし | | Unknown | なし | """ @@ -6849,7 +6850,7 @@ class TaskStatus(Enum): UserDefinedAnnotationTypeFieldDefinition = dict[str, Any] """ -ユーザー定義のアノテーション種別に設定可能なフィールドについての定義です。 +ユーザー定義アノテーション種別が持つ、制約やオプションを設定するためのフィールドを定義します。 アノテーション仕様V3では、このフィールド定義に対応する設定値オブジェクトを指定します。フィールド定義と設定値は、それぞれのオブジェクトの `_type` で種類を識別します。両者の対応を以下の表に示します。 設定値には、表に示す `_type` を持つ [AnnotationTypeFieldValue](#tag/x-data-types/AnnotationTypeFieldValue) のオブジェクトを指定します。 | フィールド定義の `_type` | 設定値オブジェクトの `_type` | | --- | --- | | `MinimumSize2d` | `MinimumSize2d` | | `MinimumSize2dWithDefaultInsertPosition` | `MinimumSize2dWithDefaultInsertPosition` | | `MarginOfErrorTolerance` | `MarginOfErrorTolerance` | | `VertexCountMinMax` | `VertexCountMinMax` | | `MinimumArea2d` | `MinimumArea2d` | | `DisplayLineDirection` | `DisplayLineDirection` | | `AnnotationEditorFeature` | `AnnotationEditorFeature` | | `OneIntegerField` | `OneIntegerFieldValue` | | `OneStringField` | `OneStringFieldValue` | | `OneBooleanField` | `OneBooleanFieldValue` | Keys of dict diff --git a/annofabapi/pydantic_models/additional_data_default_type.py b/annofabapi/pydantic_models/additional_data_default_type.py index 924bd2a..2fcb649 100644 --- a/annofabapi/pydantic_models/additional_data_default_type.py +++ b/annofabapi/pydantic_models/additional_data_default_type.py @@ -23,7 +23,7 @@ class AdditionalDataDefaultType(BaseModel): """ - 属性の初期値です。 初期値を設定する場合、属性の種類に応じて次の値を指定してください。 属性の種類に対して有効でない初期値を指定した場合、その初期値は無視されます。 |属性の種類(`type`) | 指定できる初期値| |-----------------|----------| | flag | 真偽値(`true` or `false`)| | integer | 整数値 | | text | 文字列 | | comment | 文字列| | choice | 選択肢(`choices`)の `choice_id` | | select | 選択肢(`choices`)の`choice_id`| 属性の種類が`tracking`または`link`の場合、初期値を設定できません。 初期値を設定しない場合は、nullまたは空文字を指定してください。 + 属性の初期値です。 初期値を設定する場合、属性の種類に応じて次の値を指定してください。 属性の種類に対して有効でない初期値を指定した場合、その初期値は無視されます。 |属性の種類(`type`) | 指定できる初期値| |-----------------|----------| | flag | 真偽値(`true` or `false`)| | integer | 整数値 | | comment | 文字列| | text | 文字列 | | choice | 選択肢(`choices`)の `choice_id` | | select | 選択肢(`choices`)の`choice_id`| 属性の種類が`tracking`または`link`の場合、初期値を設定できません。 初期値を設定しない場合は、nullまたは空文字を指定してください。 """ # data type: bool diff --git a/annofabapi/pydantic_models/additional_data_definition_type.py b/annofabapi/pydantic_models/additional_data_definition_type.py index 755db17..09beee8 100644 --- a/annofabapi/pydantic_models/additional_data_definition_type.py +++ b/annofabapi/pydantic_models/additional_data_definition_type.py @@ -19,7 +19,7 @@ class AdditionalDataDefinitionType(StrEnum): """ - 属性の種類 * `flag` - 真偽値 * `integer` - 整数値 * `text` - 自由記述(1行) * `comment` - 自由記述(複数行) * `choice` - 選択肢(ラジオボタン式) * `select` - 選択肢(ドロップダウン式) * `tracking` - トラッキングID * `link` - アノテーションリンク + 属性の種類 * `flag` - 真偽値 * `integer` - 整数値 * `comment` - 自由記述(1行) * `text` - 自由記述(複数行) * `choice` - 選択肢(ラジオボタン式) * `select` - 選択肢(ドロップダウン式) * `tracking` - トラッキングID * `link` - アノテーションリンク """ """ @@ -27,8 +27,8 @@ class AdditionalDataDefinitionType(StrEnum): """ FLAG = "flag" INTEGER = "integer" - TEXT = "text" COMMENT = "comment" + TEXT = "text" CHOICE = "choice" SELECT = "select" TRACKING = "tracking" diff --git a/annofabapi/pydantic_models/additional_data_restriction_condition.py b/annofabapi/pydantic_models/additional_data_restriction_condition.py index 7d6d2a0..304af87 100644 --- a/annofabapi/pydantic_models/additional_data_restriction_condition.py +++ b/annofabapi/pydantic_models/additional_data_restriction_condition.py @@ -38,7 +38,7 @@ class AdditionalDataRestrictionCondition(BaseModel): """ - 属性の制約 * `AdditionalDataRestrictionConditionCanInput`: 属性値の入力を許可するかどうか * `AdditionalDataRestrictionConditionEquals`: 指定した値に等しい * `AdditionalDataRestrictionConditionNotEquals`: 指定した値に等しくない * `AdditionalDataRestrictionConditionMatches`: 指定した正規表現に一致する * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 * `AdditionalDataRestrictionConditionNotMatches`: 指定した正規表現に一致しない * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 * `AdditionalDataRestrictionConditionHasLabel`: 指定したラベルIDに一致する(アノテーションリンク属性限定) * `AdditionalDataDefinitionType`が`link`のときのみ利用可能 * `AdditionalDataRestrictionConditionImply`: 指定した前提条件を満たすときのみ、制約を満たすかどうか 以下のJSONは、「属性IDが`attr2`の属性値が`true`ならば、属性IDが`attr1`の属性値は`choice1`である」という制約を表しています。 ``` { \"additional_data_definition_id\": \"attr1\", \"condition\": { \"_type\": \"Imply\", \"premise\": { \"additional_data_definition_id\": \"attr2\", \"condition\": { \"_type\": \"Equals\", \"value\": \"true\" } }, \"condition\": { \"_type\": \"Equals\", \"value\": \"choice1\" } } } ``` + 属性の制約 * `AdditionalDataRestrictionConditionCanInput`: 属性値の入力を許可するかどうか * `AdditionalDataRestrictionConditionEquals`: 指定した値に等しい * `AdditionalDataRestrictionConditionNotEquals`: 指定した値に等しくない * `AdditionalDataRestrictionConditionMatches`: 指定した正規表現に一致する * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionNotMatches`: 指定した正規表現に一致しない * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionHasLabel`: 指定したラベルIDに一致する(アノテーションリンク属性限定) * `AdditionalDataDefinitionType`が`link`のときのみ利用可能 * `AdditionalDataRestrictionConditionImply`: 指定した前提条件を満たすときのみ、制約を満たすかどうか 以下のJSONは、「属性IDが`attr2`の属性値が`true`ならば、属性IDが`attr1`の属性値は`choice1`である」という制約を表しています。 ``` { \"additional_data_definition_id\": \"attr1\", \"condition\": { \"_type\": \"Imply\", \"premise\": { \"additional_data_definition_id\": \"attr2\", \"condition\": { \"_type\": \"Equals\", \"value\": \"true\" } }, \"condition\": { \"_type\": \"Equals\", \"value\": \"choice1\" } } } ``` """ # data type: AdditionalDataRestrictionConditionCanInput diff --git a/annofabapi/pydantic_models/additional_data_v1.py b/annofabapi/pydantic_models/additional_data_v1.py index 97bac4e..0723880 100644 --- a/annofabapi/pydantic_models/additional_data_v1.py +++ b/annofabapi/pydantic_models/additional_data_v1.py @@ -33,7 +33,7 @@ class AdditionalDataV1(BaseModel): flag: StrictBool | None = Field(default=None, description="`additional_data_definition`の`type`が`flag`のときの属性値。 ") integer: StrictInt | None = Field(default=None, description="`additional_data_definition`の`type`が`integer`のときの属性値。 ") comment: StrictStr | None = Field( - default=None, description="`additional_data_definition`の`type`が`text`,`comment`,`link` または `tracking`のときの属性値。 " + default=None, description="`additional_data_definition`の`type`が`comment`,`text`,`link` または `tracking`のときの属性値。 " ) choice: StrictStr | None = Field( default=None, diff --git a/annofabapi/pydantic_models/annotation_detail_v1.py b/annofabapi/pydantic_models/annotation_detail_v1.py index 5042550..7838411 100644 --- a/annofabapi/pydantic_models/annotation_detail_v1.py +++ b/annofabapi/pydantic_models/annotation_detail_v1.py @@ -60,7 +60,7 @@ class AnnotationDetailV1(BaseModel): description="外部ファイルに保存されたアノテーションの認証済み一時URL。`data_holding_type`が`inner`の場合、または[putAnnotation](#operation/putAnnotation) APIのリクエストボディに渡す場合は未指定です。", ) additional_data_list: List[AdditionalDataV1] = Field( - description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " + description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " ) created_datetime: str | None = Field(default=None, description="作成日時") updated_datetime: str | None = Field(default=None, description="更新日時") diff --git a/annofabapi/pydantic_models/annotation_query.py b/annofabapi/pydantic_models/annotation_query.py index 872fc71..4a4ee61 100644 --- a/annofabapi/pydantic_models/annotation_query.py +++ b/annofabapi/pydantic_models/annotation_query.py @@ -43,7 +43,7 @@ class AnnotationQuery(BaseModel): ) attributes: List[AdditionalDataV1] | None = Field( default=None, - description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | ", + description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | ", ) updated_from: str | None = Field( default=None, diff --git a/annofabapi/pydantic_models/annotation_type.py b/annofabapi/pydantic_models/annotation_type.py index e30a11a..f0b585d 100644 --- a/annofabapi/pydantic_models/annotation_type.py +++ b/annofabapi/pydantic_models/annotation_type.py @@ -33,7 +33,7 @@ class AnnotationType(BaseModel): # data type: str oneof_schema_2_validator: StrictStr | None = Field( default=None, - description="ユーザー定義のアノテーション種別名です。先頭が `user_` から始まる任意の文字列を指定します。 ", + description="ユーザー定義アノテーション種別名です。先頭が `user_` から始まる任意の文字列を指定します。 ", json_schema_extra={"examples": ["user_bounding_box"]}, ) actual_instance: Union[DefaultAnnotationType, str] | None = None diff --git a/annofabapi/pydantic_models/annotation_type_field_min_warn_rule.py b/annofabapi/pydantic_models/annotation_type_field_min_warn_rule.py index ca533f8..47798af 100644 --- a/annofabapi/pydantic_models/annotation_type_field_min_warn_rule.py +++ b/annofabapi/pydantic_models/annotation_type_field_min_warn_rule.py @@ -12,23 +12,77 @@ from __future__ import annotations import json -from enum import StrEnum +import pprint +import re # noqa: F401 +from typing import Any, ClassVar, Dict, List, Set +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic_core import to_jsonable_python from typing_extensions import Self -class AnnotationTypeFieldMinWarnRule(StrEnum): +class AnnotationTypeFieldMinWarnRule(BaseModel): """ - 最小の幅(min_width)と最小の高さ(min_height)がどのような状態になったときにエラーとするかを指定します。 * `and` - min_width、min_heightの両方が最小値未満の場合にエラーとなります。 * `or` - min_width、min_heightのいずれかが最小値未満の場合にエラーとなります。 + 最小の幅(min_width)と最小の高さ(min_height)に対する判定条件を指定します。 * `And` - min_width、min_heightの両方が最小値未満の場合に最小サイズ違反となります。 * `Or` - min_width、min_heightのいずれかが最小値未満の場合に最小サイズ違反となります。 """ - """ - allowed enum values - """ - AND = "and" - OR = "or" + type: StrictStr = Field(alias="_type") + __properties: ClassVar[List[str]] = ["_type"] + + @field_validator("type") + def type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["And", "Or"]): + raise ValueError("must be one of enum values ('And', 'Or')") + return value + + model_config = ConfigDict( + validate_by_name=True, + validate_by_alias=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(to_jsonable_python(self.to_dict())) @classmethod - def from_json(cls, json_str: str) -> Self: + def from_json(cls, json_str: str) -> Self | None: """Create an instance of AnnotationTypeFieldMinWarnRule from a JSON string""" - return cls(json.loads(json_str)) + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None: + """Create an instance of AnnotationTypeFieldMinWarnRule from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"_type": obj.get("_type")}) + return _obj diff --git a/annofabapi/pydantic_models/annotation_type_field_value.py b/annofabapi/pydantic_models/annotation_type_field_value.py index f26eea6..6e61e85 100644 --- a/annofabapi/pydantic_models/annotation_type_field_value.py +++ b/annofabapi/pydantic_models/annotation_type_field_value.py @@ -49,7 +49,7 @@ class AnnotationTypeFieldValue(BaseModel): """ - ユーザー定義アノテーション種別のフィールドに設定される値です。 アノテーション種別のフィールド定義と対応するフィールド値のみ登録を許可されます。 + フィールドに設定する制約やオプションを表すオブジェクトです。 Annofabの標準エディタで使用するアノテーション種別では、[LabelV3 の `field_values`](#tag/x-data-types/LabelV3) に記載された、設定値の構造を示す名前を `_type` に指定します。 ユーザー定義アノテーション種別では、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)に示す、設定値オブジェクトの `_type` を指定します。 """ # data type: AnnotationTypeFieldValueMinimumSize diff --git a/annofabapi/pydantic_models/annotation_type_field_value_margin_of_error_tolerance.py b/annofabapi/pydantic_models/annotation_type_field_value_margin_of_error_tolerance.py index 991c50c..730f921 100644 --- a/annofabapi/pydantic_models/annotation_type_field_value_margin_of_error_tolerance.py +++ b/annofabapi/pydantic_models/annotation_type_field_value_margin_of_error_tolerance.py @@ -27,7 +27,7 @@ class AnnotationTypeFieldValueMarginOfErrorTolerance(BaseModel): """ type: StrictStr = Field(alias="_type") - max_pixel: Annotated[int, Field(strict=True, ge=1)] + max_pixel: Annotated[int, Field(strict=True, ge=0)] __properties: ClassVar[List[str]] = ["_type", "max_pixel"] @field_validator("type") diff --git a/annofabapi/pydantic_models/annotation_type_field_value_minimum_size.py b/annofabapi/pydantic_models/annotation_type_field_value_minimum_size.py index 2c89031..e172963 100644 --- a/annofabapi/pydantic_models/annotation_type_field_value_minimum_size.py +++ b/annofabapi/pydantic_models/annotation_type_field_value_minimum_size.py @@ -30,8 +30,8 @@ class AnnotationTypeFieldValueMinimumSize(BaseModel): type: StrictStr = Field(alias="_type") min_warn_rule: AnnotationTypeFieldMinWarnRule - min_width: Annotated[int, Field(strict=True, ge=1)] - min_height: Annotated[int, Field(strict=True, ge=1)] + min_width: Annotated[int, Field(strict=True, ge=0)] + min_height: Annotated[int, Field(strict=True, ge=0)] __properties: ClassVar[List[str]] = ["_type", "min_warn_rule", "min_width", "min_height"] @field_validator("type") @@ -78,6 +78,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of min_warn_rule + if self.min_warn_rule: + _dict["min_warn_rule"] = self.min_warn_rule.to_dict() return _dict @classmethod @@ -92,7 +95,7 @@ def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None: _obj = cls.model_validate( { "_type": obj.get("_type"), - "min_warn_rule": obj.get("min_warn_rule"), + "min_warn_rule": AnnotationTypeFieldMinWarnRule.from_dict(obj["min_warn_rule"]) if obj.get("min_warn_rule") is not None else None, "min_width": obj.get("min_width"), "min_height": obj.get("min_height"), } diff --git a/annofabapi/pydantic_models/annotation_type_field_value_minimum_size2d_with_default_insert_position.py b/annofabapi/pydantic_models/annotation_type_field_value_minimum_size2d_with_default_insert_position.py index 62b3ed3..88eae56 100644 --- a/annofabapi/pydantic_models/annotation_type_field_value_minimum_size2d_with_default_insert_position.py +++ b/annofabapi/pydantic_models/annotation_type_field_value_minimum_size2d_with_default_insert_position.py @@ -30,9 +30,9 @@ class AnnotationTypeFieldValueMinimumSize2dWithDefaultInsertPosition(BaseModel): type: StrictStr = Field(alias="_type") min_warn_rule: AnnotationTypeFieldMinWarnRule - min_width: Annotated[int, Field(strict=True, ge=1)] - min_height: Annotated[int, Field(strict=True, ge=1)] - position_for_minimum_bounding_box_insertion: List[StrictInt] | None = Field( + min_width: StrictInt = Field(description="最小の幅。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 ") + min_height: StrictInt = Field(description="最小の高さ。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 ") + position_for_minimum_bounding_box_insertion: Annotated[List[StrictInt], Field(min_length=2, max_length=2)] | None = Field( default=None, description="最小矩形の挿入位置を、要素が2の配列で指定します。 ", json_schema_extra={"examples": [[0, 0]]} ) __properties: ClassVar[List[str]] = ["_type", "min_warn_rule", "min_width", "min_height", "position_for_minimum_bounding_box_insertion"] @@ -81,6 +81,14 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of min_warn_rule + if self.min_warn_rule: + _dict["min_warn_rule"] = self.min_warn_rule.to_dict() + # set to None if position_for_minimum_bounding_box_insertion (nullable) is None + # and model_fields_set contains the field + if self.position_for_minimum_bounding_box_insertion is None and "position_for_minimum_bounding_box_insertion" in self.model_fields_set: + _dict["position_for_minimum_bounding_box_insertion"] = None + return _dict @classmethod @@ -95,7 +103,7 @@ def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None: _obj = cls.model_validate( { "_type": obj.get("_type"), - "min_warn_rule": obj.get("min_warn_rule"), + "min_warn_rule": AnnotationTypeFieldMinWarnRule.from_dict(obj["min_warn_rule"]) if obj.get("min_warn_rule") is not None else None, "min_width": obj.get("min_width"), "min_height": obj.get("min_height"), "position_for_minimum_bounding_box_insertion": obj.get("position_for_minimum_bounding_box_insertion"), diff --git a/annofabapi/pydantic_models/annotation_type_field_value_vertex_count_min_max.py b/annofabapi/pydantic_models/annotation_type_field_value_vertex_count_min_max.py index 1cf0870..874cb46 100644 --- a/annofabapi/pydantic_models/annotation_type_field_value_vertex_count_min_max.py +++ b/annofabapi/pydantic_models/annotation_type_field_value_vertex_count_min_max.py @@ -16,7 +16,7 @@ import re # noqa: F401 from typing import Any, ClassVar, Dict, List, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -27,8 +27,13 @@ class AnnotationTypeFieldValueVertexCountMinMax(BaseModel): """ type: StrictStr = Field(alias="_type") - min: Annotated[int, Field(strict=True, ge=1)] - max: Annotated[int, Field(strict=True, ge=1)] + min: Annotated[int, Field(strict=True, ge=2)] | None = Field( + default=None, description="頂点数の最小値。データ型が `Polyline2d` の場合は2以上、`Polygon2d` の場合は3以上を指定します。 " + ) + max: StrictInt | None = Field( + default=None, + description="頂点数の最大値。標準種別ではポリラインは2以上、ポリゴンは3以上を指定します。ユーザー定義種別では、`max` のみ指定した場合、下限は検証されません。 ", + ) __properties: ClassVar[List[str]] = ["_type", "min", "max"] @field_validator("type") @@ -75,6 +80,16 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # set to None if min (nullable) is None + # and model_fields_set contains the field + if self.min is None and "min" in self.model_fields_set: + _dict["min"] = None + + # set to None if max (nullable) is None + # and model_fields_set contains the field + if self.max is None and "max" in self.model_fields_set: + _dict["max"] = None + return _dict @classmethod diff --git a/annofabapi/pydantic_models/batch_annotation_v1.py b/annofabapi/pydantic_models/batch_annotation_v1.py index deb8a78..d13cbc7 100644 --- a/annofabapi/pydantic_models/batch_annotation_v1.py +++ b/annofabapi/pydantic_models/batch_annotation_v1.py @@ -48,7 +48,7 @@ class BatchAnnotationV1(BaseModel): json_schema_extra={"examples": ["12345678-abcd-1234-abcd-1234abcd5678"]}, ) additional_data_list: List[AdditionalDataV1] = Field( - description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " + description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " ) updated_datetime: str = Field( description="アノテーション取得時の更新日時。更新時の楽観ロックに利用されます。 AnnotationDetailのものではなく、それを格納するAnnotationV2Outputなどが保持する更新時刻であることに注意してください。 " diff --git a/annofabapi/pydantic_models/default_annotation_type.py b/annofabapi/pydantic_models/default_annotation_type.py index 87cef8b..2849e51 100644 --- a/annofabapi/pydantic_models/default_annotation_type.py +++ b/annofabapi/pydantic_models/default_annotation_type.py @@ -19,7 +19,7 @@ class DefaultAnnotationType(StrEnum): """ - アノテーションの種類 * `bounding_box` - 矩形 * `segmentation` - 塗りつぶし(インスタンスセグメンテーション用) * `segmentation_v2` - 塗りつぶしv2(セマンティックセグメンテーション用) * `polygon` - ポリゴン(閉じた頂点集合) * `polyline` - ポリライン(開いた頂点集合) * `point` - 点 * `classification` - 全体 * `range` - 動画の区間 * `custom` - カスタム プロジェクトの種類によって、使用できるアノテーションの種類は決まっています。アノテーションの種類が使用できるかどうかを、以下の表に記載しました。 * `○`:使用できる * `×`:使用できない |アノテーションの種類 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | |-----------------|:----------:|:----:|:------:| | bounding_box | 〇 | × | × | | segmentation | 〇 | × | × | | segmentation_v2 | 〇 | × | × | | polygon | 〇 | × | × | | polyline | 〇 | × | × | | point | 〇 | × | × | | classification | 〇 | 〇 | × | | range | × | 〇 | × | | custom | × | × | 〇 | + アノテーション種別 * `bounding_box` - 矩形 * `segmentation` - 塗りつぶし(インスタンスセグメンテーション用) * `segmentation_v2` - 塗りつぶしv2(セマンティックセグメンテーション用) * `polygon` - ポリゴン(閉じた頂点集合) * `polyline` - ポリライン(開いた頂点集合) * `point` - 点 * `classification` - 全体 * `range` - 動画の区間 * `custom` - カスタム プロジェクトの種類によって、使用できるアノテーション種別は決まっています。アノテーション種別が使用できるかどうかを、以下の表に記載しました。 * `○`:使用できる * `×`:使用できない |アノテーション種別 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | |-----------------|:----------:|:----:|:------:| | bounding_box | 〇 | × | × | | segmentation | 〇 | × | × | | segmentation_v2 | 〇 | × | × | | polygon | 〇 | × | × | | polyline | 〇 | × | × | | point | 〇 | × | × | | classification | 〇 | 〇 | × | | range | × | 〇 | × | | custom | × | × | 〇 | """ """ diff --git a/annofabapi/pydantic_models/label_v3.py b/annofabapi/pydantic_models/label_v3.py index 3b7b953..ed19fdc 100644 --- a/annofabapi/pydantic_models/label_v3.py +++ b/annofabapi/pydantic_models/label_v3.py @@ -40,7 +40,7 @@ class LabelV3(BaseModel): keybind: List[Keybind] = Field(description="ショートカットキー") annotation_type: AnnotationType field_values: Dict[str, AnnotationTypeFieldValue] = Field( - description="KeyがフィールドIdであるDictionaryです。 カスタムの[組織プラグイン](#operation/putOrganizationPlugin)で利用される[UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition).`field_definitions`で定義されます。 " + description='ラベルごとの制約や設定値を保持するオブジェクトです。 キーには設定項目を識別するフィールドIDを指定し、値にはそのフィールドに設定する制約やオプションを表すオブジェクトを指定します。 例えば頂点数制約は、`"vertex_count_min_max": {"_type": "VertexCountMinMax", "max": 20}` のように指定します。 Annofabの標準エディタでは、アノテーション種別ごとに、使用可能なフィールドIDと設定値の構造があらかじめ決まっています。設定値の構造は、値オブジェクトの `_type` に設定値の構造を示す名前を指定することで示します。以下の表に、フィールドIDと設定値の構造を示す名前を示します。 | エディタ | アノテーション種別(`annotation_type`) | フィールドID → 設定値の構造を示す名前 | | --- | --- | --- | | 画像 | 矩形(`bounding_box`) | `minimum_size_2d_with_default_insert_position` → `MinimumSize2dWithDefaultInsertPosition`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリゴン(`polygon`) | `minimum_size_2d` → `MinimumSize2d`
`minimum_area_2d` → `MinimumArea2d`
`vertex_count_min_max` → `VertexCountMinMax`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | ポリライン(`polyline`) | `minimum_size_2d` → `MinimumSize2d`
`vertex_count_min_max` → `VertexCountMinMax`
`display_line_direction` → `DisplayLineDirection`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 点(`point`) | `margin_of_error_tolerance` → `MarginOfErrorTolerance` | | 画像 | 塗りつぶし(`segmentation`)・塗りつぶしv2(`segmentation_v2`) | `minimum_size_2d` → `MinimumSize2d`
`margin_of_error_tolerance` → `MarginOfErrorTolerance`
`annotation_editor_feature` → `AnnotationEditorFeature` | | 画像・動画 | 全体(`classification`) | なし | | 動画 | 区間(`range`) | なし | ユーザー定義アノテーション種別では、[組織プラグイン](#operation/putOrganizationPlugin)の [UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition) の `field_definitions` で定義されたフィールドIDをキーに指定します。値オブジェクトの `_type` には、設定値の構造を示す名前を指定します。指定する名前は、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)を参照してください。 ' ) additional_data_definitions: List[StrictStr] = Field(description="ラベルに所属する属性のID") color: Color diff --git a/annofabapi/pydantic_models/plugin_detail_extended_annotation_specs.py b/annofabapi/pydantic_models/plugin_detail_extended_annotation_specs.py index c470012..5e21b44 100644 --- a/annofabapi/pydantic_models/plugin_detail_extended_annotation_specs.py +++ b/annofabapi/pydantic_models/plugin_detail_extended_annotation_specs.py @@ -36,7 +36,7 @@ class PluginDetailExtendedAnnotationSpecs(BaseModel): description="プラグインを使用したプロジェクトで選択可能なアノテーション種別のリストです。 同じ種別を重複して設定することはできません。 " ) user_defined_annotation_type_definitions: Dict[str, UserDefinedAnnotationTypeDefinition] | None = Field( - default=None, description="Keyが[アノテーションの種類(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 " + default=None, description="Keyが[アノテーション種別(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 " ) compatible_input_data_types: List[InputDataType] = Field( description="プラグインが対応している入力データです。 プラグイン種別がカスタムアノテーションエディタ、またはカスタムアノテーション仕様の場合のみ有効です。 ", diff --git a/annofabapi/pydantic_models/single_annotation_detail_v1.py b/annofabapi/pydantic_models/single_annotation_detail_v1.py index 66f836b..d033ec7 100644 --- a/annofabapi/pydantic_models/single_annotation_detail_v1.py +++ b/annofabapi/pydantic_models/single_annotation_detail_v1.py @@ -47,7 +47,7 @@ class SingleAnnotationDetailV1(BaseModel): etag: StrictStr | None = Field(default=None, description="data_holding_typeがouterの場合のみ存在し、データのETagが格納される") url: StrictStr | None = Field(default=None, description="data_holding_typeがouterの場合のみ存在し、データへの一時URLが格納される") additional_data_list: List[AdditionalDataV1] = Field( - description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| text | comment | | 自由記述(複数行)| comment | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " + description="属性情報。 アノテーション属性の種類(`additional_data_definition`の`type`)によって、属性値を格納するプロパティは変わります。 | 属性の種類 | `additional_data_definition`の`type` | 属性値を格納するプロパティ | |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | | 自由記述(1行)| comment | comment | | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | | 排他選択(ドロップダウン) | select | choice | " ) created_datetime: str = Field(description="作成日時") updated_datetime: str = Field(description="更新日時") diff --git a/annofabapi/pydantic_models/user_defined_annotation_data_type.py b/annofabapi/pydantic_models/user_defined_annotation_data_type.py index d824c77..debd7bc 100644 --- a/annofabapi/pydantic_models/user_defined_annotation_data_type.py +++ b/annofabapi/pydantic_models/user_defined_annotation_data_type.py @@ -28,7 +28,7 @@ class UserDefinedAnnotationDataType(BaseModel): type: StrictStr | None = Field( default=None, - description="ユーザー定義アノテーション種別の型を指定します。 指定可能な値と、その意味は下記の通りです。 * `BoundingBox2d` - 2次元の矩形 * `Polygon2d` - 2次元のポリゴン * `Polyline2d` - 2次元のポリライン * `SinglePoint2d` - 2次元の点 * `SemanticSegmentation2d` - 2次元のセマンティックセグメンテーション * `InstanceSegmentation2d` - 2次元のインスタンスセグメンテーション * `Range1d` - 1次元の範囲 * `Classification` - 全体アノテーション * `Unknown` - その他のアノテーション種別 下記のフィールド定義は、すべてのアノテーション種別の型に対して使用可能です。 * `OneIntegerField` * `OneStringField` * `OneBooleanField` その他のフィールド定義は、使用可能なアノテーション種別の型に制限があります。 ユーザー定義アノテーション種別の型ごとの、使用可能なフィールド定義を下記の表で示します。 |ユーザー定義アノテーション種別の型 | 使用可能なフィールド定義 | |-----------------|:----------:| | BoundingBox2d | MinimumSize2dWithDefaultInsertPosition, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polygon2d | MinimumSize2d, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polyline2d | VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | | SinglePoint2d | MarginOfErrorTolerance | | SemanticSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | | InstanceSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | | Range1d | MarginOfErrorTolerance | | Classification | MarginOfErrorTolerance | | Unknown | - | ", + description="ユーザー定義アノテーション種別が扱うデータ型を指定します。 指定可能な値と、その意味は下記の通りです。 * `BoundingBox2d` - 2次元の矩形 * `Polygon2d` - 2次元のポリゴン * `Polyline2d` - 2次元のポリライン * `SinglePoint2d` - 2次元の点 * `SemanticSegmentation2d` - 2次元のセマンティックセグメンテーション * `InstanceSegmentation2d` - 2次元のインスタンスセグメンテーション * `Range1d` - 1次元の範囲 * `Classification` - 全体アノテーション * `Unknown` - その他のアノテーション種別 下記のフィールド定義は、すべてのデータ型に対して使用可能です。 * `OneIntegerField` * `OneStringField` * `OneBooleanField` その他のフィールド定義は、使用可能なデータ型に制限があります。 データ型ごとの、使用可能なフィールド定義を下記の表で示します。 |データ型 | 使用可能なフィールド定義 | |-----------------|:----------:| | BoundingBox2d | MinimumSize2d, MinimumSize2dWithDefaultInsertPosition, MinimumArea2d, MarginOfErrorTolerance | | Polygon2d | MinimumSize2d, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | | Polyline2d | MinimumSize2d, VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | | SinglePoint2d | MarginOfErrorTolerance | | SemanticSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | | InstanceSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | | Range1d | なし | | Classification | なし | | Unknown | なし | ", alias="_type", ) __properties: ClassVar[List[str]] = ["_type"] diff --git a/annofabapi/pydantic_models/user_defined_annotation_type_field_definition.py b/annofabapi/pydantic_models/user_defined_annotation_type_field_definition.py index 69d379f..067a2da 100644 --- a/annofabapi/pydantic_models/user_defined_annotation_type_field_definition.py +++ b/annofabapi/pydantic_models/user_defined_annotation_type_field_definition.py @@ -47,7 +47,7 @@ class UserDefinedAnnotationTypeFieldDefinition(BaseModel): """ - ユーザー定義のアノテーション種別に設定可能なフィールドについての定義です。 + ユーザー定義アノテーション種別が持つ、制約やオプションを設定するためのフィールドを定義します。 アノテーション仕様V3では、このフィールド定義に対応する設定値オブジェクトを指定します。フィールド定義と設定値は、それぞれのオブジェクトの `_type` で種類を識別します。両者の対応を以下の表に示します。 設定値には、表に示す `_type` を持つ [AnnotationTypeFieldValue](#tag/x-data-types/AnnotationTypeFieldValue) のオブジェクトを指定します。 | フィールド定義の `_type` | 設定値オブジェクトの `_type` | | --- | --- | | `MinimumSize2d` | `MinimumSize2d` | | `MinimumSize2dWithDefaultInsertPosition` | `MinimumSize2dWithDefaultInsertPosition` | | `MarginOfErrorTolerance` | `MarginOfErrorTolerance` | | `VertexCountMinMax` | `VertexCountMinMax` | | `MinimumArea2d` | `MinimumArea2d` | | `DisplayLineDirection` | `DisplayLineDirection` | | `AnnotationEditorFeature` | `AnnotationEditorFeature` | | `OneIntegerField` | `OneIntegerFieldValue` | | `OneStringField` | `OneStringFieldValue` | | `OneBooleanField` | `OneBooleanFieldValue` | """ # data type: AnnotationTypeFieldDefinitionMinimumSize2d diff --git a/generate/swagger/swagger-api-components.yaml b/generate/swagger/swagger-api-components.yaml index 2d38a3c..ec62891 100644 --- a/generate/swagger/swagger-api-components.yaml +++ b/generate/swagger/swagger-api-components.yaml @@ -1180,7 +1180,7 @@ components: user_defined_annotation_type_definitions: type: object description: | - Keyが[アノテーションの種類(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 + Keyが[アノテーション種別(AnnotationType)](#tag/x-data-types/AnnotationType)であるDictionaryです。 additionalProperties: $ref: "#/components/schemas/UserDefinedAnnotationTypeDefinition" compatible_input_data_types: @@ -3330,7 +3330,7 @@ components: - range - custom description: | - アノテーションの種類 + アノテーション種別 * `bounding_box` - 矩形 * `segmentation` - 塗りつぶし(インスタンスセグメンテーション用) * `segmentation_v2` - 塗りつぶしv2(セマンティックセグメンテーション用) @@ -3341,12 +3341,12 @@ components: * `range` - 動画の区間 * `custom` - カスタム - プロジェクトの種類によって、使用できるアノテーションの種類は決まっています。アノテーションの種類が使用できるかどうかを、以下の表に記載しました。 + プロジェクトの種類によって、使用できるアノテーション種別は決まっています。アノテーション種別が使用できるかどうかを、以下の表に記載しました。 * `○`:使用できる * `×`:使用できない - |アノテーションの種類 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | + |アノテーション種別 | 画像プロジェクト | 動画プロジェクト | カスタムプロジェクト | |-----------------|:----------:|:----:|:------:| | bounding_box | 〇 | × | × | | segmentation | 〇 | × | × | @@ -3361,7 +3361,7 @@ components: UserDefinedAnnotationType: type: string description: | - ユーザー定義のアノテーション種別名です。先頭が `user_` から始まる任意の文字列を指定します。 + ユーザー定義アノテーション種別名です。先頭が `user_` から始まる任意の文字列を指定します。 example: user_bounding_box UserDefinedAnnotationTypeDefinition: type: object @@ -3399,7 +3399,22 @@ components: $ref: "#/components/schemas/UserDefinedAnnotationDataType" UserDefinedAnnotationTypeFieldDefinition: description: | - ユーザー定義のアノテーション種別に設定可能なフィールドについての定義です。 + ユーザー定義アノテーション種別が持つ、制約やオプションを設定するためのフィールドを定義します。 + アノテーション仕様V3では、このフィールド定義に対応する設定値オブジェクトを指定します。フィールド定義と設定値は、それぞれのオブジェクトの `_type` で種類を識別します。両者の対応を以下の表に示します。 + 設定値には、表に示す `_type` を持つ [AnnotationTypeFieldValue](#tag/x-data-types/AnnotationTypeFieldValue) のオブジェクトを指定します。 + + | フィールド定義の `_type` | 設定値オブジェクトの `_type` | + | --- | --- | + | `MinimumSize2d` | `MinimumSize2d` | + | `MinimumSize2dWithDefaultInsertPosition` | `MinimumSize2dWithDefaultInsertPosition` | + | `MarginOfErrorTolerance` | `MarginOfErrorTolerance` | + | `VertexCountMinMax` | `VertexCountMinMax` | + | `MinimumArea2d` | `MinimumArea2d` | + | `DisplayLineDirection` | `DisplayLineDirection` | + | `AnnotationEditorFeature` | `AnnotationEditorFeature` | + | `OneIntegerField` | `OneIntegerFieldValue` | + | `OneStringField` | `OneStringFieldValue` | + | `OneBooleanField` | `OneBooleanFieldValue` | oneOf: - $ref: "#/components/schemas/AnnotationTypeFieldDefinitionMinimumSize2d" - $ref: "#/components/schemas/AnnotationTypeFieldDefinitionMinimumSize2dWithDefaultInsertPosition" @@ -3587,7 +3602,7 @@ components: _type: type: string description: | - ユーザー定義アノテーション種別の型を指定します。 + ユーザー定義アノテーション種別が扱うデータ型を指定します。 指定可能な値と、その意味は下記の通りです。 * `BoundingBox2d` - 2次元の矩形 @@ -3600,25 +3615,25 @@ components: * `Classification` - 全体アノテーション * `Unknown` - その他のアノテーション種別 - 下記のフィールド定義は、すべてのアノテーション種別の型に対して使用可能です。 + 下記のフィールド定義は、すべてのデータ型に対して使用可能です。 * `OneIntegerField` * `OneStringField` * `OneBooleanField` - その他のフィールド定義は、使用可能なアノテーション種別の型に制限があります。 - ユーザー定義アノテーション種別の型ごとの、使用可能なフィールド定義を下記の表で示します。 + その他のフィールド定義は、使用可能なデータ型に制限があります。 + データ型ごとの、使用可能なフィールド定義を下記の表で示します。 - |ユーザー定義アノテーション種別の型 | 使用可能なフィールド定義 | + |データ型 | 使用可能なフィールド定義 | |-----------------|:----------:| - | BoundingBox2d | MinimumSize2dWithDefaultInsertPosition, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | + | BoundingBox2d | MinimumSize2d, MinimumSize2dWithDefaultInsertPosition, MinimumArea2d, MarginOfErrorTolerance | | Polygon2d | MinimumSize2d, VertexCountMinMax, MinimumArea2d, MarginOfErrorTolerance | - | Polyline2d | VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | + | Polyline2d | MinimumSize2d, VertexCountMinMax, DisplayLineDirection, MarginOfErrorTolerance | | SinglePoint2d | MarginOfErrorTolerance | - | SemanticSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | - | InstanceSegmentation2d | AnnotationEditorFeature, MarginOfErrorTolerance | - | Range1d | MarginOfErrorTolerance | - | Classification | MarginOfErrorTolerance | - | Unknown | - | + | SemanticSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | + | InstanceSegmentation2d | MinimumSize2d, AnnotationEditorFeature, MarginOfErrorTolerance | + | Range1d | なし | + | Classification | なし | + | Unknown | なし | enum: - BoundingBox2d - Polygon2d @@ -3634,8 +3649,8 @@ components: enum: - flag - integer - - text - comment + - text - choice - select - tracking @@ -3644,8 +3659,8 @@ components: 属性の種類 * `flag` - 真偽値 * `integer` - 整数値 - * `text` - 自由記述(1行) - * `comment` - 自由記述(複数行) + * `comment` - 自由記述(1行) + * `text` - 自由記述(複数行) * `choice` - 選択肢(ラジオボタン式) * `select` - 選択肢(ドロップダウン式) * `tracking` - トラッキングID @@ -3856,9 +3871,23 @@ components: field_values: type: object description: | - KeyがフィールドIdであるDictionaryです。 + ラベルごとの制約や設定値を保持するオブジェクトです。 + キーには設定項目を識別するフィールドIDを指定し、値にはそのフィールドに設定する制約やオプションを表すオブジェクトを指定します。 + 例えば頂点数制約は、`"vertex_count_min_max": {"_type": "VertexCountMinMax", "max": 20}` のように指定します。 + + Annofabの標準エディタでは、アノテーション種別ごとに、使用可能なフィールドIDと設定値の構造があらかじめ決まっています。設定値の構造は、値オブジェクトの `_type` に設定値の構造を示す名前を指定することで示します。以下の表に、フィールドIDと設定値の構造を示す名前を示します。 + + | エディタ | アノテーション種別(`annotation_type`) | フィールドID → 設定値の構造を示す名前 | + | --- | --- | --- | + | 画像 | 矩形(`bounding_box`) | `minimum_size_2d_with_default_insert_position` → `MinimumSize2dWithDefaultInsertPosition`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | + | 画像 | ポリゴン(`polygon`) | `minimum_size_2d` → `MinimumSize2d`
`minimum_area_2d` → `MinimumArea2d`
`vertex_count_min_max` → `VertexCountMinMax`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | + | 画像 | ポリライン(`polyline`) | `minimum_size_2d` → `MinimumSize2d`
`vertex_count_min_max` → `VertexCountMinMax`
`display_line_direction` → `DisplayLineDirection`
`margin_of_error_tolerance` → `MarginOfErrorTolerance` | + | 画像 | 点(`point`) | `margin_of_error_tolerance` → `MarginOfErrorTolerance` | + | 画像 | 塗りつぶし(`segmentation`)・塗りつぶしv2(`segmentation_v2`) | `minimum_size_2d` → `MinimumSize2d`
`margin_of_error_tolerance` → `MarginOfErrorTolerance`
`annotation_editor_feature` → `AnnotationEditorFeature` | + | 画像・動画 | 全体(`classification`) | なし | + | 動画 | 区間(`range`) | なし | - カスタムの[組織プラグイン](#operation/putOrganizationPlugin)で利用される[UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition).`field_definitions`で定義されます。 + ユーザー定義アノテーション種別では、[組織プラグイン](#operation/putOrganizationPlugin)の [UserDefinedAnnotationTypeDefinition](#tag/x-data-types/UserDefinedAnnotationTypeDefinition) の `field_definitions` で定義されたフィールドIDをキーに指定します。値オブジェクトの `_type` には、設定値の構造を示す名前を指定します。指定する名前は、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)を参照してください。 additionalProperties: $ref: "#/components/schemas/AnnotationTypeFieldValue" additional_data_definitions: @@ -3876,8 +3905,9 @@ components: type: string AnnotationTypeFieldValue: description: | - ユーザー定義アノテーション種別のフィールドに設定される値です。 - アノテーション種別のフィールド定義と対応するフィールド値のみ登録を許可されます。 + フィールドに設定する制約やオプションを表すオブジェクトです。 + Annofabの標準エディタで使用するアノテーション種別では、[LabelV3 の `field_values`](#tag/x-data-types/LabelV3) に記載された、設定値の構造を示す名前を `_type` に指定します。 + ユーザー定義アノテーション種別では、[フィールド定義と設定値の対応表](#tag/x-data-types/UserDefinedAnnotationTypeDefinition)(`field_definitions` の `definition` の説明)に示す、設定値オブジェクトの `_type` を指定します。 oneOf: - $ref: "#/components/schemas/AnnotationTypeFieldValueMinimumSize" - $ref: "#/components/schemas/AnnotationTypeFieldValueMinimumSize2dWithDefaultInsertPosition" @@ -3920,11 +3950,12 @@ components: $ref: "#/components/schemas/AnnotationTypeFieldMinWarnRule" min_width: type: integer - minimum: 1 + minimum: 0 min_height: type: integer - minimum: 1 + minimum: 0 AnnotationTypeFieldValueMinimumSize2dWithDefaultInsertPosition: + type: object required: - _type - min_warn_rule @@ -3938,27 +3969,38 @@ components: $ref: "#/components/schemas/AnnotationTypeFieldMinWarnRule" min_width: type: integer - minimum: 1 + description: | + 最小の幅。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 min_height: type: integer - minimum: 1 + description: | + 最小の高さ。標準の矩形種別では0以上を指定します。ユーザー定義種別では、現在、下限は検証されません。 position_for_minimum_bounding_box_insertion: type: array + nullable: true + minItems: 2 + maxItems: 2 description: | 最小矩形の挿入位置を、要素が2の配列で指定します。 example: [0, 0] items: type: integer AnnotationTypeFieldMinWarnRule: - type: string - enum: - - and - - or + type: object + required: + - _type + properties: + _type: + type: string + enum: + - And + - Or + example: {"_type": "Or"} description: | - 最小の幅(min_width)と最小の高さ(min_height)がどのような状態になったときにエラーとするかを指定します。 + 最小の幅(min_width)と最小の高さ(min_height)に対する判定条件を指定します。 - * `and` - min_width、min_heightの両方が最小値未満の場合にエラーとなります。 - * `or` - min_width、min_heightのいずれかが最小値未満の場合にエラーとなります。 + * `And` - min_width、min_heightの両方が最小値未満の場合に最小サイズ違反となります。 + * `Or` - min_width、min_heightのいずれかが最小値未満の場合に最小サイズ違反となります。 AnnotationTypeFieldValueMarginOfErrorTolerance: type: object description: 誤差許容範囲 @@ -3971,25 +4013,28 @@ components: enum: ["MarginOfErrorTolerance"] max_pixel: type: integer - minimum: 1 + minimum: 0 AnnotationTypeFieldValueVertexCountMinMax: type: object description: | 頂点数の最大・最小 required: - _type - - min - - max properties: _type: type: string enum: ["VertexCountMinMax"] min: + description: | + 頂点数の最小値。データ型が `Polyline2d` の場合は2以上、`Polygon2d` の場合は3以上を指定します。 type: integer - minimum: 1 + minimum: 2 + nullable: true max: + description: | + 頂点数の最大値。標準種別ではポリラインは2以上、ポリゴンは3以上を指定します。ユーザー定義種別では、`max` のみ指定した場合、下限は検証されません。 type: integer - minimum: 1 + nullable: true AnnotationTypeFieldValueMinimumArea2d: type: object description: | @@ -4270,9 +4315,9 @@ components: * `AdditionalDataRestrictionConditionEquals`: 指定した値に等しい * `AdditionalDataRestrictionConditionNotEquals`: 指定した値に等しくない * `AdditionalDataRestrictionConditionMatches`: 指定した正規表現に一致する - * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 + * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionNotMatches`: 指定した正規表現に一致しない - * `AdditionalDataDefinitionType`が`text`か`comment`のときのみ利用可能 + * `AdditionalDataDefinitionType`が`comment`か`text`のときのみ利用可能 * `AdditionalDataRestrictionConditionHasLabel`: 指定したラベルIDに一致する(アノテーションリンク属性限定) * `AdditionalDataDefinitionType`が`link`のときのみ利用可能 * `AdditionalDataRestrictionConditionImply`: 指定した前提条件を満たすときのみ、制約を満たすかどうか @@ -5866,8 +5911,8 @@ components: |------------|-------------------------|----------------------| | ON/OFF | flag | flag | | 整数 | integer | integer | - | 自由記述(1行)| text | comment | - | 自由記述(複数行)| comment | comment | + | 自由記述(1行)| comment | comment | + | 自由記述(複数行)| text | comment | | トラッキングID | tracking | comment | | アノテーションリンク | link | comment | | 排他選択(ラジオボタン) |choice | choice | @@ -5899,7 +5944,7 @@ components: comment: type: string description: | - `additional_data_definition`の`type`が`text`,`comment`,`link` または `tracking`のときの属性値。 + `additional_data_definition`の`type`が`comment`,`text`,`link` または `tracking`のときの属性値。 choice: $ref: "#/components/schemas/ChoiceId" description: | @@ -8102,8 +8147,8 @@ components: |-----------------|----------| | flag | 真偽値(`true` or `false`)| | integer | 整数値 | - | text | 文字列 | | comment | 文字列| + | text | 文字列 | | choice | 選択肢(`choices`)の `choice_id` | | select | 選択肢(`choices`)の`choice_id`| diff --git a/generate/swagger/swagger.v2.yaml b/generate/swagger/swagger.v2.yaml index 2bd3d0f..294793c 100644 --- a/generate/swagger/swagger.v2.yaml +++ b/generate/swagger/swagger.v2.yaml @@ -115,7 +115,7 @@ info: 上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。 - version: 0.213.0 + version: 0.214.0 title: Annofab Web API x-logo: url: "https://annofab.com/resource/images/logo_landscape.png" diff --git a/generate/swagger/swagger.yaml b/generate/swagger/swagger.yaml index 6507671..83f3cb6 100644 --- a/generate/swagger/swagger.yaml +++ b/generate/swagger/swagger.yaml @@ -119,7 +119,7 @@ info: 上記例 `account_id_count` は、タスクのフィールド `account_id` でタスクを分類したところ「`account_id` が `c5eee002` であるタスクが9件、`9f110e48` であるタスクが5件、`b25dfeb3` であるタスクが1件」だったという結果を表しています。 また、AggregationResultの集約の件数は、合計で10000件以下に制限されており、それを超える件数がある場合は上位10000件が取得されます。もし、省略された部分を取得したい場合は、検索条件を縛って結果に上る集約の数を減らしてください。 - version: 0.213.0 + version: 0.214.0 title: Annofab Web API x-logo: url: "https://annofab.com/resource/images/logo_landscape.png" @@ -317,9 +317,15 @@ tags: # AnnotationType + # LabelV3 + + # UserDefinedAnnotationTypeDefinition + # AnnotationTypeFieldValue + + x-tagGroups: - name: API tags: @@ -3645,8 +3651,16 @@ paths: summary: アノテーション仕様更新 description: | アノテーション仕様を更新します。 + + プロジェクトのチェッカーロールを持つユーザーは、以下の項目のみ変更できます。 + * ラベルの色 + * ラベル・属性・選択肢のショートカットキー + * ラベル・属性・選択肢の表示順 + * 定型指摘 + + チェッカーロールを持つユーザーがそれ以外の項目を変更しようとした場合、`403 Forbidden`(エラーコード`FORBIDDEN_FEATURE`)になります。 security: - - ProjectOwner: [] + - ProjectAccepter: [] operationId: putAnnotationSpecs parameters: - name: project_id @@ -4159,6 +4173,8 @@ paths: description: | タスクを作成または更新します。 + 一度でもタスクが作業中になっている場合は、タスクの入力データを更新することはできません。入力データを更新したい場合は、新しくタスクを作成してください。 + 大量のタスクを一括で生成する場合は、[initiateTasksGeneration](#operation/initiateTasksGeneration) APIの使用を検討してください。 security: