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

fetch_extension added to Handler #923

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [UNRELEASED] neptune-client 0.16.4

## Fixes
- fetch_extension added to Handler ([#923](https://github.com/neptune-ai/neptune-client/pull/923))

## Changes
- Rename and copy update for UnsupportedClientVersion and DeprecatedClientLibraryVersion ([#917](https://github.com/neptune-ai/neptune-client/pull/917))

Expand Down
4 changes: 3 additions & 1 deletion e2e_tests/standard/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_using_new_api(self, container: MetadataContainer):
)
def test_single_file(self, container: MetadataContainer, file_size: int):
key = self.gen_key()
filename = fake.file_name()
extension = fake.file_extension()
filename = fake.file_name(extension=extension)
downloaded_filename = fake.file_name()

with tmp_context():
Expand All @@ -62,6 +63,7 @@ def test_single_file(self, container: MetadataContainer, file_size: int):
container.sync()
container[key].download(downloaded_filename)

assert container[key].fetch_extension() == extension
assert os.path.getsize(downloaded_filename) == file_size
with open(downloaded_filename, "rb") as file:
content = file.read()
Expand Down
2 changes: 1 addition & 1 deletion neptune/new/attributes/atoms/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def download(self, destination: Optional[str] = None) -> None:
self._container_id, self._container_type, self._path, destination
)

def fetch_extension(self):
def fetch_extension(self) -> str:
# pylint: disable=protected-access
val = self._backend.get_file_attribute(self._container_id, self._container_type, self._path)
return val.ext
8 changes: 8 additions & 0 deletions neptune/new/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ def fetch_hash(self) -> str:
"""
return self._pass_call_to_attr(function_name="fetch_hash")

def fetch_extension(self) -> str:
"""Fetches the extension of a file.

You may also want to check `fetch_extension docs page`_.
https://docs.neptune.ai/api-reference/field-types#.fetch_extension
"""
return self._pass_call_to_attr(function_name="fetch_extension")

def fetch_files_list(self) -> List[ArtifactFileData]:
"""Fetches the list of files in an artifact and their metadata.

Expand Down