ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
20 stars 33 forks source link

Add download_files and import functions to gateway #284

Open will-moore opened 3 years ago

will-moore commented 3 years ago

See https://github.com/ome/omero-documentation/issues/2179#issuecomment-810225179 For example, download files:

For import of files to OMERO, needs some decisions on what to do with https://gitlab.com/openmicroscopy/incubator/omero-python-importer/-/blob/master/import.py I have referred quite a few users to this recently (don't know how much it's been used, but haven't heard about any problems), so it probably needs to be more accessible.

cc @joshmoore

joshmoore commented 3 years ago

In general, having this be user-friendly is a big win. Some things to think about though:

will-moore commented 3 years ago

Are you thinking like:

from omero.gateway import download

download(conn, "Image", [image_id], "download_loc_local_dir")

This has some overlap with omero-downloader, but allows you to combine it with other python code. It's relatively small amount of code, equivalent to this (from https://gist.github.com/will-moore/dab2148ef566125b60625f7773aa1b64):

        for used_file in fileset.listFiles():
            rel_path = getTargetPath(used_file, templatePrefix)
            file_path = os.path.join(tmpdirname, rel_path)
            dir_name = os.path.dirname(file_path)
            if not os.path.exists(dir_name):
                os.makedirs(dir_name)
            print('downloading file to', file_path)
            with open(str(file_path), "wb") as f:
                for chunk in used_file.getFileInChunks():
                    f.write(chunk)

I don't think it has anything to do with Zarr. These files are just the original imported files, so they are already a PFF, but not a new one.

joshmoore commented 3 years ago

These files are just the original imported files, so they are already a PFF, but not a new one.

:+1:

This has some overlap with omero-downloader, but ... It's relatively small amount of code, equivalent to this

:+1: Just want to be clear on the scope, since we have N of these efforts at the moment.

from omero.gateway import download

Possibly. We just generally need to start working to reduce the size of omero/gateway/__init__.py (importing things into the omero.gateway namespace is probably still fine in the interim)