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

Fix error in yokogawa-to-zarr (due to Pillow v10.1.0) #570

Closed
tcompa opened this issue Oct 16, 2023 · 3 comments · Fixed by #571
Closed

Fix error in yokogawa-to-zarr (due to Pillow v10.1.0) #570

tcompa opened this issue Oct 16, 2023 · 3 comments · Fixed by #571
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@tcompa
Copy link
Collaborator

tcompa commented Oct 16, 2023

Running fractal-demos example 01 via a fresh version of fractal-containers leads to a failed job, with the traceback below.
The obvious candidate explanation is https://pillow.readthedocs.io/en/stable/releasenotes/10.1.0.html#setting-image-mode:

If you attempt to set the mode of an image directly, e.g. im.mode = "RGBA", you will now receive an AttributeError. This is not about removing existing functionality, but instead about raising an explicit error to prevent later consequences. The convert method is the correct way to change an image’s mode.


TASK ERROR:Task id: 2 (Convert Yokogawa to OME-Zarr), e.workflow_task_order=1
TRACEBACK:
2023-10-16 08:56:03,815; INFO; START yokogawa_to_ome_zarr task
2023-10-16 08:56:03,825; INFO; NGFF image has num_levels=5
2023-10-16 08:56:03,825; INFO; NGFF image has coarsening_xy=2
2023-10-16 08:56:03,825; INFO; NGFF image has full-res pixel sizes [1.0, 0.1625, 0.1625]
2023-10-16 08:56:03,833; INFO; [glob_with_multiple_patterns] patterns=['*_B03_*.png']
2023-10-16 08:56:03,833; INFO; [glob_with_multiple_patterns] Found 4 items
Traceback (most recent call last):
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/fractal_tasks_core/tasks/yokogawa_to_ome_zarr.py", line 271, in <module>
    run_fractal_task(
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/fractal_tasks_core/tasks/_utils.py", line 79, in run_fractal_task
    metadata_update = task_function(**pars)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
    from contextlib import _GeneratorContextManager
  File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
    
  File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
    
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/fractal_tasks_core/tasks/yokogawa_to_ome_zarr.py", line 184, in yokogawa_to_ome_zarr
    sample = imread(tmp_images.pop())
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/dask/array/image.py", line 56, in imread
    sample = imread(filenames[0])
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/skimage/io/_io.py", line 53, in imread
    img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/skimage/io/manage_plugins.py", line 205, in call_plugin
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/skimage/io/_plugins/imageio_plugin.py", line 11, in imread
    out = np.asarray(imageio_imread(*args, **kwargs))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/imageio/v3.py", line 54, in imread
    return np.asarray(img_file.read(**call_kwargs))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/imageio/plugins/pillow.py", line 231, in read
    image = self._apply_transforms(
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fractal_share/tasks/.fractal/fractal_tasks_core0.12.2/venv/lib/python3.11/site-packages/imageio/plugins/pillow.py", line 312, in _apply_transforms
    image.mode = desired_mode
    ^^^^^^^^^^
AttributeError: property 'mode' of 'PngImageFile' object has no setter
@tcompa tcompa added bug Something isn't working dependencies Pull requests that update a dependency file labels Oct 16, 2023
@tcompa
Copy link
Collaborator Author

tcompa commented Oct 16, 2023

Current versions in fractal-tasks-core:
Required in pyproject.toml: >=9.1.1,<11.0.0
Used for tests: 10.0.1

@tcompa
Copy link
Collaborator Author

tcompa commented Oct 16, 2023

I checked in https://github.com/fractal-analytics-platform/fractal-tasks-core/actions/runs/6531523635/job/17732909815?pr=571, and the latest Pillow version (10.1) is indeed responsible for this issue.

I opened an issue at imageio: imageio/imageio#1044. Depending on how it works over there, we may want to temporarily constrain the Pillow version to <10.1.

I suspect a similar issue may appear in scikit-image (see https://github.com/search?q=repo%3Ascikit-image%2Fscikit-image+%22.mode+%3D%22&type=code), but I'm not able to say whether we rely on these features.

@tcompa
Copy link
Collaborator Author

tcompa commented Oct 16, 2023

I checked (through a fractal-containers run of examples 01 and 02 from fractal-demos, using the 570-fix-error-in-yokogawa-to-zarr-due-to-pillow-version fractal-tasks-core branch) that restricting the Pillow version to be <10.1 does fix the issue.

I'm merging #571 for now, and will open a new issue as a reminder for relaxing this constraint as soon as there are relevant updates in imageio or pillow.

tcompa added a commit that referenced this issue Oct 16, 2023
…-in-yokogawa-to-zarr-due-to-pillow-version

Test pillow 10.1 (ref #570)
@tcompa tcompa changed the title Fix error in yokogawa-to-zarr (due to Pillow version?) Fix error in yokogawa-to-zarr (due to Pillow v10.1.0) Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant