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

java.lang.ClassCastException on ZARR import #94

Open
jo-mueller opened this issue Aug 2, 2024 · 8 comments · May be fixed by #95
Open

java.lang.ClassCastException on ZARR import #94

jo-mueller opened this issue Aug 2, 2024 · 8 comments · May be fixed by #95

Comments

@jo-mueller
Copy link

Hi all,

following up an issue I created over at ezomero, I am having some trouble uploading zarr to our omero server.

I created a test zarr file for trial with this Python code:

from bioio.writers.ome_zarr_writer import OmeZarrWriter

writer = OmeZarrWriter('test.zarr')
writer.write_image(
    np.random.rand(1, 1, 64, 128, 128).astype(np.float32),
    chunk_dims=(1, 1, 64, 128, 128),
    scale_num_levels=1,
    dimension_order='TCZYX',
    image_name='test',
    channel_names=['test'],
    channel_colors=None,
    physical_pixel_sizes = None,
)

and tried the upload through both ezomero as well as the CLI using

omero import --name "Test" --depth 10 ./test.zarr/

You can create the zarr yourself, otherwise, you can also download the test file here.

Full traceback:

$ omero import --name "Test" --depth 10 ./test.zarr/
Using OMERO.java-5.6.12-ice36
Using session for johamuel@omero-int.biotec.tu-dresden.de:4064. Idle timeout: 10 min. Current group: default
2024-08-02 16:00:09,071 150        [      main] INFO          ome.formats.importer.ImportConfig - OMERO.blitz Version: 5.7.4
2024-08-02 16:00:09,081 160        [      main] INFO          ome.formats.importer.ImportConfig - Bioformats version: 7.3.1 revision: 41e12f630ad7349caa0293cba23948c17d22732b date: 11 July 2024
2024-08-02 16:00:09,111 190        [      main] INFO   formats.importer.cli.CommandLineImporter - Log levels -- Bio-Formats: ERROR OMERO.importer: INFO
2024-08-02 16:00:09,291 370        [      main] INFO      ome.formats.importer.ImportCandidates - Depth: 10 Metadata Level: MINIMUM
2024-08-02 16:00:09,406 485        [      main] ERROR     ome.formats.importer.cli.ErrorHandler - FILE_EXCEPTION: /home/pol_haase/johamuel/Documents/Git/single-cell-analysis-of-organoids/notebooks/00_data_management/./test.zarr/0/0/0/0/0/0
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.Double (java.lang.Integer and java.lang.Double are in module java.base of loader 'bootstrap')
	at loci.formats.in.ZarrReader.parseOmeroMetadata(ZarrReader.java:704)
	at loci.formats.in.ZarrReader.initFile(ZarrReader.java:170)
	at loci.formats.FormatReader.setId(FormatReader.java:1480)
	at loci.formats.ImageReader.setId(ImageReader.java:864)
	at ome.formats.importer.OMEROWrapper$4.setId(OMEROWrapper.java:167)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
	at loci.formats.ChannelFiller.setId(ChannelFiller.java:258)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
	at loci.formats.ChannelSeparator.setId(ChannelSeparator.java:317)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
	at loci.formats.Memoizer.setId(Memoizer.java:698)
	at loci.formats.ReaderWrapper.setId(ReaderWrapper.java:692)
	at ome.formats.importer.ImportCandidates.singleFile(ImportCandidates.java:427)
	at ome.formats.importer.ImportCandidates.handleFile(ImportCandidates.java:576)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:367)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:364)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:364)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:364)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:364)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:364)
	at org.apache.commons.io.DirectoryWalker.walk(DirectoryWalker.java:335)
	at ome.formats.importer.ImportCandidates.execute(ImportCandidates.java:381)
	at ome.formats.importer.ImportCandidates.<init>(ImportCandidates.java:222)
	at ome.formats.importer.ImportCandidates.<init>(ImportCandidates.java:174)
	at ome.formats.importer.cli.CommandLineImporter.<init>(CommandLineImporter.java:148)
	at ome.formats.importer.cli.CommandLineImporter.main(CommandLineImporter.java:1021)
