Skip to content

Commit

Permalink
annotation restore: SimpleアノテーションJSONに、Optional型のフィールドに対応するキーが存在しなくても…
Browse files Browse the repository at this point in the history
…データクラスのインスタンスを生成できるようにする (#685)

* poetry update

* foormat

* version up

* update documetn
  • Loading branch information
yuji38kwmt authored Jan 24, 2022
1 parent 9558f8f commit d678eb5
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 57 deletions.
2 changes: 1 addition & 1 deletion annofabcli/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.56.2"
__version__ = "1.56.3"
14 changes: 8 additions & 6 deletions annofabcli/annotation/restore_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def _to_annotation_detail_for_request(
return detail

def parser_to_request_body(self, project_id: str, parser: SimpleAnnotationParser) -> Dict[str, Any]:

annotation: Annotation = Annotation.from_dict(parser.load_json())
# infer_missing=Trueを指定する理由:Optional型のキーが存在しない場合でも、Annotationデータクラスのインスタンスを生成できるようにするため
# https://qiita.com/yuji38kwmt/items/c5b56f70da3b8a70ba31
annotation: Annotation = Annotation.from_dict(parser.load_json(), infer_missing=True)
request_details: List[Dict[str, Any]] = []
for detail in annotation.details:
request_detail = self._to_annotation_detail_for_request(project_id, parser, detail)
Expand Down Expand Up @@ -96,9 +97,10 @@ def put_annotation_for_task(self, project_id: str, task_parser: SimpleAnnotation
try:
if self.put_annotation_for_input_data(project_id, parser):
success_count += 1
except Exception as e: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
logger.warning(
f"task_id={parser.task_id}, input_data_id={parser.input_data_id} のアノテーションのリストアに失敗しました。: {e}"
f"task_id={parser.task_id}, input_data_id={parser.input_data_id} のアノテーションのリストアに失敗しました。",
exc_info=True,
)

logger.info(f"タスク'{task_parser.task_id}'の入力データ {success_count} 個に対してアノテーションをリストアしました。")
Expand Down Expand Up @@ -184,8 +186,8 @@ def main(self):
if self.execute_task(project_id, task_parser, force=args.force):
success_count += 1

except Exception as e: # pylint: disable=broad-except
logger.warning(f"task_id={task_parser.task_id} のアノテーションのリストアに失敗しました。: {e}")
except Exception: # pylint: disable=broad-except
logger.warning(f"task_id={task_parser.task_id} のアノテーションのリストアに失敗しました。", exc_info=True)

logger.info(f"{success_count} 個のタスクに対してアノテーションをリストアしました。")

Expand Down
8 changes: 6 additions & 2 deletions docs/user_guide/3dpc-editor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ AnnoFabの拡張機能である"3DPC-EDITOR"用のプロジェクトでも、ann

ただし、以下のコマンドは3DPC-EDITOR用のコマンドライン引数を指定する必要があります。詳細はコマンドのリファレンスを参照してください。

* `inspection_comment put <../inspection_comment/put.html>`_
* `task reject <../task/put.html>`_

.. toctree::
:maxdepth: 1
:titlesonly:

../command_reference/inspection_comment/put
../command_reference/task/put
98 changes: 51 additions & 47 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "annofabcli"
version = "1.56.2"
version = "1.56.3"
description = "Utility Command Line Interface for AnnoFab"
authors = ["yuji38kwmt"]
license = "MIT"
Expand Down

0 comments on commit d678eb5

Please sign in to comment.