Skip to content

Commit d5ea566

Browse files
authored
annotation , annptation_specsにデータクラスを追加 (#514)
* poetry update * format * update swagger * アノテーションの追加 * アノテーション仕様の追加 * generated_api * generate.shの修正 * 生成 * dataclassへの変換 * version up
1 parent 051fd2a commit d5ea566

File tree

12 files changed

+720
-142
lines changed

12 files changed

+720
-142
lines changed

annofabapi/__version__.py

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

annofabapi/dataclass/annotation.py

Lines changed: 371 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@
2323
TaskStatus,
2424
)
2525

26+
AnnotationDataV1 = Union[str, Dict[str, Any]]
2627
FullAnnotationData = Any
2728
AdditionalDataValue = Dict[str, Any]
2829
FullAnnotationAdditionalDataValue = Dict[str, Any]
29-
AnnotationDataV1 = Union[str, Dict[str, Any]]
30+
AnnotationDetailV2Input = Dict[str, Any]
31+
AnnotationDetailContentOutput = Dict[str, Any]
32+
AnnotationType = str
33+
AnnotationDetailContentInput = Dict[str, Any]
34+
AnnotationDetailV2Output = Dict[str, Any]
3035

3136

3237
@dataclass
@@ -177,7 +182,7 @@ class FullAnnotationDetail(DataClassJsonMixin):
177182
label_name: InternationalizationMessage
178183
""""""
179184

180-
annotation_type: str
185+
annotation_type: AnnotationType
181186
""""""
182187

183188
data_holding_type: AnnotationDataHoldingType
@@ -393,3 +398,367 @@ class AnnotationV1(DataClassJsonMixin):
393398

