Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/codalab/codalab
Browse files Browse the repository at this point in the history
  • Loading branch information
irjudson committed Aug 7, 2013
2 parents df5387e + 5eb828a commit e82337b
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 73 deletions.
88 changes: 88 additions & 0 deletions codalab/apps/web/management/commands/add_submission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from django.core.management.base import BaseCommand, CommandError
from apps.web.models import Competition,CompetitionPhase,CompetitionParticipant,CompetitionSubmission
from django.contrib.auth import get_user_model
User = get_user_model()
from optparse import make_option

from django.core.files.base import File

class Command(BaseCommand):
help = "Creates a submission for a participant"

option_list = BaseCommand.option_list + (
make_option('--email',
dest='email',
help="Email of the user"),
make_option('--competition',
dest='competition',
default=None,
help="ID of the submission"),
make_option('--phase',
dest='phase',
default=None,
help="ID of the competition phase"),
make_option('--submission',
dest='submission',
default=None,
help="Path to the submission file"),

)

def handle(self, *args, **options):
competition_id = options['competition']
phase_id = options['phase']
submission = options['submission']
competition = None
phase = None
if not options['email']:
print " ERROR ... Email Required ... "
exit(1)
if not submission:
print " ERROR ... Submission File Required ... "
exit(1)

user = User.objects.get(email=options['email'])
while not competition and not phase:
if competition_id and phase_id:
try:
phase = CompetitionPhase.objects.get(pk=phase_id, competition__pk=competition_id)
break
except Competition.DoesNotExist:
pass
else:
print "Competition/Phase not specified or not valid:\n"

clist = CompetitionPhase.objects.order_by('competition__pk').all()
if not clist:
print " ... There are no competitions ..."
exit(1)
sel = []
i = 0
for c in clist:
sel.append((c.competition,c))
print " %d) %s - %s" % (i+1,c.competition.title,c.label)
i = i + 1
try:
inp = int(raw_input("\n Enter number --> "))
idx = inp - 1
competition = sel[idx][0]
phase = sel[idx][1]
except ValueError:
print " ... Bad Input ... "
competition_id = None
continue
except Exception as e:
print e

part = CompetitionParticipant.objects.get(user=user,
competition=competition
)
submission_file = File(open(options['submission'],'rb'))

s = CompetitionSubmission.objects.create(participant=part,phase=phase,file=submission_file)

print "OK. Submission Created"




15 changes: 0 additions & 15 deletions codalab/compsrv/celery.py

This file was deleted.

32 changes: 29 additions & 3 deletions codalab/compsrv/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
from __future__ import absolute_import

from celery import Celery
from celery import task

celery = Celery('tasks', backend='amqp', )
celery.config_from_object('celeryconfig')

# Optional configuration, see the application user guide.
celery.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
)


# Tasks for competitions
# Currently stubs to test functionality
@task
def evaluate_submission(location):
# evaluate(inputdir,standard,outputdir)

def validate_submission(url):
"""
Will validate the format of a submission.
"""
return url

@task
def evaluate_submission(url):
# evaluate(inputdir, standard, outputdir)
return url


# For starting the process
if __name__ == '__main__':
celery.start()
4 changes: 2 additions & 2 deletions codalab/config/templates/freetds.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[global]
tds version = 8.0
tds version = 7.1
character set = UTF-8

[{{DB_SERVER}}]
port = {{DB_PORT}}
tds version = 8.0
tds version = 7.1
character set = UTF-8
host = {{DB_HOST}}
encryption = required
Expand Down
1 change: 1 addition & 0 deletions codalab/config/templates/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ worker_processes 4;
pid {{PROJECT_DIR}}/var/nginx-{{PORT}}.pid;
#error_log /tmp/nginx-https.err.log;
lock_file {{PROJECT_DIR}}/var/nginx-{{PORT}}.lock;
daemon off;

events {
worker_connections 768;
Expand Down
2 changes: 1 addition & 1 deletion codalab/config/templates/odbc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Database = {{DB_NAME}}
UID = {{DB_USER}}
PWD = {{DB_PASSWORD}}
Port = {{DB_PORT}}
TDS_Version = 8.0
TDS_Version = 7.1

2 changes: 1 addition & 1 deletion codalab/config/templates/odbcinst.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ODBC]
Trace = Yes
Trace = No
TraceFile = /tmp/odbc-{{DB_NAME}}.log

