Skip to content

Commit 8a29644

Browse files
committed
Back to dockerfile & master_openworm.py from master; to v0.9.2
1 parent cbb8217 commit 8a29644

File tree

3 files changed

+16
-42
lines changed

3 files changed

+16
-42
lines changed

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:18.04
22

33
LABEL maintainer="David Lung ([email protected]); Padraig Gleeson ([email protected])"
44

@@ -36,7 +36,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \
3636
wget nano htop build-essential make git automake autoconf \
3737
g++ rpm libtool libncurses5-dev zlib1g-dev bison flex lsb-core \
3838
sudo xorg openbox x11-xserver-utils \
39-
libxext-dev libncurses-dev python3-dev mercurial \
39+
libxext-dev libncurses-dev python-dev mercurial \
4040
freeglut3-dev libglu1-mesa-dev libglew-dev python3-dev python3-pip python3-lxml python3-scipy python3-tk \
4141
kmod dkms linux-source linux-headers-generic \
4242
maven openjdk-8-jdk \
@@ -50,7 +50,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \
5050

5151
RUN sudo usermod -a -G video $USER
5252

53-
#USER $USER
53+
USER $USER
5454
ENV HOME /home/$USER
5555
WORKDIR $HOME
5656

@@ -62,7 +62,8 @@ RUN sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10
6262
################################################################################
6363
######## Install NEURON simulator
6464

65-
RUN pip3 install neuron==8.0.1
65+
RUN sudo pip install neuron==7.8.1
66+
6667

6768
################################################################################
6869
######## Install pyNeuroML for handling NeuroML network model
@@ -149,7 +150,8 @@ sudo apt install -y ocl-icd-opencl-dev vim
149150
######## Build Sibernetic
150151

151152
RUN cd sibernetic && \
152-
sed -i -e "s/n2.7/n3.10/g" makefile && \
153+
sed -i -e "s/lpython2.7/lpython3.6m/g" makefile && \
154+
sed -i -e "s/n2.7/n3.6/g" makefile && \
153155
make clean && make all # Use python 3 libs
154156

155157
# intel i5, hd 5500, linux 4.15.0-39-generic

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.3
1+
0.9.2

master_openworm.py

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import matplotlib
33
matplotlib.use('Agg')
44
import shutil
5-
from subprocess import Popen, PIPE, check_output, STDOUT
5+
from subprocess import Popen, PIPE, check_output
66
import os
77
import pwd
88
import shlex
@@ -12,7 +12,7 @@
1212
import math
1313

1414
print("*****************************")
15-
print("OpenWorm Master Script v0.9.3")
15+
print("OpenWorm Master Script v0.9.2")
1616
print("*****************************")
1717
print("")
1818
print("This script attempts to run a full pass through the OpenWorm scientific libraries.")
@@ -76,28 +76,16 @@
7676
def execute_with_realtime_output(command, directory, env=None):
7777
p = None
7878
try:
79-
80-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
81-
print('>> Executing command: %s'%command)
82-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
83-
p = Popen(shlex.split(command),
84-
stdout=PIPE,
85-
stderr=STDOUT,
86-
cwd=directory,
87-
env=env)
79+
p = Popen(shlex.split(command), stdout=PIPE, bufsize=1, cwd=directory, env=env)
8880
with p.stdout:
8981
for line in iter(p.stdout.readline, b''):
90-
print('>> %s'%line.decode('utf-8'), end='')
82+
print(line.decode('utf-8'), end='')
9183
p.wait() # wait for the subprocess to exit
9284
except KeyboardInterrupt as e:
9385
print("Caught CTRL+C")
9486
if p:
9587
p.kill()
9688
raise e
97-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
98-
print('>> Command exited with %i: %s'%(p.returncode,command))
99-
print('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n')
100-
10189

10290

10391
sys.path.append(os.environ['C302_HOME'])
@@ -122,10 +110,6 @@ def execute_with_realtime_output(command, directory, env=None):
122110
if 'DURATION' in os.environ:
123111
sim_duration = float(os.environ['DURATION'])
124112