394399
updated_datetime: Optional[str]
395400
"""更新日時"""
401+
402+
403+
@dataclass
404+
class AdditionalDataV2(DataClassJsonMixin):
405+
""" """
406+
407+
definition_id: str
408+
"""属性ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
409+
410+
value: Optional[AdditionalDataValue]
411+
""""""
412+
413+
414+
@dataclass
415+
class AnnotationPropsForEditor(DataClassJsonMixin):
416+
"""
417+
アノテーションエディタ用のアノテーション毎のプロパティです。<br /> ここに含まれているデータはアノテーション結果に反映されず、エディタが利用するために存在します。 エディタ用のデータであるため、たとえば`can_delete`や`can_edit_data`が`false`でも、APIによる編集は妨げません。<br /> ここで定義されているデータを利用して動作を変えるかどうかは、エディタによって異なります。
418+
"""
419+
420+
can_delete: Optional[bool]
421+
"""アノテーションがエディタ上で削除できるかどうか。 trueの場合削除可能。"""
422+
423+
can_edit_data: Optional[bool]
424+
"""アノテーションの本体のデータを編集できるかどうか。 trueの場合編集可能。 2022/09現在、この値を利用しているエディタは存在しません。"""
425+
426+
can_edit_additional: Optional[bool]
427+
"""アノテーションの付加情報を編集できるかどうか。 trueの場合編集可能。 2022/09現在、この値を利用しているエディタは存在しません。"""
428+
429+
description: Optional[str]
430+
"""アノテーションについての人間可読な説明。 2022/09現在、この値を利用しているエディタは存在しません。"""
431+
432+
tags: Optional[List[str]]
433+
"""アノテーションに付与されている機械可読・人間可読なタグの列。 2022/09現在、この値を利用しているエディタは存在しません"""
434+
435+
etc: Optional[Dict[str, Any]]
436+
"""上記以外の任意のJson構造"""
437+
438+
439+
@dataclass
440+
class AdditionalDataValueFlag(DataClassJsonMixin):
441+
""" """
442+
443+
type: str
444+
""""""
445+
446+
value: bool
447+
"""ON/OFF属性の属性値。 ONの時trueとなります"""
448+
449+
450+
@dataclass
451+
class AdditionalDataValueInteger(DataClassJsonMixin):
452+
""" """
453+
454+
type: str
455+
""""""
456+
457+
value: int
458+
"""整数属性の属性値"""
459+
460+
461+
@dataclass
462+
class AdditionalDataValueComment(DataClassJsonMixin):
463+
""" """
464+
465+
type: str
466+
""""""
467+
468+
value: str
469+
"""自由記述(1行)の属性値"""
470+
471+
472+
@dataclass
473+
class AdditionalDataValueText(DataClassJsonMixin):
474+
""" """
475+
476+
type: str
477+
""""""
478+
479+
value: str
480+
"""自由記述(複数行)の属性値"""
481+
482+
483+
@dataclass
484+
class AdditionalDataValueChoice(DataClassJsonMixin):
485+
""" """
486+
487+
type: str
488+
""""""
489+
490+
choice_id: str
491+
"""選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
492+
493+
494+
@dataclass
495+
class AdditionalDataValueSelect(DataClassJsonMixin):
496+
""" """
497+
498+
type: str
499+
""""""
500+
501+
choice_id: str
502+
"""選択肢ID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
503+
504+
505+
@dataclass
506+
class AdditionalDataValueTracking(DataClassJsonMixin):
507+
""" """
508+
509+
type: str
510+
""""""
511+
512+
value: str
513+
"""トラッキングID属性の属性値"""
514+
515+
516+
@dataclass
517+
class AdditionalDataValueLink(DataClassJsonMixin):
518+
""" """
519+
520+
type: str
521+
""""""
522+
523+
annotation_id: str
524+
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """
525+
526+
527+
@dataclass
528+
class AnnotationDetailContentInputInner(DataClassJsonMixin):
529+
"""
530+
アノテーションのデータ部をJSON内部に保持します
531+
"""
532+
533+
type: str
534+
""""""
535+
536+
data: FullAnnotationData
537+
""""""
538+
539+
540+
@dataclass
541+
class AnnotationDetailContentInputOuter(DataClassJsonMixin):
542+
"""
543+
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します
544+
"""
545+
546+
type: str
547+
""""""
548+
549+
path: str
550+
"""外部ファイルの位置を示す文字列。 [createTempPath](#operation/createTempPath) APIによって取得したpathを指定します。"""
551+
552+
553+
@dataclass
554+
class AnnotationDetailV2Create(DataClassJsonMixin):
555+
"""
556+
新規にアノテーションを作成する場合にこの型を利用します。
557+
"""
558+
559+
type: str
560+
""""""
561+
562+
annotation_id: str
563+
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """
564+
565+
label_id: str
566+
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
567+
568+
body: AnnotationDetailContentInput
569+
""""""
570+
571+
additional_data_list: List[AdditionalDataV2]
572+
""""""
573+
574+
editor_props: AnnotationPropsForEditor
575+
""""""
576+
577+
578+
@dataclass
579+
class AnnotationDetailV2Import(DataClassJsonMixin):
580+
"""
581+
過去にAnnofab内外で作成したアノテーションをそのままインポートする場合にこの型を利用します。
582+
"""
583+
584+
type: str
585+
""""""
586+
587+
annotation_id: str
588+
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """
589+
590+
account_id: str
591+
"""アカウントID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
592+
593+
label_id: str
594+
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
595+
596+
body: AnnotationDetailContentInput
597+
""""""
598+
599+
additional_data_list: List[AdditionalDataV2]
600+
""""""
601+
602+
editor_props: AnnotationPropsForEditor
603+
""""""
604+
605+
created_datetime: str
606+
"""作成日時"""
607+
608+
updated_datetime: str
609+
"""更新日時"""
610+
611+
612+
@dataclass
613+
class AnnotationDetailV2Update(DataClassJsonMixin):
614+
"""
615+
既に存在するアノテーションを更新する場合にこの型を利用します
616+
"""
617+
618+
type: str
619+
""""""
620+
621+
annotation_id: str
622+
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """
623+
624+
label_id: str
625+
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
626+
627+
body: Optional[AnnotationDetailContentInput]
628+
""""""
629+
630+
additional_data_list: List[AdditionalDataV2]
631+
""""""
632+
633+
editor_props: AnnotationPropsForEditor
634+
""""""
635+
636+
637+
@dataclass
638+
class AnnotationV2Input(DataClassJsonMixin):
639+
""" """
640+
641+
project_id: str
642+
"""プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
643+
644+
task_id: str
645+
"""タスクID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
646+
647+
input_data_id: str
648+
"""入力データID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
649+
650+
details: List[AnnotationDetailV2Input]
651+
"""矩形、ポリゴン、全体アノテーションなど個々のアノテーションの配列。"""
652+
653+
updated_datetime: Optional[str]
654+
"""対象タスク・対象入力データへの最初の保存時は未指定にしてください。 更新の場合はアノテーション取得時のupdated_datetimeをそのまま指定してください。 """
655+
656+
format_version: str
657+
""""""
658+
659+
660+
@dataclass
661+
class AnnotationDetailContentOutputInner(DataClassJsonMixin):
662+
"""
663+
アノテーションのデータ部をJSON内部に保持します
664+
"""
665+
666+
type: str
667+
""""""
668+
669+
data: FullAnnotationData
670+
""""""
671+
672+
673+
@dataclass
674+
class AnnotationDetailContentOutputInnerUnknown(DataClassJsonMixin):
675+
"""
676+
アノテーションのデータ部をJSON内部に保持します。 AnnotationDetailV1の形式で保存されていたデータのAnnotationTypeが特定できない場合にこの値となります。 典型的な例では、アノテーションの保存後にアノテーション仕様が書き換わっていた場合が該当します。
677+
"""
678+
679+
type: str
680+
""""""
681+
682+
data: str
683+
"""アノテーション座標値や区間などの文字列表現です。 アノテーション種類(`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> """
684+
685+
686+
@dataclass
687+
class AnnotationDetailContentOutputOuter(DataClassJsonMixin):
688+
"""
689+
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します
690+
"""
691+
692+
type: str
693+
""""""
694+
695+
url: str
696+
"""外部ファイルに保存されたアノテーションの認証済み一時URL"""
697+
698+
etag: str
699+
"""外部ファイルに保存されたアノテーションのETag"""
700+
701+
702+
@dataclass
703+
class AnnotationDetailContentOutputOuterUnresolved(DataClassJsonMixin):
704+
"""
705+
アノテーションのデータ部を外部ファイルの形式(画像など)で保持します。 Outerのurl / etagを解決しなかった場合(過去のアノテーションを取得した場合等)にこの値となります。
706+
"""
707+
708+
type: str
709+
""""""
710+
711+
712+
@dataclass
713+
class AnnotationDetailV2Get(DataClassJsonMixin):
714+
""" """
715+
716+
type: str
717+
""""""
718+
719+
annotation_id: str
720+
"""アノテーションID。[値の制約についてはこちら。](#section/API-Convention/APIID) `annotation_type`が`classification`の場合は label_id と同じ値が格納されます。 """
721+
722+
account_id: str
723+
"""アカウントID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
724+
725+
label_id: str
726+
"""ラベルID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
727+
728+
body: AnnotationDetailContentOutput
729+
""""""
730+
731+
additional_data_list: List[AdditionalDataV2]
732+
""""""
733+
734+
editor_props: AnnotationPropsForEditor
735+
""""""
736+
737+
created_datetime: str
738+
"""作成日時"""
739+
740+
updated_datetime: str
741+
"""更新日時"""
742+
743+
744+
@dataclass
745+
class AnnotationV2Output(DataClassJsonMixin):
746+
""" """
747+
748+
project_id: str
749+
"""プロジェクトID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
750+
751+
task_id: str
752+
"""タスクID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
753+
754+
input_data_id: str
755+
"""入力データID。[値の制約についてはこちら。](#section/API-Convention/APIID) """
756+
757+
details: List[AnnotationDetailV2Output]
758+
"""矩形、ポリゴン、全体アノテーションなど個々のアノテーションの配列。"""
759+
760+
updated_datetime: Optional[str]
761+
"""対象タスク・対象入力データへ一度もアノテーションの保存が行われていない場合、未指定となります。 そうで無い場合、対象タスク・対象入力データのアノテーション最終更新時刻です。 """
762+
763+
format_version: str
764+
""""""

0 commit comments

Comments
 (0)