From a0978b9bc16f8b97d7dec5bc60e5e03f9128f9a8 Mon Sep 17 00:00:00 2001 From: Nils Date: Tue, 3 Dec 2024 12:19:23 +0100 Subject: [PATCH] fix: `read_image` and `write_image` now use `LocalFileSystem` as default (#140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📥 Pull Request Description Currently you cannot use `read_image` and `write_image` without specifying a FileSystem. The default (`LocalFileSystem`) was not used correctly. This is now fixed in this PR. ## 👀 Affected Areas - ioutils ## 📝 Checklist Please make sure you've completed the following tasks before submitting this pull request: - [X] Pre-commit hooks were executed - [ ] Changes have been reviewed by at least one other developer - [ ] Tests have been added or updated to cover the changes (only necessary if the changes affect the executable code) - [X] All tests ran successfully - [X] All merge conflicts are resolved - [X] Documentation has been updated to reflect the changes - [X] Any necessary migrations have been run --- niceml/utilities/ioutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/niceml/utilities/ioutils.py b/niceml/utilities/ioutils.py index 32a7c23..d9c09ba 100644 --- a/niceml/utilities/ioutils.py +++ b/niceml/utilities/ioutils.py @@ -289,7 +289,7 @@ def write_image( dirname(filepath), exist_ok=True, ) - with file_system.open(filepath, "wb") as file: + with cur_fs.open(filepath, "wb") as file: file_format = filepath.rsplit(".")[-1] image.save(file, format=file_format, **kwargs) @@ -311,7 +311,7 @@ def read_image( cur_fs: AbstractFileSystem = file_system or LocalFileSystem() if not cur_fs.exists(filepath): raise FileNotFoundError(f"ImageFile not found: {filepath}") - with file_system.open(filepath, "rb") as file: + with cur_fs.open(filepath, "rb") as file: return Image.open(file, **kwargs).copy()