Skip to content

Commit

Permalink
Merge pull request #30 from elephant-track/dev
Browse files Browse the repository at this point in the history
ELEPHANT server v0.5.4 -> v0.5.5
  • Loading branch information
ksugar authored Mar 27, 2024
2 parents 5013f34 + ea1b79b commit b27850d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM elephant-server:0.5.4
FROM elephant-server:0.5.6

LABEL maintainer="Ko Sugawara <[email protected]>"

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ help:

ELEPHANT_GPU?=all
ELEPHANT_WORKSPACE?=${PWD}/workspace
ELEPHANT_IMAGE_NAME?=elephant-server:0.5.4
ELEPHANT_IMAGE_NAME?=elephant-server:0.5.6
ELEPHANT_NVIDIA_GID?=$$(ls -n /dev/nvidia0 2>/dev/null | awk '{print $$4}')
ELEPHANT_DOCKER?=docker
ELEPHANT_RABBITMQ_NODENAME?=rabbit@localhost
Expand Down
28 changes: 18 additions & 10 deletions docker/install-rabbitmq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@ apt-get install curl gnupg debian-keyring debian-archive-keyring apt-transport-h
## Ignore warnings
export APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
## Team RabbitMQ's main signing key
apt-key adv --keyserver "hkps://keys.openpgp.org" --recv-keys "0x0A9AF2115F4687BD29803A206B73A36E6026DFCA"
## Cloudsmith: modern Erlang repository
curl -1sLf https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key | apt-key add -
## Cloudsmith: RabbitMQ repository
curl -1sLf https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/gpg.9F4587F226208342.key | apt-key add -
curl -1sLf "https://keys.openpgp.org/vks/v1/by-fingerprint/0A9AF2115F4687BD29803A206B73A36E6026DFCA" | sudo gpg --dearmor | sudo tee /usr/share/keyrings/com.rabbitmq.team.gpg > /dev/null
## Community mirror of Cloudsmith: modern Erlang repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-erlang.E495BB49CC4BBE5B.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg > /dev/null
## Community mirror of Cloudsmith: RabbitMQ repository
curl -1sLf https://github.com/rabbitmq/signing-keys/releases/download/3.0/cloudsmith.rabbitmq-server.9F4587F226208342.key | sudo gpg --dearmor | sudo tee /usr/share/keyrings/rabbitmq.9F4587F226208342.gpg > /dev/null

## Add apt repositories maintained by Team RabbitMQ
tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
sudo tee /etc/apt/sources.list.d/rabbitmq.list <<EOF
## Provides modern Erlang/OTP releases
##
deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu bionic main
deb-src https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/deb/ubuntu bionic main
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main
# another mirror for redundancy
deb [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.E495BB49CC4BBE5B.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-erlang/deb/ubuntu jammy main
## Provides RabbitMQ
##
deb https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu bionic main
deb-src https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-server/deb/ubuntu bionic main
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa1.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main
# another mirror for redundancy
deb [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main
deb-src [signed-by=/usr/share/keyrings/rabbitmq.9F4587F226208342.gpg] https://ppa2.novemberain.com/rabbitmq/rabbitmq-server/deb/ubuntu jammy main
EOF

## Update package indices
Expand Down
65 changes: 30 additions & 35 deletions elephant-core/elephant/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def profile(func):
return func


def _load_image(za_input, timepoint, use_median=False, img_size=None):
img = za_input[timepoint].astype('float32')
def _load_image(img, use_median=False, img_size=None):
if use_median and img.ndim == 3:
global_median = np.median(img)
for z in range(img.shape[0]):
Expand Down Expand Up @@ -86,38 +85,37 @@ def _get_memmap_or_load(za, timepoint, memmap_dir=None, use_median=False,
fpath = Path(memmap_dir) / f'{key}.dat'
lock = FileLock(str(fpath) + '.lock')
with lock:
if not fpath.exists():
logger().info(f'creating {fpath}')
fpath.parent.mkdir(parents=True, exist_ok=True)
if not fpath_org.exists():
logger().info(f'creating {fpath_org}')
fpath_org.parent.mkdir(parents=True, exist_ok=True)
img_org = np.memmap(
fpath_org,
dtype='float32',
mode='w+',
shape=za.shape[1:]
)
img_org[:] = za[timepoint].astype('float32')
if img_size is None:
img = img_org
else:
img = np.memmap(
fpath,
dtype='float32',
mode='w+',
shape=img_size
)
img[:] = F.interpolate(
torch.from_numpy(img_org)[None, None],
size=img_size,
mode='trilinear' if img.ndim == 3 else 'bilinear',
align_corners=True,
)[0, 0].numpy()
if use_median and img.ndim == 3:
global_median = np.median(img)
for z in range(img.shape[0]):
slice_median = np.median(img[z])
if 0 < slice_median:
img[z] -= slice_median - global_median
img = normalize_zero_one(img)
else:
img_org = np.memmap(
fpath_org,
dtype='float32',
mode='c',
shape=za.shape[1:]
)
if not fpath.exists():
logger().info(f'creating {fpath}')
fpath.parent.mkdir(parents=True, exist_ok=True)
img = np.memmap(
fpath,
dtype='float32',
mode='w+',
shape=img_size
)
img[:] = _load_image(
img_org,
use_median=use_median,
img_size=img_size,
)
logger().info(f'loading from {fpath}')
return np.memmap(
fpath,
Expand All @@ -126,14 +124,11 @@ def _get_memmap_or_load(za, timepoint, memmap_dir=None, use_median=False,
shape=za.shape[1:] if img_size is None else img_size
)
else:
img = za[timepoint].astype('float32')
if use_median and img.ndim == 3:
global_median = np.median(img)
for z in range(img.shape[0]):
slice_median = np.median(img[z])
if 0 < slice_median:
img[z] -= slice_median - global_median
img = normalize_zero_one(img)
img = _load_image(
za[timepoint].astype('float32'),
use_median=use_median,
img_size=img_size,
)
return img


Expand Down
2 changes: 1 addition & 1 deletion elephant-core/elephant/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# ==============================================================================
"""Version definition."""

__version__ = "0.5.4"
__version__ = "0.5.6"
2 changes: 1 addition & 1 deletion elephant_server.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"outputs": [],
"source": [
"%env ELEPHANT_SERVER_VERSION = v0.5.4"
"%env ELEPHANT_SERVER_VERSION = v0.5.6"
]
},
{
Expand Down

0 comments on commit b27850d

Please sign in to comment.