ome / omero-cli-zarr

https://pypi.org/project/omero-cli-zarr/
GNU General Public License v2.0
15 stars 10 forks source link

Add --bfpath option #112

Closed joshmoore closed 2 years ago

joshmoore commented 2 years ago

Currently, --bf requires access to the managed repository. If, however, a copy of the necessary files are already available locally, it would be necessary to first determine where they live on the server, and place the files in exactly that location.

The --bfpath option takes the absolute or relative path to the files and uses that rather than inspect the OMERO repository.

joshmoore commented 2 years ago

whether --bf should remain the single top-level option allowing to choose the underlying writer library and this moved as a secondary conditional option.

I'm not sure what you mean.

sbesson commented 2 years ago

I'm not sure what you mean.

omero zarr export Image:1 --bf # Use bioformats2raw and assume the OMERO ManagedRepository or the original files (if in-place imported) are accessible
omero zarr export Image:1 --bfpath /path/to/original/file # Use bioformats2raw and specify the path to the original file

I think there is something about the symmetry that I find slighlty odd. Possibly, it comes from the fact that before reading the code, I had assumed the new logic would be invoked by passing an argument in addition to the boolean flag toggling bioformats2raw i.e.

omero zarr export Image:1 --bf --bfpath /path/to/originalfile

Writing the above, I can certainly see it looks verbose and repetitive. Therefore I don't feel that strongly about it and happy to go with your proposal. Maybe two ideas to clarify the expectations:

joshmoore commented 2 years ago
  • should the two options be marked as mutually exclusive?

That would definitely be an improvement, but can also investigate if two flags should be needed. What can't be done (I think, without being breaking) is to have --bf and --bf=path.

joshmoore commented 2 years ago

Perhaps --bf-server-side would be a better name for --bf...

joshmoore commented 2 years ago

Updated help:

omero zarr export -h
usage: /usr/local/anaconda3/envs/omero/bin/omero zarr export
       [-h] [--bf] [--bfpath BFPATH] [--tile_width TILE_WIDTH]
       [--tile_height TILE_HEIGHT] [--resolutions RESOLUTIONS]
       [--max_workers MAX_WORKERS] [--output OUTPUT]
       object

Export an image in zarr format.

Using bioformats2raw
--------------------

Rather than download pixels from OMERO using the API, two options allow
converting files directly using bioformats2raw:

  --bf

     Server-side option which queries the server for the location
     of the file within the managed repository (e.g. /OMERO/ManagedRepository)
     and then calls bioformats2raw directly on that file.

  --bfpath=local/file/path

     If a copy of the fileset is available locally, then this option
     calls bioformats2raw directly on the argument. No checks are performed
     that the fileset is the correct one.

bioformats2raw executable
-------------------------

In order to use bioformats2raw for the actual export,
make sure the bioformats2raw binary is in the $PATH.

bioformats2raw options
----------------------

  --max_workers

     Maximum number of workers to use for parallel generation of pyramids

  --tile_width / --tile_height

     Maximum tile width or height to read (only for use with bioformats2raw)

  --resolutions

     Number of pyramid resolutions to generate

Positional Arguments:
  object                     The Image to export.

Optional Arguments:
  In addition to any higher level options

  -h, --help                 show this help message and exit
  --bf                       Use bioformats2raw on the server to export images. Requires bioformats2raw 0.3.0 or higher and access to the managed repo.
  --bfpath BFPATH            Use bioformats2raw on a local copy of a file. Requires bioformats2raw 0.4.0 or higher.
  --tile_width TILE_WIDTH    Maximum tile width to read (only for use with bioformats2raw)
  --tile_height TILE_HEIGHT  Maximum tile height to read (only for use with bioformats2raw)
  --resolutions RESOLUTIONS  Number of pyramid resolutions to generate (only for use with bioformats2raw)
  --max_workers MAX_WORKERS  Maximum number of workers (only for use with bioformats2raw)
  --output OUTPUT            The output directory