Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e29a775
auto-detect arm platform in build.sh
tijszwinkels Jul 5, 2024
0f68b03
Add exp branch
pgleeson Aug 15, 2024
259750b
Merge pull request #355 from tijszwinkels/detect-arm
pgleeson Aug 15, 2024
c11c5b1
Add the jupyterlab for compatibility with binder
Sep 21, 2024
dc7afef
Merge pull request #358 from tomichec/287-mybinder
pgleeson Oct 4, 2024
42d80bc
Merge branch 'development' into test_jupyterlab2
pgleeson Oct 4, 2024
e878e3d
Merge branch 'patch-1' of github.com:pikid/OpenWorm into pikid-patch-1
pgleeson Oct 4, 2024
9516673
Merge branch 'pikid-patch-1' into test_jupyterlab2
pgleeson Oct 4, 2024
1abda59
Merge branch 'experimental' into test_jupyterlab2
pgleeson Oct 4, 2024
d36a9fe
Arch check in rebuild also
pgleeson Oct 5, 2024
4e6e757
Initial jupyterlab run script
pgleeson Oct 5, 2024
b6ffffe
Copy out positions buffer also
pgleeson Oct 10, 2024
36a80c3
Merge branch 'master' into experimental
pgleeson Jun 6, 2025
724761f
Merge branch 'development' into experimental
pgleeson Jul 31, 2025
5a569e2
Better jupyterlab install
pgleeson Jul 31, 2025
715de9f
Tidying up image
pgleeson Jul 31, 2025
3a9e7a2
Improves the master_openworm script - makes it more realsitic about w…
pgleeson Aug 8, 2025
2b19881
Improve options o run.sh, able to pass a configuration, e.g. ./run.sh…
pgleeson Aug 8, 2025
551d12c
Use default worm_crawl_half_resolution
pgleeson Aug 8, 2025
cd45918
Improved test
pgleeson Aug 8, 2025
1adf562
Merge branch 'development' into experimental
pgleeson Nov 14, 2025
6492775
Some of the changes from experimental
pgleeson Nov 28, 2025
9468e9c
Temp: run a longer sim...
pgleeson Nov 28, 2025
2dea247
Just copy position files out
pgleeson Nov 28, 2025
2cf0ac4
Allow no c302 option to be passed with: -n
pgleeson Dec 1, 2025
b753a5a
Merge branch 'test_all' into experimental
pgleeson Dec 1, 2025
3fcb10e
Changes from experimental
pgleeson Dec 4, 2025
446749b
Latest run sh and py
pgleeson Dec 4, 2025
7170d26
Improved run scripts
pgleeson Dec 4, 2025
5049196
Install x11-xserver-utils
pgleeson Dec 4, 2025
de352fb
Better run scripts
pgleeson Dec 4, 2025
06e3b82
Merge branch 'test_all' into experimental
pgleeson Dec 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker-image-intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Run the Docker image
run: |
sudo apt-get update && sudo apt-get install -y x11-xserver-utils # for xhost
./run.sh
- name: Info on generated files
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docker-image-quickrun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
docker images
- name: Run the Docker image
run: |
sudo apt-get update && sudo apt-get install -y x11-xserver-utils # for xhost
./run-quick.sh
- name: Info on generated files
run: |
Expand Down
23 changes: 19 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Docker Image Build and Run

on:
push:
branches: [ master, dev*, test* ]
branches: [ master, dev*, experimental, test* ]
pull_request:
branches: [ master, dev*, test* ]
branches: [ master, dev*, experimental, test* ]

jobs:

Expand All @@ -14,18 +14,33 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: |
chmod a+w output/
ls -alth
./build.sh

- name: Info on Docker images
run: |
docker -v
docker images
- name: Run the Docker image

- name: Run the Docker image with the default falling cube demo from sibernetic
run: |
sudo apt-get update && sudo apt-get install -y x11-xserver-utils # for xhost
./run.sh -d 20 -c demo1

- name: Run the Docker image with a worm simulation - no c302
run: |
./stop.sh
./run.sh -d 10 -n

- name: Run the Docker image with a worm simulation
run: |
./run.sh
./stop.sh
./run.sh -d 150 # temp longer simulation for testing

- name: Info on generated files
run: |
ls -alth
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ output/C2*
/output/siminfo.py
/output/wor*
/output/Sibernetic_*
/output/test*
/output/box
/output/swim*
/output/alone*
/output/cube*
/output/master*
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ RUN apt-get install -y --no-install-recommends apt-utils \
wget nano htop build-essential make git automake autoconf \
g++ rpm libtool libncurses5-dev zlib1g-dev bison flex \
sudo xorg openbox x11-xserver-utils \
libxext-dev libncurses-dev mercurial \
libxext-dev libncurses-dev \
freeglut3-dev libglu1-mesa-dev libglew-dev python3-dev python3-pip \
kmod dkms linux-source linux-headers-generic \
maven openjdk-8-jdk \
openjdk-21-jdk \
libnuma1 \
openmpi-bin libopenmpi-dev \
libgl1 libglx-mesa0 libgl1-mesa-dri libfreetype6-dev \
libxft-dev unzip ffmpeg xvfb tmux

