Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 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
32b1ad6
Updated requirements to use standalone celery instead of django plugin
TomekFraczek May 15, 2019
4d87c5c
Use updated setup for standalone celery app
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
f1ab5a8
Cleanup imports, minor style changes in db.tracker
TomekFraczek May 15, 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 *
8 changes: 7 additions & 1 deletion db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# from . import websocket
from .tracker import tasktrack
from .tracker import tasktrack

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery_base import app as celery_app

__all__ = ('celery_app',)
22 changes: 22 additions & 0 deletions db/celery_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery

# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'db.settings')

app = Celery('db')

# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks()


@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
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
5 changes: 0 additions & 5 deletions db/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'''
Django config file mostly auto-generated when a django project is created.
See https://docs.djangoproject.com/en/dev/intro/tutorial01/ for an introduction
Expand All @@ -8,10 +7,7 @@
import os
cwd = os.path.split(os.path.abspath(__file__))[0]

import djcelery
djcelery.setup_loader()
# Django settings for db project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

Expand Down Expand Up @@ -126,7 +122,6 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'djcelery',
'tracker.apps.TrackerConfig',
'trainbmi'
)
Expand Down
3 changes: 2 additions & 1 deletion db/tracker/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
default_app_config = "tracker.apps.TrackerConfig"
default_app_config = "tracker.apps.TrackerConfig"

13 changes: 7 additions & 6 deletions db/tracker/admin.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
'''
"""
Declare which database tables are visible from Django's default admin interface.

This file was initially created by Django
'''
from tracker.models import Task, Feature, System, TaskEntry, Calibration, DataFile, Subject, Sequence, Generator, AutoAlignment, Decoder
from django.contrib import admin

"""


from db.tracker.models import Task, Feature, System, TaskEntry, Calibration, DataFile, Subject, Sequence, Generator, AutoAlignment, Decoder
from django.contrib import admin
from django.db.models.signals import post_delete
from django.dispatch.dispatcher import receiver


@receiver(post_delete, sender=DataFile)
def _mymodel_delete(sender, instance, **kwargs):
instance.remove()



admin.site.register(Task)
admin.site.register(Feature)
admin.site.register(System)
Expand Down
Loading