[FreeTDS]
Expand Down
39 changes: 29 additions & 10 deletions codalab/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,51 @@
VENV_PATH = os.path.join(THIS_DIR,'venv')
THIS_SETTINGS_DIR = os.path.join(THIS_DIR,'codalab','settings')

env.conf.DEPLOY_USER = 'wwwuser'
env.conf.DEPLOY_PATH = 'codalab_src'

def env_setup(config=env.CONFIG,settings_module='codalab.settings'):
if config is None:

sys.path.append('.')
os.environ['DJANGO_CONFIGURATION'] = config
os.environ["DJANGO_SETTINGS_MODULE"]= settings_module
os.environ["DJANGO_SETTINGS_MODULE"] = settings_module
from fabric.contrib import django

from configurations import importer

importer.install()
from fabric.contrib import django

django.settings_module(settings_module)
from django.conf import settings
from django.conf import settings as django_settings

#env.roledefs = settings.DEPLOY_ROLES
env.django_settings = settings
env_setup()
env.roledefs = django_settings.DEPLOY_ROLES
env.django_settings = django_settings

@task
def local():
def local(**kwargs):
env.run = lrun

env_setup(**kwargs)

@task
def remote():
def remote(**kwargs):
env.run = run
env_setup(**kwargs)

@task
def bootstrap_on_linux():
def clone_repo(repo_url='https://github.com/codalab/codalab.git',path=env.conf.DEPLOY_PATH):
env.run('git clone %s %s' % (repo_url, path))

@task
def provision(config='Dev'):
clone_repo()
with cd(env.conf.DEPLOY_PATH):
sudo('/bin/bash codalab/scripts/provision %s' % env.conf.DEPLOY_USER)
sudo('python manage.py config_gen --configuration=%s' % config,
user=env.conf.DEPLOY_USER)

@task
def bootstrap():
make_virtualenv(path='venv', system_site_packages=False)
with virtualenv('venv'):
run('pip install --upgrade pip')
Expand Down
7 changes: 7 additions & 0 deletions codalab/manage
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source ./config/generated/startup_env.sh
echo " .... "
echo "$DJANGO_CONFIGURATION Configuration"
echo " .... "
python manage.py "$@"
7 changes: 6 additions & 1 deletion codalab/runserver
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash

THIS_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd `pwd` > /dev/null
cd $THIS_DIR

source ./config/generated/startup_env.sh
echo " .... "
echo "$DJANGO_CONFIGURATION Configuration"
echo " .... "
python manage.py runserver $1 $2
/bin/bash manage runserver "$@"
popd
29 changes: 0 additions & 29 deletions codalab/scripts/provision

This file was deleted.

22 changes: 11 additions & 11 deletions codalab/scripts/ubuntu/provision
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
## This will eventually be a bit more configurable

THIS_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd `pwd` > /dev/null
pushd `pwd` 2>&1 > /dev/null
cd $THIS_DIR

U=$1

if [[ "$U" == "" ]] ; then
echo "Specify user"
exit 1
fi
if ! id -u "$U" > /dev/null; then
sudo useradd -m -s /bin/bash $U
sudo passwd $U
if [[ $U =~ [a-zA-Z0-9][\-\_a-zA-Z0-9]+[a-zA-Z0-9] ]] ; then
if ! id -u "$U" 2>&1 > /dev/null; then
echo "User will be added."
sudo useradd -m -s /bin/bash $U
sudo passwd $U
fi
else
echo "User not specified or username has bad characters"
exit 1
fi

echo "Installing codalab dependency meta-package..."
sudo dpkg -i *.deb > /dev/null && \
sudo apt-get -f install > /dev/null && \
echo "Updaing some user permissions..." && \
echo "Updaing some group permissions..." && \
sudo chgrp -R www-data /var/log/nginx /var/lib/nginx && \
sudo chmod -R g+rw /var/log/nginx /var/lib/nginx && \
sudo usermod -a -G www-data $U


popd > /dev/null

0 comments on commit e82337b

Please sign in to comment.