Expand Down Expand Up @@ -96,7 +95,8 @@ ENV NEURON_MODULE_OPTIONS=-nogui
RUN wget https://master.dl.sourceforge.net/project/nicehashsgminerv5viptools/APP%20SDK%20A%20Complete%20Development%20Platform/AMD%20APP%20SDK%203.0%20for%2064-bit%20Linux/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 && \
tar -xf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 && \
printf 'Y\n\n' | sudo ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh && \
rm AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
rm AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 && \
rm AMD-APP-SDK-v3.0.130.136-GA-linux64.sh

RUN sudo ln -s /opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libOpenCL.so.1 /usr/lib/libOpenCL.so.1
RUN sudo ln -s /opt/AMDAPPSDK-3.0/lib/x86_64/sdk/libamdocl64.so /usr/lib/libamdocl64.so
Expand All @@ -116,6 +116,12 @@ RUN cd sibernetic && \
make clean && make all && ldd ./Release/Sibernetic # Use python 3 libs


################################################################################
######## Set up JupyterLab

RUN sudo pip install notebook jupyterlab --break-system-packages


################################################################################
######## Copy master python script

Expand All @@ -125,6 +131,9 @@ RUN sudo chown $USER:$USER $HOME/master_openworm.py

RUN printf '\n\nalias cd..="cd .."\nalias h=history\nalias ll="ls -alth"\n' >> ~/.bashrc



RUN pip list

RUN echo "Built the OpenWorm Docker image!"

114 changes: 43 additions & 71 deletions master_openworm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,20 @@
import math

print("*****************************")
print("OpenWorm Master Script")
print(" OpenWorm Master Script")
print("*****************************")
print("")
print(
"This script attempts to run a full pass through the OpenWorm scientific libraries."
)
print("This script attempts to run a full pass through the OpenWorm software stack.")
print(
"This depends on several other repositories being loaded to work and presumes it is running in a preloaded Docker instance."
)
print("It will report out where steps are missing.")
print("Eventually all the steps will be filled in.")
print("")

print("****************************")
print("Step 1: Rebuild c302 from the latest owmeta")
print("****************************")
print("Not yet implemented. See https://github.com/openworm/c302/issues/10")


print("****************************")
print("Step 2: Execute unit tests via the c302 simulation framework")
print("****************************")
"""
from runAndPlot import run_c302
orig_display_var = None
if os.environ.has_key('DISPLAY'):
orig_display_var = os.environ['DISPLAY']
del os.environ['DISPLAY'] # https://www.neuron.yale.edu/phpBB/viewtopic.php?f=6&t=1603

run_c302(DEFAULTS['reference'],
DEFAULTS['c302params'],
'',
DEFAULTS['duration'],
DEFAULTS['dt'],
'jNeuroML_NEURON',
data_reader=DEFAULTS['datareader'],
save=True,
show_plot_already=False,
target_directory=os.path.join(os.environ['C302_HOME'], 'examples'),
save_fig_to='tmp_images')
prev_dir = os.getcwd()
os.chdir(DEFAULTS['outDir'])
try:
os.mkdir('c302_out')
except OSError as e:
if e.errno != errno.EEXIST:
raise
src_files = os.listdir(os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images'))
for file_name in src_files:
full_file_name = os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images', file_name)
print("COPY %s" % full_file_name)
if (os.path.isfile(full_file_name)):
shutil.copy2(full_file_name, 'c302_out')
shutil.rmtree(os.path.join(os.environ['C302_HOME'], 'examples', 'tmp_images'))
os.chdir(prev_dir)
if orig_display_var:
os.environ['DISPLAY'] = orig_display_var
"""

print("****************************")
print("Step 3: Run c302 + Sibernetic in the same loop.")
print(" Step 1: Run c302 + Sibernetic in the same loop.")
print("****************************")

OW_OUT_DIR = os.environ["OW_OUT_DIR"]
Expand Down Expand Up @@ -112,8 +65,6 @@ def execute_with_realtime_output(command, directory, env=None):
except Exception:
print("Unexpected error: %s" % sys.exc_info()[0])

OW_OUT_DIR = os.environ["OW_OUT_DIR"]


try:
if os.access(OW_OUT_DIR, os.W_OK) is not True:
Expand All @@ -130,20 +81,26 @@ def execute_with_realtime_output(command, directory, env=None):
if "DURATION" in os.environ:
sim_duration = float(os.environ["DURATION"])

noc302 = False

configuration = "worm_crawl_half_resolution"
if "CONFIGURATION" in os.environ:
configuration = os.environ["CONFIGURATION"]

if "NOC302" in os.environ:
noc302 = bool(os.environ["NOC302"])
noc302 = os.environ["NOC302"] == "1"
else:
noc302 = "worm" not in configuration