2024-08-02 16:00:09,408 487        [      main] INFO      ome.formats.importer.ImportCandidates - 4 file(s) parsed into 0 group(s) with 1 call(s) to setId in 115ms. (118ms total) [0 unknowns]
2024-08-02 16:00:09,434 513        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Attempting initial SSL connection to omero-int.biotec.tu-dresden.de:4064
2024-08-02 16:00:09,644 723        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Insecure connection requested, falling back
2024-08-02 16:00:09,806 885        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Pinging session every 300s.
2024-08-02 16:00:09,813 892        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Server: 5.6.3
2024-08-02 16:00:09,814 893        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Client: 5.7.4
2024-08-02 16:00:09,814 893        [      main] INFO       ome.formats.OMEROMetadataStoreClient - Java Version: 11.0.24
2024-08-02 16:00:09,814 893        [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Name: Linux
2024-08-02 16:00:09,814 893        [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Arch: amd64
2024-08-02 16:00:09,814 893        [      main] INFO       ome.formats.OMEROMetadataStoreClient - OS Version: 5.15.0-25-generic
No imports due to errors!

Any help is much appreciated and thanks already in advance :)

@jo-mueller
Copy link
Author

I think I have a fix on my fork - I'd need somehelp with testing though - how exactly would I be able to test my changes in the underlying Java code in my Python workflow? 🤔

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/ome-zarr-import-to-omero-failure-response-on-import/82067/7

@dgault
Copy link
Member

dgault commented Aug 6, 2024

Thank you for opening the issue and investigating a fix. I believe the version of ZarrReader you are using is 0.3.1 so the initial failure would have been here: https://github.com/ome/ZarrReader/blob/v0.3.1/src/loci/formats/in/ZarrReader.java#L704

This would make sense based on the sample file. From that file the OMERO metadata looks like this:

    "omero": {
        "channels": [
            {
                "active": true,
                "coefficient": 1,
                "color": "000000",
                "family": "linear",
                "inverted": false,
                "label": "test",
                "window": {
                    "end": 1.0,
                    "max": 1.0,
                    "min": 0.0,
                    "start": 0.0
                }
            }
        ],
        "id": 1,
        "name": "test",
        "rdefs": {
            "defaultT": 0,
            "defaultZ": 32,
            "model": "color"
        },
        "version": "0.4"
    }

@jo-mueller, if you want to open a Pull Request against this repository then we can review and test the fix for a future release. If you wanted to test it locally as part of your own workflow then you would have to build the jar file using mvn clean package and then replace your existing OMEZarrReader jar file.

@jo-mueller
Copy link
Author

Hi @dgault ,

thanks for the hint. I am not super-experienced with Java (actually not at all 😅 ) - I successfully built my fork using maven. Where exactly would the current OMEZarrReader.jar be stored for me to replace by my own build? I did not find it in the site-packages directory. That said, I am not even exactly sure which package exactly would invoke the build jar - is that omero-py?

@dgault
Copy link
Member

dgault commented Aug 9, 2024

Hi @jo-mueller, sorry for the slow response. The OMEZarrReader.jar file should be part of the main OMERO server. In the maoin server location you should see a number of .jar files under lib/server, including formats-api.jar, formats-bsd.jar, formats-gpl.jar etc. This will also be were the OMEZarrReader.jar file lives.

@jo-mueller
Copy link
Author

Hi @dgault ,

I tried myself at fixing this but no success, unfortunately - I think I would have to limit myself to an observer on this issue :/ I'll be happy to test any changes on the project though, if need be.

@will-moore
Copy link
Member

will-moore commented Aug 30, 2024

@jo-mueller could you open a PR with your branch?
@dgault is unfortunately leaving the OME team - today is his last day - but we may be able to test your fix.
I am seeing a similar error trying to import a Plate with acquisition starttime Int/Long issue. see #55

@dgault dgault linked a pull request Aug 30, 2024 that will close this issue
@dgault
Copy link
Member

dgault commented Aug 30, 2024

I have opened a PR which contains the 2 commits from that fork for testing: #95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants