Skip to content

TypeError when using upload_workflow: unsupported operand type(s) for /: 'str' and 'int' #37

Description

@garybrowne

Hello,

I'm passing a list of Paths to the "files" argument to the api.upload_workflow method. However, I think that the file_info object generated internally sets the file_info["size"] value as a str, not an int.

Error trace:

ERROR:xxx.clients.filesender_client:Upload failed: unsupported operand type(s) for /: 'str' and 'int'

Traceback (most recent call last):
  File "/xxx/clients/filesender_client.py", line 78, in upload_file
    transfer = await self.client.upload_workflow(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/xxx/.venv/lib/python3.12/site-packages/filesender/api.py", line 486, in upload_workflow
    await stream.starmap(_upload_args(), self.upload_complete, ordered=False, task_limit=self.concurrent_files) # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
  File "/xxx/.venv/lib/python3.12/site-packages/filesender/api.py", line 325, in upload_file
    async for _ in tqdm(streamer, total=math.ceil(file_info["size"] / self.chunk_size), desc=file_info["name"]): # type: ignore
                                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'str' and 'int'
ERROR:__main__:Upload failed: unsupported operand type(s) for /: 'str' and 'int'
Traceback (most recent call last):
  File "/xxx/test_xnat_to_filesender.py", line 194, in upload_local_to_filesender
    transfer_id = await filesender_client.upload_file(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/clients/filesender_client.py", line 78, in upload_file
    transfer = await self.client.upload_workflow(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/xxx/.venv/lib/python3.12/site-packages/filesender/api.py", line 486, in upload_workflow
    await stream.starmap(_upload_args(), self.upload_complete, ordered=False, task_limit=self.concurrent_files) # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
  File "/xxx/.venv/lib/python3.12/site-packages/filesender/api.py", line 325, in upload_file
    async for _ in tqdm(streamer, total=math.ceil(file_info["size"] / self.chunk_size), desc=file_info["name"]): # type: ignore
                                                  ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for /: 'str' and 'int'
ERROR:__main__:FAILED uploading local files: unsupported operand type(s) for /: 'str' and 'int'

Would you have any time to investigate this, or would you be open to a PR to rectify (if it is indeed a bug)?

Thanks very much

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions