Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
63fe4fc
updated requirements file
TomekFraczek May 8, 2019
cb3fafa
Move to docker based install
TomekFraczek May 9, 2019
9b6a02e
Split docker install to facilitate caching, remove opengl-accelerate
TomekFraczek May 9, 2019
b3904ee
Move package install to docker file, re-order to use cache
TomekFraczek May 9, 2019
0d937f5
Fix rabbitmq install, reactivate python installs
TomekFraczek May 13, 2019
10b19a9
Comment out all plexon setup, seems to try and use python2
TomekFraczek May 14, 2019
ed6143d
Multiple dockerfile install bugfixes:
TomekFraczek May 14, 2019
5b2bf8f
Fix references to config file after directory name change
TomekFraczek May 14, 2019
eb095a4
Remove debug statements in dockerfile
TomekFraczek May 14, 2019
d3d584e
Made make_config.py optionally non-interactive, run defaults in build
TomekFraczek May 14, 2019
1d42eb1
Add bash and batch scripts to run interactive config on docker container
TomekFraczek May 14, 2019
5cf9d60
Indent default value output in make_config.py
TomekFraczek May 14, 2019
d932918
Bugfix: was making directory 'logs' instead of 'log'
TomekFraczek May 14, 2019
4cedf14
Use makemigrations/migrate isntead of syncdb
TomekFraczek May 14, 2019
796db54
Merge branch 'unstable_py3' into uw_py3
TomekFraczek May 14, 2019
a086f66
Split dockerfile into 3 to allow re-building of only tail
TomekFraczek May 15, 2019
6574f30
Tmp fix of feature and task lists: use empty dicts on import error
TomekFraczek May 15, 2019
97865c7
Split docker images into three separate images to help with partial r…
TomekFraczek May 15, 2019
3332169
Merge celery fix into uw_py3'
TomekFraczek May 15, 2019
f123409
Re-organize build code between dockerfiles
TomekFraczek May 15, 2019
daffa0d
Actually remove OpenGL-accelerate
TomekFraczek May 18, 2019
175531e
Preven clearing of logs on python level re-build
TomekFraczek May 18, 2019
68ceee1
Prevent pip install if requirements have not changed
TomekFraczek May 18, 2019
d2cb2ac
Removed redundant installs of plotutils and pygame
TomekFraczek May 20, 2019
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
9 changes: 9 additions & 0 deletions config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off