125-
noc302 = False
126-
if 'NOC302' in os.environ:
127-
noc302 = bool(os.environ['NOC302'])
128-
129113
DEFAULTS = {'duration': sim_duration,
130114
'dt': 0.005,
131115
'dtNrn': 0.05,
@@ -135,7 +119,7 @@ def execute_with_realtime_output(command, directory, env=None):
135119
'verbose': False,
136120
'device': 'GPU',
137121
'configuration': 'worm_crawl_half_resolution',
138-
'noc302': noc302,
122+
'noc302': False,
139123
'datareader': 'UpdatedSpreadsheetDataReader2',
140124
'outDir': OW_OUT_DIR}
141125

@@ -167,9 +151,6 @@ def execute_with_realtime_output(command, directory, env=None):
167151
DEFAULTS['datareader'],
168152
'simulations')
169153
#DEFAULTS['outDir'])
170-
171-
if noc302: command += ' -noc302'
172-
173154
execute_with_realtime_output(command, os.environ['SIBERNETIC_HOME'], env=my_env)
174155
except KeyboardInterrupt as e:
175156
pass
@@ -181,13 +162,9 @@ def execute_with_realtime_output(command, directory, env=None):
181162
for directory in dirnames:
182163
if directory.startswith('%s_%s' % (DEFAULTS['c302params'], DEFAULTS['reference'])):
183164
all_subdirs.append(os.path.join(dirpath, directory))
184-
if directory.startswith('Sibernetic'):
185-
all_subdirs.append(os.path.join(dirpath, directory))
186165

187166
latest_subdir = max(all_subdirs, key=os.path.getmtime)
188-
print('\n========================================================================\n')
189-
print('Finished main simulation, data saved in: %s'%latest_subdir)
190-
execute_with_realtime_output('ls -alt %s'%latest_subdir, os.environ['SIBERNETIC_HOME'], env=my_env)
167+
191168

192169
try:
193170
os.mkdir('%s/output' % OW_OUT_DIR)
@@ -221,9 +198,6 @@ def execute_with_realtime_output(command, directory, env=None):
221198
print("Moving %s to %s"%(wcon, new_sim_out))
222199
shutil.move(wcon, new_sim_out)
223200

224-
time.sleep(2)
225-
226-
227201

228202
# Rerun and record simulation
229203
os.system('export DISPLAY=:44')
@@ -236,9 +210,7 @@ def execute_with_realtime_output(command, directory, env=None):
236210
os.system('tmux send-keys -t SiberneticRecording q')
237211
os.system('tmux send-keys -t SiberneticRecording "exit" C-m')
238212

239-
time.sleep(5)
240-
241-
execute_with_realtime_output('ls -alt %s'%latest_subdir, os.environ['SIBERNETIC_HOME'], env=my_env)
213+
time.sleep(3)
242214

243215
# Remove black frames at the beginning of the recorded video
244216
command = "ffmpeg -i %s/%s -vf blackdetect=d=0:pic_th=0.70:pix_th=0.10 -an -f null - 2>&1 | grep blackdetect" % (new_sim_out, sibernetic_movie_name)
@@ -275,7 +247,7 @@ def execute_with_realtime_output(command, directory, env=None):
275247
os.system('ffmpeg -ss 1 -i %s/cut_%s -vf "select=gt(scene\,0.1)" -vsync vfr -vf fps=fps=1/1 %s' % (new_sim_out, sibernetic_movie_name, 'tmp/out%06d.jpg'))
276248
os.system('ffmpeg -r 100 -i %s -r 100 -vb 60M %s/speeded_%s' % ('tmp/out%06d.jpg', new_sim_out, sibernetic_movie_name))
277249

278-
os.system('rm -r tmp/*')
250+
os.system('sudo rm -r tmp/*')
279251

280252

281253

0 commit comments

Comments
 (0)