Skip to content

Commit

Permalink
Merge branch 'master' into parallel-uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
j6k4m8 authored Dec 9, 2021
2 parents e6d77f0 + 29179a0 commit 942b864
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -26,8 +26,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install brotli>=1.0.7
pip install cloud-volume>=3.4.0
pip install -e .[cloudvolume,meshing]
# - name: Lint with flake8
# run: |
# pip install flake8
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- **Convenience API**
- Adds support for uint16 image channel creation with the convenience API (#71)
- Now, the `array` class reports voxel size as a `float[3]` and `voxel_units` as a string (e.g. "nanometers") to match the input arguments to the `array` constructor (#83)
- **Parallelism**
- Fixes parallelism defaulting to n=1 (#70)
- This release adds support for parallel data uploads through `BossRemote#create_cutout`.
Expand Down
34 changes: 33 additions & 1 deletion intern/convenience/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ def __init__(
)
)
except:
# Default to nanometers if a voxel unit isn't provided
voxel_unit = voxel_unit or "nanometers"
# Create the coordframe:
coordframe = CoordinateFrameResource(
coordinate_frame_name or f"CF_{uri.collection}_{uri.experiment}",
Expand Down Expand Up @@ -486,7 +488,13 @@ def voxel_size(self):
self._coord_frame.y_voxel_size,
self._coord_frame.x_voxel_size,
)
return (vox_size, self._coord_frame.voxel_unit)
return vox_size

@property
def voxel_unit(self):
if self._coord_frame is None:
self._populate_coord_frame()
return self._coord_frame.voxel_unit

def _populate_exp(self):
"""
Expand All @@ -504,9 +512,33 @@ def _populate_coord_frame(self):
Cache the results for later.
"""
if self._exp is None:
self._populate_exp()
self._coord_frame = self.volume_provider.get_project(
CoordinateFrameResource(self._exp.coord_frame)
)

@property
def downsample_status(self):
"""
Return the downsample status of the underlying channel.
"""
return self._channel.downsample_status

@property
def available_resolutions(self):
"""
Return a list of available resolutions for this channel.
Arguments:
None
Returns:
List[int]: A list of resolutions at which this dataset can be downloaded
"""
self._populate_exp()
return list(range(dataset._exp.num_hierarchy_levels))

def __getitem__(self, key: Tuple) -> np.array:
"""
Expand Down
7 changes: 6 additions & 1 deletion intern/resource/boss/resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2016 The Johns Hopkins University Applied Physics Laboratory
# Copyright 2021 The Johns Hopkins University Applied Physics Laboratory
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,6 +39,11 @@ def __init__(self, name, description, creator='', raw={}):
self.description = description
self.creator = creator
self.raw = raw
self._public = raw.get("public", None)

@property
def public(self):
return self._public

def valid_volume(self):
return False
Expand Down
18 changes: 9 additions & 9 deletions intern/service/boss/v1/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ def get_cutout(
parallel = int(parallel)
else:
raise ValueError("Parallel must be greater than 0.")
pool = multiprocessing.Pool(processes=parallel)
chunks = pool.starmap(self.get_cutout, [
(
resource, resolution, b[0], b[1], b[2],
time_range, id_list, url_prefix, auth, session, send_opts,
access_mode
# TODO: kwargs
)
for b in blocks])
with multiprocessing.Pool(processes=parallel) as pool:
chunks = pool.starmap(self.get_cutout, [
(
resource, resolution, b[0], b[1], b[2],
time_range, id_list, url_prefix, auth, session, send_opts,
access_mode
# TODO: kwargs
)
for b in blocks])

for b, data in zip(blocks, chunks):
result[
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ blosc>=1.4.4
six
mock
nose2
zmesh
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_version(rel_path):
include_package_data=True,
author="Johns Hopkins University Applied Physics Laboratory",
install_requires=install_requires,
extras_require={"cloudvolume": ["cloud-volume>=3.4.0", "brotli>=1.0.7"]},
extras_require={'cloudvolume': ['cloud-volume>=3.4.0', 'brotli>=1.0.7'],'meshing': ['zmesh>=0.5.0']},
dependency_links=dependency_links,
author_email="[email protected]",
)

0 comments on commit 942b864

Please sign in to comment.