DEFAULTS = {
PARAMETERS = {
"duration": sim_duration,
"dt": 0.005,
"dtNrn": 0.05,
"logstep": 100,
"reference": "FW",
"reference": "FW", # "TargetMuscle",
"c302params": "C2",
"verbose": False,
"device": "CPU",
"configuration": "worm_crawl_half_resolution",
"configuration": configuration,
"noc302": noc302,
"datareader": "UpdatedSpreadsheetDataReader2",
"outDir": OW_OUT_DIR,
Expand All @@ -161,6 +118,10 @@ def execute_with_realtime_output(command, directory, env=None):
) # TODO: terminate xvfb after recording

try:
print("Starting Sibernetic simulation with parameters:")
for p in PARAMETERS:
print(" %s: %s" % (p, PARAMETERS[p]))

command = """python3 sibernetic_c302.py
-duration %s
-dt %s
Expand All @@ -172,23 +133,24 @@ def execute_with_realtime_output(command, directory, env=None):
-c302params %s
-datareader %s
-outDir %s""" % (
DEFAULTS["duration"],
DEFAULTS["dt"],
DEFAULTS["dtNrn"],
DEFAULTS["logstep"],
DEFAULTS["device"],
DEFAULTS["configuration"],
DEFAULTS["reference"],
DEFAULTS["c302params"],
DEFAULTS["datareader"],
PARAMETERS["duration"],
PARAMETERS["dt"],
PARAMETERS["dtNrn"],
PARAMETERS["logstep"],
PARAMETERS["device"],
PARAMETERS["configuration"],
PARAMETERS["reference"],
PARAMETERS["c302params"],
PARAMETERS["datareader"],
"simulations",
)
# DEFAULTS['outDir'])
# PARAMETERS['outDir'])

if noc302:
command += " -noc302"

execute_with_realtime_output(command, os.environ["SIBERNETIC_HOME"], env=my_env)

except KeyboardInterrupt:
pass

Expand All @@ -198,7 +160,7 @@ def execute_with_realtime_output(command, directory, env=None):
for dirpath, dirnames, filenames in os.walk(sibernetic_sim_dir):
for directory in dirnames:
if directory.startswith(
"%s_%s" % (DEFAULTS["c302params"], DEFAULTS["reference"])
"%s_%s" % (PARAMETERS["c302params"], PARAMETERS["reference"])
):
all_subdirs.append(os.path.join(dirpath, directory))
if directory.startswith("Sibernetic"):
Expand Down Expand Up @@ -237,6 +199,16 @@ def execute_with_realtime_output(command, directory, env=None):
print("Moving %s to %s" % (report, new_sim_out))
shutil.move(report, new_sim_out)

# Copy position files etc.
txt_files = glob.glob("%s/*.txt" % latest_subdir)
for txt_file in txt_files:
print("Moving %s to %s" % (txt_file, new_sim_out))
shutil.move(txt_file, new_sim_out)
dat_files = glob.glob("%s/*.dat" % latest_subdir)
for dat_file in dat_files:
print("Moving %s to %s" % (dat_file, new_sim_out))
shutil.move(dat_file, new_sim_out)

# Copy WCON file(s)
wcons = glob.glob("%s/*.wcon" % latest_subdir)
for wcon in wcons:
Expand Down Expand Up @@ -267,7 +239,7 @@ def execute_with_realtime_output(command, directory, env=None):
)

command = "./Release/Sibernetic -f %s -l_from lpath=%s" % (
DEFAULTS["configuration"],
PARAMETERS["configuration"],
latest_subdir,
)
execute_with_realtime_output(command, os.environ["SIBERNETIC_HOME"], env=my_env)
Expand Down Expand Up @@ -350,7 +322,7 @@ def execute_with_realtime_output(command, directory, env=None):


print("****************************")
print("Step 4: Run movement analysis")
print(" Step 2: Run movement analysis")
print("****************************")
print("Not yet implemented.")
print(
Expand All @@ -360,6 +332,6 @@ def execute_with_realtime_output(command, directory, env=None):


print("****************************")
print("Step 5: Report on movement analysis fit to real worm videos")
print(" Step 3: Report on movement analysis fit to real worm videos")
print("****************************")
print("Not yet implemented.")
5 changes: 5 additions & 0 deletions run-jl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

version=$(<VERSION) # Read version of Dockerfile from file VERSION

docker run -it --rm -p 8888:8888 "openworm/openworm:$version" jupyter lab --NotebookApp.default_url=/lab/ --ip=0.0.0.0 --port=8888 --allow-root
5 changes: 3 additions & 2 deletions run-quick.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -ex

#from: https://unix.stackexchange.com/a/129401
while getopts ":d:p:" opt; do
Expand All @@ -16,7 +17,7 @@ OW_OUT_DIR=/home/ow/shared
HOST_OUT_DIR=$PWD
version=$(<VERSION) # Read version of Dockerfile from file VERSION

xhost +
xhost + || true # allow connections to X server, don't throw an error if it fails


NOC302_PART="-e NOC302=1"
Expand All @@ -33,6 +34,6 @@ $DURATION_PART \
--privileged \
-v $HOST_OUT_DIR:$OW_OUT_DIR:rw \
openworm/openworm:$version \
bash -c "DISPLAY=:44 python master_openworm.py"
bash -c "DISPLAY=:44 python3 master_openworm.py"

docker logs -f openworm_$version
Loading