Skip to content
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

タスクを作成する場合は、--task_id_prefixを必須にしました。 #99

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions anno3d/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ def validate_aws_credentail() -> bool:
return result


def validate_task_id_prefix(task_id_prefix: str, upload_kind: UploadKind) -> bool:
if upload_kind in [UploadKind.CREATE_TASK, UploadKind.CREATE_ANNOTATION]:
if task_id_prefix == "":
print(
"'--upload_kind'の値が`task`または'annotation'の場合は、'--task_id_prefix'を指定してください。", file=sys.stderr,
)
return False
return True


class Sandbox:
""" sandboxの再現 """

Expand Down Expand Up @@ -667,6 +677,10 @@ def upload_scene(
if not validate_annofab_credential(annofab_id, annofab_pass):
return

enum_upload_kind = _decode_enum(UploadKind, upload_kind)
if not validate_task_id_prefix(task_id_prefix, enum_upload_kind):
return

assert annofab_id is not None and annofab_pass is not None
client_loader = ClientLoader(annofab_id, annofab_pass, annofab_endpoint)
with client_loader.open_api() as api:
Expand All @@ -680,7 +694,7 @@ def upload_scene(
camera_horizontal_fov=_decode_enum(CameraHorizontalFovKind, camera_horizontal_fov),
sensor_height=sensor_height,
task_id_prefix=task_id_prefix,
kind=_decode_enum(UploadKind, upload_kind),
kind=enum_upload_kind,
)
scene_uploader.upload_from_path(Path(scene_path), uploader_input)

Expand Down Expand Up @@ -732,6 +746,11 @@ def upload_scene_to_s3(
assert annofab_id is not None and annofab_pass is not None
if not validate_aws_credentail():
return

enum_upload_kind = _decode_enum(UploadKind, upload_kind)
if not validate_task_id_prefix(task_id_prefix, enum_upload_kind):
return

client_loader = ClientLoader(annofab_id, annofab_pass, annofab_endpoint)
with client_loader.open_api() as api:
uploader = SceneUploader(
Expand All @@ -744,7 +763,7 @@ def upload_scene_to_s3(
camera_horizontal_fov=_decode_enum(CameraHorizontalFovKind, camera_horizontal_fov),
sensor_height=sensor_height,
task_id_prefix=task_id_prefix,
kind=_decode_enum(UploadKind, upload_kind),
kind=enum_upload_kind,
)
uploader.upload_from_path(Path(scene_path), uploader_input)

Expand Down