-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
タスク作成処理をinitiateTasksGenerationAPI
からputTask
APIを使うように変更しました。
#98
Conversation
def create_tasks_by_csv(self, csv_path: Path) -> TaskGenerateResponse: | ||
client = self._client | ||
project_id = self._project_id | ||
uploader = AnnofabStorageUploader(client, project_id) | ||
project = self._project.get_project(project_id) | ||
if project is None: | ||
raise RuntimeError("指定されたプロジェクト(={})が見つかりませんでした。".format(project_id)) | ||
|
||
uploaded_path = uploader.upload_tempdata(csv_path) | ||
|
||
body_params = { | ||
"task_generate_rule": {"csv_data_path": uploaded_path, "_type": "ByInputDataCsv"}, | ||
"project_last_updated_datetime": project.updated_datetime, | ||
} | ||
task_generate_result, _ = client.initiate_tasks_generation(project_id, request_body=body_params) | ||
|
||
return TaskGenerateResponse.from_dict(task_generate_result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使わなくなったので削除
def put_task(self, task_id: str, input_data_ids: List[str]) -> Task: | ||
client = self._client | ||
project_id = self._project_id | ||
result, _ = client.put_task(project_id, task_id, request_body={"input_data_id_list": input_data_ids}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既にタスクが存在していたら、HTTPErrorが発生する。
タスクを上書きするとアノテーションが消える可能性があり、入力データや補助情報データの上書きよりも、慎重に行う必要があるため、--force
が指定されても、タスクは上書きしないようにした。
anno3d/kitti/scene_uploader.py
Outdated
|
||
logger.info("タスクの作成が完了しました") | ||
logger.info("タスクの作成を開始します") | ||
await asyncio.gather(self._create_tasks_async(uploader_input.project_id, task_to_data_dict)) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解決済
initiateTasksGenerationAPI
からputTask
API
initiateTasksGenerationAPI
からputTask
APIinitiateTasksGenerationAPI
からputTask
APIを使うように変更しました。
@@ -57,6 +37,12 @@ def get_task(self, task_id: str) -> Optional[Task]: | |||
|
|||
return self._decode_task(result) | |||
|
|||
def put_task(self, task_id: str, input_data_ids: Collection[str]) -> Task: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
input_daata_ids
の型がList
でなくCollectionにした理由は、mypyに怒られないようにするため。
poetry run mypy anno3d tests sandbox.py
anno3d/kitti/scene_uploader.py:152: error: Argument 2 to "put_task" of "TaskApi" has incompatible type "List[DataId]"; expected "List[str]"
anno3d/kitti/scene_uploader.py:152: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
anno3d/kitti/scene_uploader.py:152: note: Consider using "Sequence" instead, which is covariant
a8b99be
to
e0c1133
Compare
`putTask`APIの方が処理時間が短く、エラー内容が分かりやすいため。
e0c1133
to
420939a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
動作確認した
loop = asyncio.get_event_loop() | ||
project = self._project | ||
task = TaskApi(self._client, project, project_id) | ||
def _create_tasks(self, project_id: str, task_to_data_dict: Dict[TaskId, List[Tuple[DataId, FilePaths]]]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
返り値の型を明示してほしいです
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#102 で対応しました。
タスク作成の処理を
initiateTasksGeneration
APIからputTask
APIを使うように変更しました。理由は以下の通りです。
initiateTasksGeneration
APIでは、タスク作成に失敗した際のエラーが分かりづらい