Skip to content

Commit

Permalink
annotation , annptation_specsにデータクラスを追加 (#514)
Browse files Browse the repository at this point in the history
* poetry update

* format

* update swagger

* アノテーションの追加

* アノテーション仕様の追加

* generated_api

* generate.shの修正

* 生成

* dataclassへの変換

* version up
  • Loading branch information
yuji38kwmt committed Nov 4, 2022
1 parent 051fd2a commit d5ea566
Show file tree
Hide file tree
Showing 12 changed files with 720 additions and 142 deletions.
2 changes: 1 addition & 1 deletion annofabapi/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.64.0"
__version__ = "0.65.0"
373 changes: 371 additions & 2 deletions annofabapi/dataclass/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@
TaskStatus,
)

AnnotationDataV1 = Union[str, Dict[str, Any]]
FullAnnotationData = Any
AdditionalDataValue = Dict[str, Any]
FullAnnotationAdditionalDataValue = Dict[str, Any]
AnnotationDataV1 = Union[str, Dict[str, Any]]
AnnotationDetailV2Input = Dict[str, Any]
AnnotationDetailContentOutput = Dict[str, Any]
AnnotationType = str
AnnotationDetailContentInput = Dict[str, Any]
AnnotationDetailV2Output = Dict[str, Any]


@dataclass
Expand Down Expand Up @@ -177,7 +182,7 @@ class FullAnnotationDetail(DataClassJsonMixin):
label_name: InternationalizationMessage
""""""

annotation_type: str
annotation_type: AnnotationType
""""""

data_holding_type: AnnotationDataHoldingType
Expand Down Expand Up @@ -393,3 +398,367 @@ class AnnotationV1(DataClassJsonMixin):

updated_datetime: Optional[str]
"""更新日時"""


@dataclass
class AdditionalDataV2(DataClassJsonMixin):
""" """

definition_id: str
"""属性ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

value: Optional[AdditionalDataValue]
""""""


@dataclass
class AnnotationPropsForEditor(DataClassJsonMixin):
"""
アノテーションエディタ用のアノテーション毎のプロパティです。<br /> ここに含まれているデータはアノテーション結果に反映されず、エディタが利用するために存在します。 エディタ用のデータであるため、たとえば`can_delete`や`can_edit_data`が`false`でも、APIによる編集は妨げません。<br /> ここで定義されているデータを利用して動作を変えるかどうかは、エディタによって異なります。
"""

can_delete: Optional[bool]
"""アノテーションがエディタ上で削除できるかどうか。 trueの場合削除可能。"""

can_edit_data: Optional[bool]
"""アノテーションの本体のデータを編集できるかどうか。 trueの場合編集可能。 2022/09現在、この値を利用しているエディタは存在しません。"""

can_edit_additional: Optional[bool]
"""アノテーションの付加情報を編集できるかどうか。 trueの場合編集可能。 2022/09現在、この値を利用しているエディタは存在しません。"""

description: Optional[str]
"""アノテーションについての人間可読な説明。 2022/09現在、この値を利用しているエディタは存在しません。"""

tags: Optional[List[str]]
"""アノテーションに付与されている機械可読・人間可読なタグの列。 2022/09現在、この値を利用しているエディタは存在しません"""

etc: Optional[Dict[str, Any]]
"""上記以外の任意のJson構造"""


@dataclass
class AdditionalDataValueFlag(DataClassJsonMixin):
""" """

type: str
""""""

value: bool
"""ON/OFF属性の属性値。 ONの時trueとなります"""


@dataclass
class AdditionalDataValueInteger(DataClassJsonMixin):
""" """

type: str
""""""

value: int
"""整数属性の属性値"""


@dataclass
class AdditionalDataValueComment(DataClassJsonMixin):
""" """

type: str
""""""

value: str
"""自由記述(1行)の属性値"""


@dataclass
class AdditionalDataValueText(DataClassJsonMixin):
""" """

type: str
""""""

value: str
"""自由記述(複数行)の属性値"""


@dataclass
class AdditionalDataValueChoice(DataClassJsonMixin):
""" """

type: str
""""""

choice_id: str
"""選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """


@dataclass
class AdditionalDataValueSelect(DataClassJsonMixin):
""" """

type: str
""""""

choice_id: str
"""選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """


@dataclass
class AdditionalDataValueTracking(DataClassJsonMixin):
""" """

type: str
""""""

value: str
"""トラッキングID属性の属性値"""


@dataclass
class AdditionalDataValueLink(DataClassJsonMixin):
""" """

type: str
""""""

annotation_id: str
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """


@dataclass
class AnnotationDetailContentInputInner(DataClassJsonMixin):
"""
アノテーションのデータ部をJSON内部に保持します
"""

type: str
""""""

data: FullAnnotationData
""""""


@dataclass
class AnnotationDetailContentInputOuter(DataClassJsonMixin):
"""
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します
"""

type: str
""""""

path: str
"""外部ファイルの位置を示す文字列。 [createTempPath](#operation/createTempPath) APIによって取得したpathを指定します。"""


@dataclass
class AnnotationDetailV2Create(DataClassJsonMixin):
"""
新規にアノテーションを作成する場合にこの型を利用します。
"""

