Skip to content

Commit 3c33020

Browse files
committed
compress_encode: Add option to specify zip store url
1 parent 1550451 commit 3c33020

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

server/scripts/compress_encode.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def compress_encode(input_filepath,
5959
cname='zstd',
6060
clevel=5,
6161
shuffle=True,
62-
zip_chunk_store=True):
62+
zip_chunk_store=True,
63+
zip_store_url=None):
6364
image = itk.imread(input_filepath)
6465
image_da = itk.xarray_from_image(image)
6566
dataset_name = Path(input_filepath).stem
@@ -119,7 +120,10 @@ def compress_encode(input_filepath,
119120
zip_store_path = str(Path(output_directory)) + '.zip'
120121
with zarr.storage.ZipStore(zip_store_path, mode='w', compression=0) as zip_store:
121122
zarr.copy_store(store, zip_store)
122-
zchunkstore = zip_zchunkstore(zip_store_path)
123+
store_url = None
124+
if zip_store_url:
125+
store_url = zip_store_url
126+
zchunkstore = zip_zchunkstore(zip_store_path, store_url)
123127
with open(zip_store_path + '.zchunkstore', 'w') as fp:
124128
json.dump(zchunkstore, fp)
125129

@@ -135,6 +139,7 @@ def compress_encode(input_filepath,
135139
parser.add_argument('--clevel', default=5, type=int, help='Compression level.')
136140
parser.add_argument('--no-multi-scale', action='store_true', help='Do not generate a multi-scale pyramid.')
137141
parser.add_argument('--no-zip-chunk-store', action='store_true', help='Do not generate a zip file and corresponding chunk store.')
142+
parser.add_argument('--zip-store-url', help='URL where the generated zip file will be hosted.')
138143

139144
args = parser.parse_args()
140145

@@ -145,4 +150,5 @@ def compress_encode(input_filepath,
145150
cname=args.cname,
146151
clevel=args.clevel,
147152
shuffle=not args.no_shuffle,
148-
zip_chunk_store=not args.no_zip_chunk_store)
153+
zip_chunk_store=not args.no_zip_chunk_store,
154+
zip_store_url=args.zip_store_url)

0 commit comments

Comments
 (0)