diff --git a/README.rst b/README.rst index 71de343..ceceb4b 100644 --- a/README.rst +++ b/README.rst @@ -21,17 +21,21 @@ To create sql containing required functions and run it: To generate sql and create the symlinks from the ManagedRepository to the NGFF data for a specified Fileset ID: +The clientpath is used as the basis for the clientpath for each file in the Fileset. If omitted then +the clientpath is 'unknown'. When writing .zarr.bfoptions into the ManagedRepository alongside the +symlink to fileset.zarr, the clientpath will be added to bfoptions as `omezarr.alt_store`, allowing +ZarrReader to read directly from that source. :: - $ omero mkngff sql --symlink_repo /OMERO/ManagedRepository --secret=secret --bfoptions 1234 /path/to/fileset.zarr > myNgff.sql + $ omero mkngff sql --symlink_repo /OMERO/ManagedRepository --secret=secret --bfoptions --clientpath=https://url/to/fileset.zarr 1234 /path/to/fileset.zarr > myNgff.sql $ psql -U omero -d idr -h $DBHOST -f myNgff.sql -To ONLY perform the symlink creation (and optionally create fileset.zarr.bfoptions) +To ONLY perform the symlink creation (and optionally create fileset.zarr.bfoptions with clientpath as above) :: - $ omero mkngff symlink /OMERO/ManagedRepository 1234 /path/to/fileset.zarr --bfoptions + $ omero mkngff symlink /OMERO/ManagedRepository 1234 /path/to/fileset.zarr --bfoptions --clientpath=https://url/to/fileset.zarr To ONLY create fileset.zarr.bfoptions diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index 95da239..4df6694 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -197,6 +197,10 @@ def _configure(self, parser: Parser) -> None: "--bfoptions", action="store_true", help="Create data.zarr.bfoptions file" ) symlink.add_argument("--fs_suffix", default="_mkngff", help=FS_SUFFIX_HELP) + symlink.add_argument( + "--clientpath", + help=("Adds omezarr.alt_store=clientpath/path/to/img.zarr to bfoptions"), + ) symlink.set_defaults(func=self.symlink) bfoptions = sub.add_parser( @@ -290,22 +294,27 @@ def sql(self, args: Namespace) -> None: if args.symlink_repo: self.create_symlink(args.symlink_repo, prefix, args.symlink_target) if args.bfoptions: - self.write_bfoptions(args.symlink_repo, prefix, args.symlink_target) + self.write_bfoptions( + args.symlink_repo, prefix, args.symlink_target, args.clientpath + ) def bfoptions(self, args: Namespace) -> None: self.suffix = "" if args.fs_suffix == "None" else args.fs_suffix prefix = self.get_prefix(args) - self.write_bfoptions(args.symlink_repo, prefix, args.symlink_target) + self.write_bfoptions( + args.symlink_repo, prefix, args.symlink_target, args.clientpath + ) def symlink(self, args: Namespace) -> None: self.suffix = "" if args.fs_suffix == "None" else args.fs_suffix prefix = self.get_prefix(args) self.create_symlink(args.symlink_repo, prefix, args.symlink_target) if args.bfoptions: - self.write_bfoptions(args.symlink_repo, prefix, args.symlink_target) + self.write_bfoptions( + args.symlink_repo, prefix, args.symlink_target, args.clientpath + ) def get_prefix(self, args): # type: ignore - conn = self.ctx.conn(args) # noqa q = conn.sf.getQueryService() rv = q.findAllByQuery( @@ -334,15 +343,18 @@ def get_symlink_dir(self, symlink_repo, prefix): # type: ignore symlink_dir = f"{prefix_dir}{self.suffix}" return symlink_dir - def write_bfoptions(self, managed_repo, fsprefix, symlink_target): # type: ignore # noqa + def write_bfoptions(self, managed_repo, fsprefix, symlink_target, clientpath=None): # type: ignore # noqa file_path = Path(symlink_target) mkngff_dir = self.get_symlink_dir(managed_repo, fsprefix) # os.makedirs(mkngff_dir, exist_ok=True) zarr_path = os.path.join(mkngff_dir, file_path.name) bfoptions_path = f"{zarr_path}.bfoptions" self.ctx.err("write bfoptions to: %s" % bfoptions_path) + lines = ["omezarr.list_pixels=false\n", "omezarr.quick_read=true\n"] + if clientpath is not None: + lines.append("omezarr.alt_store=%s\n" % clientpath) with open(bfoptions_path, "w") as f: - f.writelines(["omezarr.list_pixels=false", "\nomezarr.quick_read=true"]) + f.writelines(lines) def create_symlink(self, symlink_repo, prefix, symlink_target): # type: ignore # noqa symlink_path = Path(symlink_target)