Skip to content

Commit

Permalink
fix: read_image and write_image now use LocalFileSystem as defa…
Browse files Browse the repository at this point in the history
…ult (#140)

## 📥 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
  • Loading branch information
aiakide committed Dec 3, 2024
1 parent 2dd66dc commit a0978b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions niceml/utilities/ioutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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()


Expand Down

0 comments on commit a0978b9

Please sign in to comment.