-
Notifications
You must be signed in to change notification settings - Fork 2
feat: multipart upload #42
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
base: main
Are you sure you want to change the base?
Conversation
source/ftrack_api/uploader.py
Outdated
for i in range(retries): | ||
try: | ||
return await func(*args) | ||
except Exception as e: |
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.
perhaps a bit broad? Maybe limit it to httpx.TimeoutException
and httpx.HTTPStatusError
in combination with exception.response.is_server_error()
if self.parts_count > MAX_PARTS: | ||
raise ValueError("File is too big.") | ||
|
||
self.upload_id: Optional[str] = None |
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.
these are only used within start
perhaps they do not need to be instance variables?
@@ -81,7 +81,7 @@ def flush(self): | |||
|
|||
def seek(self, offset, whence=os.SEEK_SET): | |||
"""Move internal pointer by *offset*.""" | |||
self.wrapped_file.seek(offset, whence) | |||
return self.wrapped_file.seek(offset, whence) |
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.
consider updating parent class doc string to indicate that position is returned.
source/ftrack_api/uploader.py
Outdated
raise ValueError("Invalid file size.") | ||
|
||
|
||
async def back_off(func: Callable[..., Awaitable], *args, retries=5, delay=5): |
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.
maybe include typing where possible ie
async def back_off(func: Callable[..., Awaitable], *args:typing.Any, retries:int=5, delay:int=5):
|
||
startPos = (part_num - 1) * self.chunk_size | ||
self.file.seek(startPos) | ||
content = self.file.read(self.chunk_size) |
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.
we are reusing the same file object across all tasks, I suppose that is fine since we are reading / seeking synchronously?
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.
yeah, we are reading synchronously and are reading the content before dropping it to the upload task.
Resolves FT-2fc3d98e-2756-45f4-b39f-3ddbef956a2f
Changes
Using httpx as async HTTP library for upload request.
Test