IF "%~1"=="" (
echo "No docker container name given!"
EXIT /B 2
) ELSE (
docker run -it --name configuration-inator %1 python config/make_config.py
docker commit configuration-inator %1
)
7 changes: 7 additions & 0 deletions config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash
if [$# -eq 0]; then
echo "No docker image name given!"
else
docker run -it --name configuration-inator $1 python config/make_config.py;
docker commit configuration-inator $1;
fi
27 changes: 18 additions & 9 deletions config/make_config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python
'''
Executable script to create the configuration file for the BMI3D code, a text file called '$BMI3D/config_files/config'
Executable script to create the configuration file for the BMI3D code, a text file called '$BMI3D/config/config'
'''
import os
import sys
from collections import OrderedDict

stuff = OrderedDict()
Expand All @@ -14,24 +15,32 @@
stuff['plexon IP address'] = dict(addr='10.0.0.13', port=6000)
stuff['update_rates'] = dict(hdf_hz=60)

# Add an optional commandline flag to make setup non-interactive
use_defaults = '-y' in sys.argv or '--use-defaults' in sys.argv

from db import settings
databases = list(settings.DATABASES.keys())

for dbname in databases:
stuff['db_config_%s' % dbname] = dict(data_path='/storage')
for db_name in databases:
stuff[f'db_config_{db_name}'] = dict(data_path='/storage')

config_filename = '$BMI3D/config_files/config'
config_filename = '$BMI3D/config/config'
config_fh = open(os.path.expandvars(config_filename), 'w')

for system_name, system_opts in list(stuff.items()):
config_fh.write('[%s]\n' % system_name)
config_fh.write(f'[{system_name}]\n')
print(system_name)
for option, default in list(system_opts.items()):
print(option, default)
opt_val = input("Enter value for '%s' (default=%s): " % (option, str(default)))
if opt_val == '':

if use_defaults:
print(f" Using default ({default}) for {option}")
opt_val = default
config_fh.write('%s = %s\n' % (option, opt_val))
else:
opt_val = input(f" Enter value for '{option}' (default={default}): ")
if opt_val == '':
opt_val = default

config_fh.write(f'{option} = {opt_val}\n')
config_fh.write('\n')
print()

Expand Down
17 changes: 11 additions & 6 deletions config/namelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
Lookup table for features, generators and tasks for experiments
'''

## Get the list of experiment features
from .featurelist import features

## Get the list of tasks
from .tasklist import tasks
# Get the list of experiment features
try:
from .featurelist import features
except (ImportError, ModuleNotFoundError):
features = {}

# Get the list of tasks
try:
from .tasklist import tasks
except (ImportError, ModuleNotFoundError):
tasks = {}

# Derive generator functions from the tasklist (all generatorfunctions should be staticmethods of a task)
generator_names = []
Expand Down Expand Up @@ -67,4 +72,4 @@ def __getitem__(self, name):

################################################################################
################################################################################
from .bmilist import *
# from .bmilist import *
6 changes: 3 additions & 3 deletions db/runserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -z "$BMI3D" ]
fi

#Check /storage (exist )
storage=$(python $BMI3D/config_files/check_storage.py 2>&1)
storage=$(python $BMI3D/config/check_storage.py 2>&1)
if [ $storage == 'False' ]; then
echo "/storage does not exist --> if on Ismore, must mount"
exit 1
Expand All @@ -28,8 +28,8 @@ if [ `ps aux | grep "manage.py runserver" | grep python | wc -l` -gt 0 ]; then
fi

# Check that a config file is in the correct place, $BMI3D/config
if [ ! -e $BMI3D/config_files/config ]; then
echo "ERROR: cannot find config file! Did you run $BMI3D/config_files/make_config.py?"
if [ ! -e $BMI3D/config/config ]; then
echo "ERROR: cannot find config file! Did you run $BMI3D/config/make_config.py?"
exit 1
fi

Expand Down
55 changes: 55 additions & 0 deletions install/docker/bmi3d.base.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
##### ################################################################### ####
##### ---- Starting point when any os dependencies have been changed ---- ####
##### ################################################################### ####
FROM python:3

#### Connect up third-party repositories (rabbitmq and erlang)
RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | bash
RUN echo "deb http://dl.bintray.com/rabbitmq-erlang/debian bionic erlang" \
>> /etc/apt/sources.list.d/bintray.erlang.list
RUN apt-get -y update


##### Install required ubuntu packages
RUN apt-get install -y \
smbclient \
cifs-utils \
bison \
flex \
openssh-server \
libusb-dev\
libcomedi-dev \
python-comedilib \
swig \
isc-dhcp-server \
sqlite3 \
vim

# Install rabbitmq with it's erlang dependencies
RUN apt-get install -y --allow-unauthenticated \
erlang-base-hipe \
erlang-asn1 \
erlang-crypto \
erlang-eldap \
erlang-ftp \
erlang-inets \
erlang-mnesia \
erlang-os-mon \
erlang-parsetools \
erlang-public-key \
erlang-runtime-tools \
erlang-snmp \
erlang-ssl \
erlang-syntax-tools \
erlang-tftp \
erlang-tools \
erlang-xmerl \
rabbitmq-server

####### Set up directories
RUN mkdir -v -p /code/src/
RUN mkdir -v -p /backup && chown root /backup
RUN mkdir -v -p /storage/plots && chown -R root /storage\
RUN mkdir -v -p /code/bmi3d/log


17 changes: 17 additions & 0 deletions install/docker/bmi3d.code.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#### ##################################################################### #####
#### ---- Starting point when only small local changes have been made ---- #####
#### ##################################################################### #####
FROM bmi3d:python
COPY bmi3d/ /code/bmi3d/
COPY bmi3d_tasks_analysis/ /code/bmi3d_tasks_analysis/

RUN python config/make_config.py --use-defaults && \
python db/manage.py makemigrations && \
python db/manage.py migrate

# Fix all .sh files that might have aquired windows line endings
RUN for f in $(find /code/ -name "*.sh"); \
do echo "fixing: $f" && sed -i 's/\r$//' $f; \
done

CMD [ "/bin/bash", "./db/runserver.sh" ]
18 changes: 18 additions & 0 deletions install/docker/bmi3d.python.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
##### ################################################################### ####
##### ---- Starting point when python dependencies have been changed ---- ####
##### ################################################################### ####
FROM bmi3d:base

# --- Expect cache invalidation here if source files have changed --- #
COPY bmi3d/requirements.txt /code/bmi3d/requirements.txt

WORKDIR /code/bmi3d/

###### Install python dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt

# Set env vars for future reference
ENV BMI3D="/code/bmi3d" \
PYTHONPATH="${PYTHONPATH}:/code/bmi3d/:/code/bmi3d_tasks_analysis"

63 changes: 63 additions & 0 deletions install/docker/src_code_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
####### Declare environment variables
CODE=/code
BMI3D=$CODE/bmi3d ### Directory in which to install the bmi3d software
USER=root # We're in a docker container so root is safe

####### Download any src code
git clone https://github.com/sgowda/robotics_toolbox $HOME/code/robotics
# Phidgets code
#wget https://www.phidgets.com/downloads/phidget22/libraries/linux/libphidget22/libphidget22-1.1.20190417.tar.gz
#wget https://www.phidgets.com/downloads/phidget22/libraries/any/Phidget22Python/Phidget22Python_1.1.20190418.zip


####### Install source code, configure software
# plexread module
#cd $BMI3D/riglib
which python
#python setup.py install

# NIDAQ software -- deprecated!
# $HOME/code/bmi3d/riglib/nidaq/build.sh

echo "TESTED IF HERE"

# Phidgets libraries
#cd $CODE/src/
#tar xzf libphidget.tar.gz
#cd libphidget*
#./configure
#make
#make install

#cd $CODE/src/
#unzip PhidgetsPython.zip
#cd PhidgetsPython
#python setup.py install



####### Configure udev rules, permissions
# Phidgets
#cp $CODE/src/libphidget*/udev/99-phidgets.rules /etc/udev/rules.d
#chmod a+r /etc/udev/rules.d/99-phidgets.rules
# NIDAQ
cp $HOME/code/bmi3d/install/udev/comedi.rules /etc/udev/rules.d/
chmod a+r /etc/udev/rules.d/comedi.rules
udevadm control --reload-rules
# Group permissions
usermod -a -G iocard $USER # NIDAQ card belongs to iocard group
usermod -a -G dialout $USER # Serial ports belong to 'dialout' group


####### Reconfigure .bashrc
sed -i '$a export PYTHONPATH=$PYTHONPATH:$HOME/code/robotics' $HOME/.bashrc
sed -i '$a export BMI3D=/home/lab/code/bmi3d' $HOME/.bashrc
sed -i '$a source $HOME/code/bmi3d/pathconfig.sh' $HOME/.bashrc
source $HOME/.bashrc

chown -R $USER ~/.matplotlibs

cd $HOME/code/bmi3d/db
python manage.py syncdb
# Add superuser 'lab' with password 'lab'
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ traits
pandas
patsy
statsmodels
PyOpenGL
PyOpenGL-accelerate
PyOpenGL
Django
pylibftdi
nitime
sphinx
numpydoc
tornado
tables
sklearn
pyserial
h5py
pygame
Expand Down