type: str
""""""

annotation_id: str
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """

label_id: str
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

body: AnnotationDetailContentInput
""""""

additional_data_list: List[AdditionalDataV2]
""""""

editor_props: AnnotationPropsForEditor
""""""


@dataclass
class AnnotationDetailV2Import(DataClassJsonMixin):
"""
過去にAnnofab内外で作成したアノテーションをそのままインポートする場合にこの型を利用します。
"""

type: str
""""""

annotation_id: str
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """

account_id: str
"""アカウントID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

label_id: str
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

body: AnnotationDetailContentInput
""""""

additional_data_list: List[AdditionalDataV2]
""""""

editor_props: AnnotationPropsForEditor
""""""

created_datetime: str
"""作成日時"""

updated_datetime: str
"""更新日時"""


@dataclass
class AnnotationDetailV2Update(DataClassJsonMixin):
"""
既に存在するアノテーションを更新する場合にこの型を利用します
"""

type: str
""""""

annotation_id: str
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """

label_id: str
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

body: Optional[AnnotationDetailContentInput]
""""""

additional_data_list: List[AdditionalDataV2]
""""""

editor_props: AnnotationPropsForEditor
""""""


@dataclass
class AnnotationV2Input(DataClassJsonMixin):
""" """

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

task_id: str
"""タスクID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

input_data_id: str
"""入力データID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

details: List[AnnotationDetailV2Input]
"""矩形、ポリゴン、全体アノテーションなど個々のアノテーションの配列。"""

updated_datetime: Optional[str]
"""対象タスク・対象入力データへの最初の保存時は未指定にしてください。 更新の場合はアノテーション取得時のupdated_datetimeをそのまま指定してください。 """

format_version: str
""""""


@dataclass
class AnnotationDetailContentOutputInner(DataClassJsonMixin):
"""
アノテーションのデータ部をJSON内部に保持します
"""

type: str
""""""

data: FullAnnotationData
""""""


@dataclass
class AnnotationDetailContentOutputInnerUnknown(DataClassJsonMixin):
"""
アノテーションのデータ部をJSON内部に保持します。 AnnotationDetailV1の形式で保存されていたデータのAnnotationTypeが特定できない場合にこの値となります。 典型的な例では、アノテーションの保存後にアノテーション仕様が書き換わっていた場合が該当します。
"""

type: str
""""""

data: str
"""アノテーション座標値や区間などの文字列表現です。 アノテーション種類(`annotation_type`)とデータ格納形式(`data_holding_type`)に応じて、以下のとおり表現が変わります。 <table> <tr><th>annotation_type</th><th>data_holding_type</th><th>文字列表現</th></tr> <tr><td>bounding_box</td><td>inner</td><td><code>\"左上x,左上y,右下x,右下y\"</code></td></tr> <tr><td>point</td><td>inner</td><td><code>\"x1,y1\"</code></td></tr> <tr><td>polygon / polyline</td><td>inner</td><td><code>\"x1,y1,x2,y2, ... \"</code></td></tr> <tr><td>range </td><td>inner</td><td><code>\"開始時間(ミリ秒),終了時間(ミリ秒) \"</code></td></tr> <tr><td>classification</td><td>inner</td><td><code>null</code></td></tr> <tr><td>segmentation</td><td>outer</td><td><code>null</code></td></tr> <tr><td>segmentation_v2</td><td>outer</td><td><code>null</code></td></tr> </table> """


@dataclass
class AnnotationDetailContentOutputOuter(DataClassJsonMixin):
"""
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します
"""

type: str
""""""

url: str
"""外部ファイルに保存されたアノテーションの認証済み一時URL"""

etag: str
"""外部ファイルに保存されたアノテーションのETag"""


@dataclass
class AnnotationDetailContentOutputOuterUnresolved(DataClassJsonMixin):
"""
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します。 Outerのurl / etagを解決しなかった場合(過去のアノテーションを取得した場合等)にこの値となります。
"""

type: str
""""""


@dataclass
class AnnotationDetailV2Get(DataClassJsonMixin):
""" """

type: str
""""""

annotation_id: str
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """

account_id: str
"""アカウントID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

label_id: str
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

body: AnnotationDetailContentOutput
""""""

additional_data_list: List[AdditionalDataV2]
""""""

editor_props: AnnotationPropsForEditor
""""""

created_datetime: str
"""作成日時"""

updated_datetime: str
"""更新日時"""


@dataclass
class AnnotationV2Output(DataClassJsonMixin):
""" """

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

task_id: str
"""タスクID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

input_data_id: str
"""入力データID。[値の制約についてはこちら。](#section/API-Convention/APIID) """

details: List[AnnotationDetailV2Output]
"""矩形、ポリゴン、全体アノテーションなど個々のアノテーションの配列。"""

updated_datetime: Optional[str]
"""対象タスク・対象入力データへ一度もアノテーションの保存が行われていない場合、未指定となります。 そうで無い場合、対象タスク・対象入力データのアノテーション最終更新時刻です。 """

format_version: str
""""""

0 comments on commit d5ea566

Please sign in to comment.