From b79657177851e09a7764f0364dc0ce028671bfd5 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 28 Mar 2024 13:20:28 +0000 Subject: [PATCH 1/5] Add omezarr.alt_store option to .bfoptions --- src/omero_mkngff/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index a82b058..490459b 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -260,19 +260,19 @@ 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): @@ -304,16 +304,19 @@ def get_symlink_dir(self, symlink_repo, prefix): symlink_dir = f"{prefix_dir}{self.suffix}" return symlink_dir - def write_bfoptions(self, managed_repo, fsprefix, symlink_target): + def write_bfoptions(self, managed_repo, fsprefix, symlink_target, clientpath=None): 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={clientpath}\n") 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): symlink_path = Path(symlink_target) From 970e708c870fa16bbf60f3e48037aa4f7f7cbc1d Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 28 Mar 2024 13:20:51 +0000 Subject: [PATCH 2/5] Update README with omezarr.alt_store info --- README.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 1f3fd1d..ef75862 100644 --- a/README.rst +++ b/README.rst @@ -22,17 +22,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 From 01c55fc2bd4ae09491763b9e88c044be7ba8ddd4 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 28 Mar 2024 13:55:12 +0000 Subject: [PATCH 3/5] Add clientpath argument to symlink command --- src/omero_mkngff/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index 490459b..31c8665 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -182,6 +182,10 @@ def _configure(self, parser: Parser) -> None: symlink.add_argument("symlink_target") symlink.add_argument("--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("bfoptions", help="Create data.zarr.bfoptions in Fileset") From f91a9ffd9dbc3653ad1b390854f518728e1a9f93 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 28 Mar 2024 14:13:08 +0000 Subject: [PATCH 4/5] fix formatting --- src/omero_mkngff/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index 31c8665..00ae8a3 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -318,7 +318,7 @@ def write_bfoptions(self, managed_repo, fsprefix, symlink_target, clientpath=Non lines = ["omezarr.list_pixels=false\n", "omezarr.quick_read=true\n"] if clientpath is not None: - lines.append("omezarr.alt_store={clientpath}\n") + lines.append("omezarr.alt_store=%s\n" % clientpath) with open(bfoptions_path, "w") as f: f.writelines(lines) From 98dc2f8b3c33318538c3d5cf592053f2544c4444 Mon Sep 17 00:00:00 2001 From: William Moore Date: Fri, 26 Apr 2024 11:37:39 +0100 Subject: [PATCH 5/5] black formatting --- src/omero_mkngff/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/omero_mkngff/__init__.py b/src/omero_mkngff/__init__.py index b201933..4df6694 100644 --- a/src/omero_mkngff/__init__.py +++ b/src/omero_mkngff/__init__.py @@ -199,7 +199,7 @@ def _configure(self, parser: Parser) -> None: 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") + help=("Adds omezarr.alt_store=clientpath/path/to/img.zarr to bfoptions"), ) symlink.set_defaults(func=self.symlink) @@ -294,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, args.clientpath) + 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, args.clientpath) + 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, args.clientpath) + 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( @@ -338,15 +343,14 @@ 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, clientpath=None): # 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"] + 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: