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

Add download_files and import functions to gateway #284

Open
will-moore opened this issue Mar 31, 2021 · 3 comments
Open

Add download_files and import functions to gateway #284

will-moore opened this issue Mar 31, 2021 · 3 comments

Comments

@will-moore
Copy link
Member

See ome/omero-documentation#2179 (comment)
For example, download files:

  • conn.download("Image", [image_id], "download_loc_local_dir")
  • conn.download("Dataset", [dataset_id], "download_loc_local_dir")
  • conn.download("Fileset", [fileset_id], "download_loc_local_dir")

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
Copy link
Member

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

  • Could this be an extension? (i.e. must it be a conn method?)
  • What's the relationship to omero-downloader? to Zarr?
  • Will the downloaded files become their own PFF?

@will-moore
Copy link
Member Author

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
Copy link
Member

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

👍

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

👍 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)

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

No branches or pull requests

2 participants