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

--scene_pathなどパスを指定する引数に、001など数値とみなされるディレクトリ名を渡したときにTypeErrorが発生する問題を修正しました。 #158

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

yuji38kwmt
Copy link
Collaborator

@yuji38kwmt yuji38kwmt commented Dec 15, 2024

不具合の内容

--scene_pathにはディレクトリ名を渡すこともできます。999というディレクトリ名があったので、 --scene_path 999を指定したら、TypeErrorが発生しました。
原因は、Path()にintである値を渡したためです。

$  anno3d project upload_scene_to_s3 --project_id ${PROJECT_ID}  --scene_path 999 --s3_path foo --upload_kind data  --force
[2024-12-13 13:10:50,497] [1289583] [botocore.credentials] [INFO] Found credentials in shared credentials file: ~/.aws/credentials
Traceback (most recent call last):
  File "/home/yuji/.pyenv/versions/3.12.4/bin/anno3d", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/site-packages/anno3d/app.py", line 912, in main
    fire.Fire(Command)
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/site-packages/fire/core.py", line 138, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/site-packages/fire/core.py", line 463, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
                                ^^^^^^^^^^^^^^^^^^^^
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/site-packages/anno3d/app.py", line 790, in upload_scene_to_s3
    uploader.upload_from_path(Path(scene_path), uploader_input)
                              ^^^^^^^^^^^^^^^^
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/pathlib.py", line 1162, in __init__
    super().__init__(*args)
  File "/home/yuji/.pyenv/versions/3.12.4/lib/python3.12/pathlib.py", line 373, in __init__
    raise TypeError(
TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'int'

Fireは型ヒントを考慮せずに自動的に適切な型へ変換するため、今回のエラーが発生しました。
#154 と同じ状況です。

修正内容

Path()に渡す以下の引数について、Path()に渡す前にstr()で文字列に変換するようにしました。

  • --scene_path
  • --output_dir
  • --kitti_dir

補足

Fireの自動的な型変換による問題はまだ残っているかもしれません。
問題が発生したときに修正しようと思います。

@yuji38kwmt yuji38kwmt added the bug Something isn't working label Dec 15, 2024
@yuji38kwmt yuji38kwmt changed the title コマンドライン引数から受け取った値からPathオブジェクトを生成する場合は、一度文字列に変換する --scene_pathなどパスを指定する引数に、001など数値とみなされるディレクトリ名を渡したときにTypeErrorが発生する問題を修正しました。 Dec 15, 2024
@yuji38kwmt yuji38kwmt marked this pull request as ready for review December 15, 2024 05:18
@yuji38kwmt yuji38kwmt requested a review from seraphr December 15, 2024 05:22
@seraphr seraphr merged commit 3f1451b into master Dec 24, 2024
2 checks passed
@seraphr seraphr deleted the modify-fire-path branch December 24, 2024 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants