diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c8e92c6..9a96f36d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/e2e_tests/standard/test_files.py b/e2e_tests/standard/test_files.py index 959c7638d..2aa276348 100644 --- a/e2e_tests/standard/test_files.py +++ b/e2e_tests/standard/test_files.py @@ -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(): @@ -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() diff --git a/neptune/new/attributes/atoms/file.py b/neptune/new/attributes/atoms/file.py index beb110846..ad3d3809b 100644 --- a/neptune/new/attributes/atoms/file.py +++ b/neptune/new/attributes/atoms/file.py @@ -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 diff --git a/neptune/new/handler.py b/neptune/new/handler.py index a5eb55141..7ae8e42fe 100644 --- a/neptune/new/handler.py +++ b/neptune/new/handler.py @@ -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.