-
Notifications
You must be signed in to change notification settings - Fork 63
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
new upload procedure #789
new upload procedure #789
Conversation
15f5be2
to
2e55cbd
Compare
cd691df
to
69de0c5
Compare
@@ -15,6 +15,16 @@ | |||
# | |||
|
|||
|
|||
class MultipartConfig: |
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.
It may be a dataclass
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.
It's Legacy Client so I didn't want to introduce dataclasses there. But I'm not sure why 🤣
Done.
|
||
from future.builtins import object | ||
|
||
from neptune.internal.storage.storage_utils import ( | ||
UploadEntry, | ||
AttributeUploadConfiguration, | ||
) | ||
from neptune.new.exceptions import InternalClientError | ||
from neptune.new.internal.backends.api_model import MultipartConfig | ||
|
||
|
||
class FileChunk(object): |
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.
It might be a dataclass as well.
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.
not really my code, but you're right :)
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.
You touched this, it's on you :p
self._max_chunk_size = multipart_config.max_chunk_size | ||
self._max_chunk_count = multipart_config.max_chunk_count | ||
|
||
def _get_chunk_size(self) -> int: |
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.
Can we add info here that our aim is to maximize number of chunks?
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.
Is it, actually? That's just my implementation decision ;)
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.
Ok
if isinstance(chunk, str): | ||
chunk = chunk.encode("utf-8") | ||
new_offset = last_offset + len(chunk) | ||
yield FileChunk(chunk, last_offset, new_offset) |
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.
Make it kwargs
, please.
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.
done
def upload_file_attribute( | ||
swagger_client: SwaggerClient, | ||
container_id: str, | ||
attribute: str, | ||
source: Union[str, bytes], | ||
ext: str, | ||
) -> Optional[NeptuneException]: | ||
multipart_config: Optional[MultipartConfig], | ||
) -> List[NeptuneException]: |
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.
Is there a situation when we send more than one exception?
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.
Or we just want to make it consistent with upload_file_set_attribute
?
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.
exactly that, I wanted consistency
No description provided.