diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..eea89370c --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +exclude: venv,scripts +ignore: E501,F403 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5a766ce06..7cb31e274 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,16 @@ -language: python -python: - - "2.7" -branches: - only: - - master -install: - - pip install -r codalab/requirements/dev_azure_nix.txt --use-mirrors -script: - - cd codalab - - python manage.py test - +language: python +python: + - "2.7" +branches: + only: + - master +install: + - "pip install -r codalab/requirements/dev_azure_nix.txt --use-mirrors" +# - "pip install -q flake8 pylint django-nose --use-mirrors" +before_script: +# - "flake8 --config=.flake8 ." +# - "pylint --rcfile=pylint.rc tests" +# - "pylint --rcfile=pylint.rc setup.py" +script: + - "cd codalab" + - "python manage.py test" diff --git a/codalab/apps/api/models.py b/codalab/apps/api/models.py index 71a836239..6b2021999 100644 --- a/codalab/apps/api/models.py +++ b/codalab/apps/api/models.py @@ -1,3 +1 @@ -from django.db import models - # Create your models here. diff --git a/codalab/apps/api/tests.py b/codalab/apps/api/tests.py index 85a735674..c7a33bb38 100644 --- a/codalab/apps/api/tests.py +++ b/codalab/apps/api/tests.py @@ -2,13 +2,17 @@ """ test for competition creation via api """ -import sys, os.path, os, random, datetime +import sys +import os.path +import os +import datetime from django.utils import timezone -from django.core import management # This is a really, really long way around saying that if the script is in -# codalab\scripts\users.py, we need to add, ../../../codalab to the sys.path to find the settings -root_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") +# codalab\scripts\users.py, we need to add, ../../../codalab to the +# sys.path to find the settings +root_dir = os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") sys.path.append(root_dir) # Set things for django configurations @@ -19,11 +23,8 @@ from configurations import importer importer.install() -from django.core.files import File from django.contrib.auth import get_user_model -from django.contrib.contenttypes.models import ContentType from django.test import TestCase -from django.core import management from apps.web.models import * @@ -34,7 +35,9 @@ current_time = timezone.now() start_date = current_time - datetime.timedelta(days=1) + class CompetitionsPhase(TestCase): + def setUp(self): # Get a user to be the creator self.guest1 = User.objects.create(username="apiguest1") @@ -42,9 +45,10 @@ def setUp(self): def create_base_competition(self): title = "Single-phase competition example" description = "This is an example of a single-phase competition." - competition,created = Competition.objects.get_or_create(title=title, creator=self.guest1, modified_by=self.guest1, description=description) - return competition; - + competition, created = Competition.objects.get_or_create( + title=title, creator=self.guest1, modified_by=self.guest1, description=description) + return competition + # Create a 3 phase test def test_three_phase_existance(self): competition = self.create_base_competition() @@ -53,12 +57,13 @@ def test_three_phase_existance(self): day_delta = datetime.timedelta(days=30) phases = [] for phase in [1, 2, 3]: - phase_start = start_date + (day_delta * (phase-2)) - p, created = CompetitionPhase.objects.get_or_create(competition=competition, phasenumber=phase, label="Phase %d" % phase, start_date=phase_start, max_submissions=4) - phases.append(p); - + phase_start = start_date + (day_delta * (phase - 2)) + p, created = CompetitionPhase.objects.get_or_create( + competition=competition, phasenumber=phase, label="Phase %d" % phase, start_date=phase_start, max_submissions=4) + phases.append(p) + self.assertEqual(len(phases), 3) - + # Create three phases, the middle phase should be active def test_three_phase_middle_active(self): competition = self.create_base_competition() @@ -67,32 +72,34 @@ def test_three_phase_middle_active(self): day_delta = datetime.timedelta(days=30) phases = [] for phase in [1, 2, 3]: - phase_start = start_date + (day_delta * (phase-2)) - p, created = CompetitionPhase.objects.get_or_create(competition=competition, phasenumber=phase, label="Phase %d" % phase, - start_date=phase_start, max_submissions=4) - phases.append(p); - + phase_start = start_date + (day_delta * (phase - 2)) + p, created = CompetitionPhase.objects.get_or_create( + competition=competition, phasenumber=phase, label="Phase %d" % phase, + start_date=phase_start, max_submissions=4) + phases.append(p) + self.assertEqual(phases[0].is_active, False) self.assertEqual(phases[1].is_active, True) self.assertEqual(phases[2].is_active, False) - + # Create two phases, the last phase should be active def test_two_phase_last_active(self): competition = self.create_base_competition() # Phases for the competition - day_delta = datetime.timedelta(days = 30) + day_delta = datetime.timedelta(days=30) phases = [] - for phase in [1, 2]: - phase_start = start_date + (day_delta * (phase-2)) - p, created = CompetitionPhase.objects.get_or_create(competition=competition, phasenumber=phase, label="Phase %d" % phase, - start_date=phase_start, max_submissions=4) - phases.append(p); + for phase in [1, 2]: + phase_start = start_date + (day_delta * (phase - 2)) + p, created = CompetitionPhase.objects.get_or_create( + competition=competition, phasenumber=phase, label="Phase %d" % phase, + start_date=phase_start, max_submissions=4) + phases.append(p) print phase_start - self.assertEqual(phases[0].is_active, False); - self.assertEqual(phases[1].is_active, True); - + self.assertEqual(phases[0].is_active, False) + self.assertEqual(phases[1].is_active, True) + # Publish / Unpublish Test # Create a competition # Get the list of competitions (The new one should not be in it, and the new one should have the published flag set to false) diff --git a/codalab/apps/authenz/models.py b/codalab/apps/authenz/models.py index 6f3b424a9..62e958c3e 100644 --- a/codalab/apps/authenz/models.py +++ b/codalab/apps/authenz/models.py @@ -1,11 +1,6 @@ -import re -from django.core import validators -from django.core.mail import send_mail -from django.db import models from django.contrib.auth import models as auth_models -from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ + class ClUser(auth_models.AbstractUser): pass diff --git a/codalab/apps/authenz/tests.py b/codalab/apps/authenz/tests.py index 79dd6e322..3fc0d15d8 100644 --- a/codalab/apps/authenz/tests.py +++ b/codalab/apps/authenz/tests.py @@ -9,6 +9,7 @@ class SimpleTest(TestCase): + def test_basic_addition(self): """ Tests that 1 + 1 always equals 2 (authenz). diff --git a/codalab/apps/web/forms.py b/codalab/apps/web/forms.py index 7d45237c5..8bd21197b 100644 --- a/codalab/apps/web/forms.py +++ b/codalab/apps/web/forms.py @@ -8,12 +8,12 @@ class CompetitionForm(forms.ModelForm): class Meta: model = models.Competition - fields = ['title', 'description', 'image', 'has_registration', 'end_date', 'published'] + fields = ('title', 'description', 'image', 'has_registration', 'end_date', 'published') class CompetitionPhaseForm(forms.ModelForm): class Meta: model = models.CompetitionPhase - fields = ['phasenumber', 'label', 'start_date', 'max_submissions', 'scoring_program', 'reference_data'] + fields = ('phasenumber', 'label', 'start_date', 'max_submissions', 'scoring_program', 'reference_data') class CompetitionDatasetForm(forms.ModelForm): class Meta: diff --git a/codalab/apps/web/management/commands/add_participant.py b/codalab/apps/web/management/commands/add_participant.py index 77297d9e3..f85167066 100644 --- a/codalab/apps/web/management/commands/add_participant.py +++ b/codalab/apps/web/management/commands/add_participant.py @@ -1,9 +1,10 @@ -from django.core.management.base import BaseCommand, CommandError -from apps.web.models import Competition,CompetitionParticipant,ParticipantStatus +from django.core.management.base import BaseCommand +from apps.web.models import Competition, CompetitionParticipant, ParticipantStatus from django.contrib.auth import get_user_model -User = get_user_model() +User = get_user_model() from optparse import make_option + class Command(BaseCommand): help = "Adds a particpant to a competition. If the user does not exist, it will create one." @@ -16,13 +17,15 @@ class Command(BaseCommand): default=None, help="ID of the competition"), make_option('--status', - choices=(ParticipantStatus.UNKNOWN,ParticipantStatus.PENDING,ParticipantStatus.APPROVED,ParticipantStatus.DENIED), + choices=( + ParticipantStatus.UNKNOWN, ParticipantStatus.PENDING, + ParticipantStatus.APPROVED, ParticipantStatus.DENIED), dest='status', default=ParticipantStatus.PENDING, help="The initial status of the created participant" ) - ) - + ) + def handle(self, *args, **options): competition_id = options['competition'] competition = None @@ -30,14 +33,15 @@ def handle(self, *args, **options): print " ... Email Required ... " exit(1) - user,cr = User.objects.get_or_create(email=options['email'], defaults={'username': options['email']}) + user, cr = User.objects.get_or_create( + email=options['email'], defaults={'username': options['email']}) if cr: user.set_password('testing') user.save() print "\nNew User Created. Password: testing\n" while not competition: if competition_id: - try: + try: competition = Competition.objects.get(pk=competition_id) competition_id = competition.pk break @@ -50,7 +54,7 @@ def handle(self, *args, **options): print " ... There are no competitions ..." exit(1) for c in clist: - print " %d) %s" % (c.pk,c.title) + print " %d) %s" % (c.pk, c.title) try: competition_id = int(raw_input("\n Enter number --> ")) except ValueError: @@ -58,13 +62,8 @@ def handle(self, *args, **options): competition_id = None continue pstatus = ParticipantStatus.objects.get(codename=options['status']) - part,cr = CompetitionParticipant.objects.get_or_create(user=user, - competition=competition, - defaults={'status':pstatus}) + part, cr = CompetitionParticipant.objects.get_or_create(user=user, + competition=competition, + defaults={'status': pstatus}) if not cr: print " ... Participant already exists ... " - - - - - diff --git a/codalab/apps/web/management/commands/add_submission.py b/codalab/apps/web/management/commands/add_submission.py index 5e65cc185..c9a8952d4 100644 --- a/codalab/apps/web/management/commands/add_submission.py +++ b/codalab/apps/web/management/commands/add_submission.py @@ -1,11 +1,12 @@ -from django.core.management.base import BaseCommand, CommandError -from apps.web.models import Competition,CompetitionPhase,CompetitionParticipant,CompetitionSubmission +from django.core.management.base import BaseCommand +from apps.web.models import Competition, CompetitionPhase, CompetitionParticipant, CompetitionSubmission from django.contrib.auth import get_user_model -User = 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" @@ -26,8 +27,8 @@ class Command(BaseCommand): default=None, help="Path to the submission file"), - ) - + ) + def handle(self, *args, **options): competition_id = options['competition'] phase_id = options['phase'] @@ -44,14 +45,15 @@ def handle(self, *args, **options): 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) + 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 ..." @@ -59,11 +61,11 @@ def handle(self, *args, **options): sel = [] i = 0 for c in clist: - sel.append((c.competition,c)) + sel.append((c.competition, c)) i = i + 1 - print "%d) %s %s" % (i,c.competition,c) + print "%d) %s %s" % (i, c.competition, c) try: - inp = int(raw_input("\n Enter number --> ")) + inp = int(raw_input("\n Enter number --> ")) idx = inp - 1 competition = sel[idx][0] phase = sel[idx][1] @@ -76,12 +78,8 @@ def handle(self, *args, **options): part = CompetitionParticipant.objects.get(user=user, competition=competition - ) - submission_file = File(open(options['submission'],'rb')) - s = CompetitionSubmission(participant=part, phase=phase, file=submission_file) + ) + submission_file = File(open(options['submission'], 'rb')) + s = CompetitionSubmission( + participant=part, phase=phase, file=submission_file) s.save() - - - - - diff --git a/codalab/apps/web/management/commands/create_competition.py b/codalab/apps/web/management/commands/create_competition.py index 5576054a7..887ae2efc 100644 --- a/codalab/apps/web/management/commands/create_competition.py +++ b/codalab/apps/web/management/commands/create_competition.py @@ -1,17 +1,14 @@ -from django.core.management.base import BaseCommand, CommandError -from django.utils.text import slugify +from django.core.management.base import BaseCommand from django.utils.timezone import utc from django.core.files import File -from apps.web.models import Competition,CompetitionPhase -from django.conf import settings +from apps.web.models import Competition, CompetitionPhase from django.contrib.auth import get_user_model -User = get_user_model() +User = get_user_model() from optparse import make_option -import random import datetime import os -import pytz + class Command(BaseCommand): help = "Creates competition." @@ -22,7 +19,7 @@ class Command(BaseCommand): help="Name ofthe competition"), make_option('--description', dest='description', - help="Description of the competition"), + help="Description of the competition"), make_option('--creator', dest='creator', help="Email address of creator"), @@ -31,7 +28,7 @@ class Command(BaseCommand): help="The file of the logo for the competition"), make_option('--force_user_create', dest='create_user', - action='store_true',default=False, + action='store_true', default=False, help="Create user if non existant" ), make_option('--numphases', @@ -39,19 +36,19 @@ class Command(BaseCommand): default=0, type="int", help="Number of phases to create" - ), + ), make_option('--phasedates', dest='phasedates', type='string', default=None, help="Comma-seprated list of the startdates of the phases: YYYY-MM-DD,YYYY-MM-DD" ) - ) + ) def handle(self, *args, **options): print " ----- " print "Creating competition" - + creator_email = options['creator'] title = options['title'] description = options['description'] @@ -59,15 +56,15 @@ def handle(self, *args, **options): phasedates = [] try: for d in options['phasedates'].split(','): - phasedates.append(datetime.datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=utc)) + phasedates.append( + datetime.datetime.strptime(d, "%Y-%m-%d").replace(tzinfo=utc)) if len(phasedates) != numphases: raise Exception("Not enough dates for phases") - + except AttributeError as e: if numphases > 0: raise e - pass - + if not creator_email or not title or not description: print "Need a title, description and email of creator" exit(1) @@ -85,7 +82,7 @@ def handle(self, *args, **options): raise e if options['logo']: try: - f = open(os.path.expanduser(options['logo']),'rb') + f = open(os.path.expanduser(options['logo']), 'rb') except IOError as e: raise e else: @@ -95,16 +92,14 @@ def handle(self, *args, **options): modified_by=creator, description=description) if f: - competition.image=File(f) + competition.image = File(f) competition.save() - for n in range(0,numphases): - p = CompetitionPhase.objects.create(competition=competition, - phasenumber=n, - label = "Phase #%d" % n, - start_date=phasedates[n]) + for n in range(0, numphases): + CompetitionPhase.objects.create(competition=competition, + phasenumber=n, + label="Phase #%d" % n, + start_date=phasedates[n]) print "Created %d phases" % numphases print " ----- " - print "Competition, %s, created. ID: %d" % (competition.title,competition.pk) + print "Competition, %s, created. ID: %d" % (competition.title, competition.pk) print " ----- " - - diff --git a/codalab/apps/web/management/commands/random_competitions.py b/codalab/apps/web/management/commands/random_competitions.py index a04d139c3..598fc2c77 100644 --- a/codalab/apps/web/management/commands/random_competitions.py +++ b/codalab/apps/web/management/commands/random_competitions.py @@ -1,15 +1,15 @@ -from django.core.management.base import BaseCommand, CommandError +from django.core.management.base import BaseCommand from django.utils.text import slugify from django.contrib.auth.models import User -from apps.web.models import Competition,CompetitionPhase,CompetitionDataset,CompetitionParticipant,ExternalFile,ExternalFileType,ParticipantStatus +from apps.web.models import Competition, CompetitionPhase, CompetitionDataset, CompetitionParticipant, ExternalFile, ExternalFileType, ParticipantStatus from optparse import make_option -import random import datetime import pytz + class Command(BaseCommand): help = "Creates test competition." @@ -17,83 +17,90 @@ class Command(BaseCommand): make_option('--name', dest='name', help="Name ofthe competition"), - make_option('--email', + make_option('--email', dest='email', help="Email address of user. Will create if doesnt exist"), - make_option('--number', + make_option('--number', dest='number', - type = 'int', + type='int', help="Number of competitions to create"), - make_option('--participant', + make_option('--participant', dest='participant', help="Participant name prefix. participant2@test.com"), - make_option('--participant_count', + make_option('--participant_count', dest='participant_count', type='int', default=2, help="Number of participants."), make_option('--participant_status', - choices=(ParticipantStatus.UNKNOWN,ParticipantStatus.PENDING,ParticipantStatus.APPROVED,ParticipantStatus.DENIED), + choices=( + ParticipantStatus.UNKNOWN, ParticipantStatus.PENDING, + ParticipantStatus.APPROVED, ParticipantStatus.DENIED), dest='participant_status', default=ParticipantStatus.PENDING, help="The initial status of the created participants" ) - ) - def handle(self,*args,**options): - for count in range(1,options['number']+1): - u,cr = User.objects.get_or_create(email=options['email'], - defaults={'username': options['email']} - ) + ) + + def handle(self, *args, **options): + for count in range(1, options['number'] + 1): + u, cr = User.objects.get_or_create(email=options['email'], + defaults={'username': + options['email']} + ) if cr: u.set_password('testing') u.save() print "Pasword for user is: testing" - competition_name = "%s %d" % (options['name'],count) + competition_name = "%s %d" % (options['name'], count) c = Competition.objects.create(title=competition_name, - description="This is the description for competition %s" % options['name'], - creator = u, - modified_by = u) - pstatus = ParticipantStatus.objects.get(codename=options['participant_status']) - for i in range(1,options['participant_count']+1): - pname = "%s%d" % (options['participant'],options['participant_count']) - - pu,cr = User.objects.get_or_create(username=pname, - email="%s@test.com" % pname) + description="This is the description for competition %s" % options[ + 'name'], + creator=u, + modified_by=u) + pstatus = ParticipantStatus.objects.get( + codename=options['participant_status']) + for i in range(1, options['participant_count'] + 1): + pname = "%s%d" % ( + options['participant'], options['participant_count']) + + pu, cr = User.objects.get_or_create(username=pname, + email="%s@test.com" % pname) if cr: pu.set_password('testing') pu.save() - - part,cr = CompetitionParticipant.objects.get_or_create(competition=c, - user=pu, - defaults={ - 'status': pstatus}) + + part, cr = CompetitionParticipant.objects.get_or_create( + competition=c, + user=pu, + defaults={ + 'status': pstatus}) if cr: - part.status=pstatus + part.status = pstatus part.save() - delta = datetime.timedelta(days = 0) + delta = datetime.timedelta(days=0) ftype = ExternalFileType.objects.get(codename='test') - for i in range(1,3): + for i in range(1, 3): - start_date = datetime.datetime.now( pytz.utc) + delta + start_date = datetime.datetime.now(pytz.utc) + delta f = ExternalFile.objects.create(type=ftype, - source_url = "http://test.com/test/%s" % slugify("%s%d" % (unicode(competition_name),i)) , - source_address_info = "SPECIFIC_INFO", - creator = u) + source_url="http://test.com/test/%s" % slugify("%s%d" % + (unicode(competition_name), i)), + source_address_info="SPECIFIC_INFO", + creator=u) d = CompetitionDataset.objects.create(competition=c, number=i, - datafile = f) - - p = CompetitionPhase.objects.create(competition=c, - phasenumber=i, - label="Phase %d" % i, - start_date=start_date, - max_submissions=4, - dataset = d) + datafile=f) - delta = datetime.timedelta(days = 10) + CompetitionPhase.objects.create(competition=c, + phasenumber=i, + label="Phase %d" % i, + start_date=start_date, + max_submissions=4, + dataset=d) - + delta = datetime.timedelta(days=10) diff --git a/codalab/apps/web/static/css/Main.css b/codalab/apps/web/static/css/Main.css index d6f2fad6e..a5ee76078 100644 --- a/codalab/apps/web/static/css/Main.css +++ b/codalab/apps/web/static/css/Main.css @@ -2343,7 +2343,7 @@ ul.leftNavigation li.active a{ height:18px; width:18px; display:inline-block; - margin-top:5px; + margin: 5px 0 5px 0; } .helpLinkIcon:hover { background: url('../img/helpicon.png') no-repeat center center; @@ -2489,10 +2489,14 @@ div.auto.section-container > section > .title a, .auto.section-container > .sect font-family: 'Segoe Light', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-weight: 100; font-size: 1.3em; - padding: 1em 0 .3em 0; + padding: 0; cursor: default; display: inline-block; } + +#edit_competition .fieldWrapper { + margin-bottom: 5px; +} #edit_competition input, #edit_competition textarea, #edit_competition p { color: #666; font-size: 1em; diff --git a/codalab/apps/web/static/css/codalab.css b/codalab/apps/web/static/css/codalab.css index 82722cc0c..6c3fa22b9 100644 --- a/codalab/apps/web/static/css/codalab.css +++ b/codalab/apps/web/static/css/codalab.css @@ -1,4 +1,4 @@ -/* line 17, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 17, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, @@ -20,45 +20,45 @@ time, mark, audio, video { vertical-align: baseline; } -/* line 22, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 22, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ html { line-height: 1; } -/* line 24, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 24, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ ol, ul { list-style: none; } -/* line 26, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 26, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ table { border-collapse: collapse; border-spacing: 0; } -/* line 28, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 28, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; } -/* line 30, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 30, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q, blockquote { quotes: none; } -/* line 103, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 103, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q:before, q:after, blockquote:before, blockquote:after { content: ""; content: none; } -/* line 32, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 32, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ a img { border: none; } -/* line 116, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 116, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary { display: block; } @@ -7647,12 +7647,12 @@ a.th { max-width: 800px; } -/* line 10, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ +/* line 10, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ html, body { height: 100%; } -/* line 12, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ +/* line 12, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ #layout { clear: both; min-height: 100%; @@ -7660,12 +7660,12 @@ html, body { height: 100%; margin-bottom: -25px; } -/* line 18, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ +/* line 18, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ #layout #layout_footer { height: 25px; } -/* line 20, C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ +/* line 20, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/layout/_sticky-footer.scss */ #footer { clear: both; position: relative; diff --git a/codalab/apps/web/static/css/screen.css b/codalab/apps/web/static/css/screen.css index 38d7107a2..5124fc3f4 100644 --- a/codalab/apps/web/static/css/screen.css +++ b/codalab/apps/web/static/css/screen.css @@ -2,7 +2,7 @@ * In this file you should write your main styles. (or centralize your imports) * Import this file using the following HTML or equivalent: * */ -/* line 17, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 17, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, @@ -24,45 +24,45 @@ time, mark, audio, video { vertical-align: baseline; } -/* line 22, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 22, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ html { line-height: 1; } -/* line 24, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 24, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ ol, ul { list-style: none; } -/* line 26, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 26, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ table { border-collapse: collapse; border-spacing: 0; } -/* line 28, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 28, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ caption, th, td { text-align: left; font-weight: normal; vertical-align: middle; } -/* line 30, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 30, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q, blockquote { quotes: none; } -/* line 103, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 103, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ q:before, q:after, blockquote:before, blockquote:after { content: ""; content: none; } -/* line 32, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 32, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ a img { border: none; } -/* line 116, ../../../../../../../../../Library/Ruby/Gems/1.8/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ +/* line 116, ../../../../../../../Ruby193/lib/ruby/gems/1.9.1/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/reset/_utilities.scss */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary { display: block; } diff --git a/codalab/apps/web/static/js/Competition.js b/codalab/apps/web/static/js/Competition.js index 552f79d75..6fc58ed50 100644 --- a/codalab/apps/web/static/js/Competition.js +++ b/codalab/apps/web/static/js/Competition.js @@ -194,7 +194,6 @@ var Competition; console.log(data); if (data['status'] == "approved") { location.reload(); - console.log("Approved, figuing out how to update the div."); } else if (data['status'] == "pending") { sOut = "
" sOut += "
" diff --git a/codalab/apps/web/templates/web/competitions/edit.html b/codalab/apps/web/templates/web/competitions/edit.html index c8e6f5bca..795b1de61 100644 --- a/codalab/apps/web/templates/web/competitions/edit.html +++ b/codalab/apps/web/templates/web/competitions/edit.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} {% load staticfiles %} +{% load codalab %} {% block head_title %}Edit Competition{% endblock head_title %} {% block page_title %}Edit Competition{% endblock page_title %} @@ -18,10 +19,40 @@
{% csrf_token %} - {{ form.as_p }} -
+ {% for field in form %} +
+
+ {{ field.errors }} +
+ +
+
+ {{ field }} +
+
+
+ {% endfor %} +
{% for formset in inlines %} - {{ formset.as_p }} + {% for iform in formset %} +
+ {% for ifield in iform %} +
+
+ {{ ifield.errors }} +
+ {% if not ifield.is_hidden %} + + {% endif %} +
+
+ {{ ifield }} +
+
+
+ {% endfor %} +
+ {% endfor %} {% endfor %}
diff --git a/codalab/apps/web/templatetags/codalab.py b/codalab/apps/web/templatetags/codalab.py index 28515a5b4..b01009fe6 100644 --- a/codalab/apps/web/templatetags/codalab.py +++ b/codalab/apps/web/templatetags/codalab.py @@ -3,11 +3,14 @@ register = template.Library() + @register.filter def filename(value): return os.path.basename(value.file.name) # by mikeivanov (on April 16, 2007) + + @register.filter -def in_list(value,arg): - return value in arg \ No newline at end of file +def in_list(value, arg): + return value in arg diff --git a/codalab/apps/web/tests.py b/codalab/apps/web/tests.py index 6991ef5ee..bac4b99d0 100644 --- a/codalab/apps/web/tests.py +++ b/codalab/apps/web/tests.py @@ -2,12 +2,10 @@ """ Tests for Codalab functionality. """ -import os import json from django.conf import settings from django.core import management -from django.core.urlresolvers import reverse from django.test import TestCase from django.test.client import Client @@ -16,69 +14,76 @@ from apps.web.models import Competition, ParticipantStatus, CompetitionParticipant, CompetitionPhase -User = get_user_model() +User = get_user_model() + class Competitions(TestCase): + def setUp(self): - self.user = User.objects.create(email='test@user.com',username='testuser') - ParticipantStatus.objects.get_or_create(name='Pending',codename=ParticipantStatus.PENDING) + self.user = User.objects.create( + email='test@user.com', username='testuser') + ParticipantStatus.objects.get_or_create( + name='Pending', codename=ParticipantStatus.PENDING) self.test_data_path = settings.TEST_DATA_PATH - management.call_command('create_competition', title='Test Title', description='Test Description',creator=self.user.email) + management.call_command('create_competition', title='Test Title', + description='Test Description', creator=self.user.email) self.competitions = [x.id for x in Competition.objects.all()] def test_add_participant(self): """ Add a participant to a competition. """ - management.call_command('add_participant', email='user1@test.com', competition=self.competitions[0]) - p = CompetitionParticipant.objects.get(user__email='user1@test.com',competition_id=self.competitions[0]) + management.call_command( + 'add_participant', email='user1@test.com', competition=self.competitions[0]) + p = CompetitionParticipant.objects.get( + user__email='user1@test.com', competition_id=self.competitions[0]) assert(p.competition_id == self.competitions[0]) def test_create_competition_api(self): """ Create a competition programmatically. - TODO: Does not authenticate (YET) + TODO: Does not authenticate (YET) """ client = Client() res = client.post('/api/competition/', {'title': 'Test Title', - 'description': 'Description', - 'creator': self.user.pk, - 'modified_by': self.user.pk, - }) + 'description': 'Description', + 'creator': self.user.pk, + 'modified_by': self.user.pk, + }) # Status 201: Created - self.assertEqual(int(res.status_code),int(201)) + self.assertEqual(int(res.status_code), int(201)) data = json.loads(res.content) - + # Just checking to make sure the data was returned correctly self.assertTrue('id' in data and data['id'] >= 1) - + def test_get_competition_api(self): """ Create a competition programmatically. - TODO: Does not authenticate (YET) + TODO: Does not authenticate (YET) """ client = Client() res = client.post('/api/competition/', {'title': 'Test Title', - 'description': 'Description', - 'creator': self.user.pk, - 'modified_by': self.user.pk, - }) + 'description': 'Description', + 'creator': self.user.pk, + 'modified_by': self.user.pk, + }) data = json.loads(res.content) - - #get competition id - res = client.get('/api/competition/'+ str(data['id'])+'/') + + # get competition id + res = client.get('/api/competition/' + str(data['id']) + '/') data = json.loads(res.content) self.assertEqual(data['title'], 'Test Title') self.assertEqual(data['description'], 'Description') self.assertEqual(data['creator'], self.user.pk) self.assertEqual(data['modified_by'], self.user.pk) - #def test_delete_competition_api(self): - + # def test_delete_competition_api(self): + # client = Client() - - # #create a competition + + # create a competition # res = client.post('/api/competition/', {'title': 'Test Title', # 'description': 'Description', # 'creator': self.user.pk, @@ -86,47 +91,46 @@ def test_get_competition_api(self): # }) # create_data = json.loads(res.content) - # #delete a competition + # delete a competition # res = client.delete('/api/competition/'+ str(create_data['id'])+'/') # delete_data = json.loads(res.content) - # #try to access the deleted comp + # try to access the deleted comp # res = client.get('/api/competition/'+ delete_data + '/') # self.assertEqual(int(res.status_code), int(404)) - #def test_delete_one_from_two_competitions_api(self): - + # def test_delete_one_from_two_competitions_api(self): + # client = Client() - - # #create a competition + + # create a competition # res = client.post('/api/competition/', {'title': 'Test Title 1', # 'description': 'Description', # 'creator': self.user.pk, # 'modified_by': self.user.pk, - # }) + # }) # create_data1 = json.loads(res.content) - - # #create another + + # create another # res = client.post('/api/competition/', {'title': 'Test Title 2', # 'description': 'Description', # 'creator': self.user.pk, # 'modified_by': self.user.pk, # }) - + # create_data2 = json.loads(res.content) - - - # #delete first competition + + + # delete first competition # res = client.delete('/api/competition/'+ str(create_data1['id'])+'/') # delete_data = json.loads(res.content) - - - # #try to access the deleted comp - # res = client.get('/api/competition/'+ str(create_data1['id'])+'/') - # self.assertEqual(int(res.status_code), int(404)) -class CompetitionPhaseTests(TestCase): + # try to access the deleted comp + # res = client.get('/api/competition/'+ str(create_data1['id'])+'/') + # self.assertEqual(int(res.status_code), int(404)) + +class CompetitionPhaseTests(TestCase): def validate(self, ids, expected_ranks, actual_ranks): self.assertEqual(len(ids), len(expected_ranks)) @@ -137,80 +141,89 @@ def validate(self, ids, expected_ranks, actual_ranks): def test_rank_values_1(self): ids = {"a", "b", "d", "f", "e"} input = {} - expected = {"a": 1, "b" : 1, "d" : 1, "f" : 1, "e" : 1 } + expected = {"a": 1, "b": 1, "d": 1, "f": 1, "e": 1} self.validate(ids, expected, CompetitionPhase.rank_values(ids, input)) def test_rank_values_2(self): ids = {"a", "b", "d", "f", "e"} input = {} - expected = {"a": 1, "b" : 1, "d" : 1, "f" : 1, "e" : 1 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + expected = {"a": 1, "b": 1, "d": 1, "f": 1, "e": 1} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_rank_values_3(self): ids = {"a", "b", "d", "f", "e"} input = {"d": 1.0} - expected = {"a": 2, "b" : 2, "d" : 1, "f" : 2, "e" : 2 } + expected = {"a": 2, "b": 2, "d": 1, "f": 2, "e": 2} self.validate(ids, expected, CompetitionPhase.rank_values(ids, input)) def test_rank_values_4(self): ids = {"a", "b", "d", "f", "e"} input = {"d": 1.0} - expected = {"a": 2, "b" : 2, "d" : 1, "f" : 2, "e" : 2 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + expected = {"a": 2, "b": 2, "d": 1, "f": 2, "e": 2} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_rank_values_5(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":4.0} - expected = {"a": 2, "b" : 3, "d" : 3, "f" : 3, "e" : 1 } + input = {"e": 1.0, "a": 4.0} + expected = {"a": 2, "b": 3, "d": 3, "f": 3, "e": 1} self.validate(ids, expected, CompetitionPhase.rank_values(ids, input)) def test_rank_values_6(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":4.0} - expected = {"a": 1, "b" : 3, "d" : 3, "f" : 3, "e" : 2 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + input = {"e": 1.0, "a": 4.0} + expected = {"a": 1, "b": 3, "d": 3, "f": 3, "e": 2} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_rank_values_7(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":1.0} - expected = {"a": 1, "b" : 2, "d" : 2, "f" : 2, "e" : 1 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + input = {"e": 1.0, "a": 1.0} + expected = {"a": 1, "b": 2, "d": 2, "f": 2, "e": 1} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_rank_values_8(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":1.001} - expected = {"a": 1, "b" : 2, "d" : 2, "f" : 2, "e" : 1 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False, eps=0.01)) + input = {"e": 1.0, "a": 1.001} + expected = {"a": 1, "b": 2, "d": 2, "f": 2, "e": 1} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False, eps=0.01)) def test_rank_values_9(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":1.001} - expected = {"a": 1, "b" : 2, "d" : 2, "f" : 2, "e" : 1 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=True, eps=0.01)) + input = {"e": 1.0, "a": 1.001} + expected = {"a": 1, "b": 2, "d": 2, "f": 2, "e": 1} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=True, eps=0.01)) def test_rank_values_10(self): ids = {"a", "b", "d", "f", "e"} input = {"e": 1.0, "a": 1.001} - expected = {"a": 2, "b" : 3, "d" : 3, "f" : 3, "e" : 1 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=True)) + expected = {"a": 2, "b": 3, "d": 3, "f": 3, "e": 1} + self.validate(ids, expected, + CompetitionPhase.rank_values(ids, input, sort_ascending=True)) def test_rank_values_11(self): ids = {"a", "b", "d", "f", "e"} - input = {"e": 1.0, "a":1.001} - expected = {"a": 1, "b" : 3, "d" : 3, "f" : 3, "e" : 2 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + input = {"e": 1.0, "a": 1.001} + expected = {"a": 1, "b": 3, "d": 3, "f": 3, "e": 2} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_rank_values_12(self): ids = {"a", "b", "d", "f", "e"} - input = {"a": 4.0, "b" : 2.0, "d" : 5.0, "f" : 3.0, "e" : 1.0} - expected = {"a": 4, "b" : 2, "d" : 5, "f" : 3, "e" : 1 } + input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0} + expected = {"a": 4, "b": 2, "d": 5, "f": 3, "e": 1} self.validate(ids, expected, CompetitionPhase.rank_values(ids, input)) def test_rank_values_14(self): ids = {"a", "b", "d", "f", "e"} - input = {"a": 4.0, "b" : 2.0, "d" : 5.0, "f" : 3.0, "e" : 1.0} - expected = {"a": 2, "b" : 4, "d" : 1, "f" : 3, "e" : 5 } - self.validate(ids, expected, CompetitionPhase.rank_values(ids, input, sort_ascending=False)) + input = {"a": 4.0, "b": 2.0, "d": 5.0, "f": 3.0, "e": 1.0} + expected = {"a": 2, "b": 4, "d": 1, "f": 3, "e": 5} + self.validate(ids, expected, CompetitionPhase.rank_values( + ids, input, sort_ascending=False)) def test_format_values(self): x = 0.12834956 @@ -223,7 +236,8 @@ def test_format_values(self): self.assertEqual("0.13", CompetitionPhase.format_value(x)) self.assertEqual("0.1", CompetitionPhase.format_value(x, "0")) - self.assertEqual("0.1283495600", CompetitionPhase.format_value(x, "20")) + self.assertEqual("0.1283495600", + CompetitionPhase.format_value(x, "20")) self.assertEqual("0.1", CompetitionPhase.format_value(x, "-2")) self.assertEqual("0.1", CompetitionPhase.format_value(x, "2.13")) diff --git a/codalab/apps/web/urls/__init__.py b/codalab/apps/web/urls/__init__.py index 130c3e58f..e49d9b9dd 100644 --- a/codalab/apps/web/urls/__init__.py +++ b/codalab/apps/web/urls/__init__.py @@ -1 +1,15 @@ -from base import urlpatterns +from django.conf.urls import patterns, include, url +from django.views.generic import TemplateView + +from .. import views + +urlpatterns = patterns('', + url(r'^$', TemplateView.as_view(template_name='web/index.html'), name='home'), + url(r'^_ver', views.VersionView.as_view(),name='_version'), + url(r'^my/', include('apps.web.urls.my')), + url(r'^competitions/', include('apps.web.urls.competitions', namespace="competitions")), + url(r'^experiments/', include('apps.web.urls.experiments')), + url(r'^about/', TemplateView.as_view(template_name='web/help/about.html'), name='about'), + url(r'^help/', include('apps.web.urls.help')), + url(r'^bundles/', include('apps.web.urls.bundles')), +) diff --git a/codalab/apps/web/urls/base.py b/codalab/apps/web/urls/base.py deleted file mode 100644 index e49d9b9dd..000000000 --- a/codalab/apps/web/urls/base.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.conf.urls import patterns, include, url -from django.views.generic import TemplateView - -from .. import views - -urlpatterns = patterns('', - url(r'^$', TemplateView.as_view(template_name='web/index.html'), name='home'), - url(r'^_ver', views.VersionView.as_view(),name='_version'), - url(r'^my/', include('apps.web.urls.my')), - url(r'^competitions/', include('apps.web.urls.competitions', namespace="competitions")), - url(r'^experiments/', include('apps.web.urls.experiments')), - url(r'^about/', TemplateView.as_view(template_name='web/help/about.html'), name='about'), - url(r'^help/', include('apps.web.urls.help')), - url(r'^bundles/', include('apps.web.urls.bundles')), -) diff --git a/codalab/apps/web/urls/experiments.py b/codalab/apps/web/urls/experiments.py index daa93fd69..4ef891600 100644 --- a/codalab/apps/web/urls/experiments.py +++ b/codalab/apps/web/urls/experiments.py @@ -1,8 +1,8 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import patterns +from django.conf.urls import url from django.views.generic import TemplateView -from .. import views - urlpatterns = patterns('', - url(r'^$', TemplateView.as_view(template_name='web/experiments/index.html'), name='worksheets'), - ) + url(r'^$', TemplateView.as_view(template_name='web/experiments/index.html'), + name='worksheets'), +) diff --git a/codalab/apps/web/urls/my.py b/codalab/apps/web/urls/my.py index b834fc63e..830484c06 100644 --- a/codalab/apps/web/urls/my.py +++ b/codalab/apps/web/urls/my.py @@ -1,24 +1,29 @@ from django.conf.urls import patterns, include, url -from django.views.generic import TemplateView from django.contrib.auth.decorators import login_required from apps.web import views partials_patterns = patterns( '', - url(r'^_competitions_managed$', login_required(views.MyCompetitionsManagedPartial.as_view()), + url(r'^_competitions_managed$', + login_required(views.MyCompetitionsManagedPartial.as_view()), name='my_competitions_managed'), - url(r'^_competitions_entered$', login_required(views.MyCompetitionsEnteredPartial.as_view()), + url(r'^_competitions_entered$', + login_required(views.MyCompetitionsEnteredPartial.as_view()), name='my_competitions_entered'), - url(r'^(?P\d+)/(?P\d+)/_submission_results', login_required(views.MySubmissionResultsPartial.as_view()),name='my_competition_submissions'), - ) + url(r'^(?P\d+)/(?P\d+)/_submission_results', + login_required(views.MySubmissionResultsPartial.as_view()), + name='my_competition_submissions'), +) urlpatterns = patterns( '', url(r'^$', views.my_index, name='competitions'), - url(r'^competition/(?P\d+)/participants/', views.MyCompetitionParticipantView.as_view(), name='my_competition_participants'), - url(r'^competition/submission/(?P\d+)/(?Pstdout.txt|stderr.txt|output.zip)$', views.MyCompetitionSubmisisonOutput.as_view(),name='my_competition_output'), + url(r'^competition/(?P\d+)/participants/', + views.MyCompetitionParticipantView.as_view(), + name='my_competition_participants'), + url(r'^competition/submission/(?P\d+)/(?Pstdout.txt|stderr.txt|output.zip)$', + views.MyCompetitionSubmisisonOutput.as_view(), + name='my_competition_output'), url(r'^_partials/', include(partials_patterns)), - - ) - +) diff --git a/codalab/codalab/context_processors.py b/codalab/codalab/context_processors.py index 0d94c899d..bf4e50147 100644 --- a/codalab/codalab/context_processors.py +++ b/codalab/codalab/context_processors.py @@ -1,8 +1,9 @@ from django.conf import settings + def app_version_proc(request): "A context processor that provides 'app_version'." return { 'app_version': settings.CODALAB_VERSION, 'last_commit': settings.CODALAB_LAST_COMMIT - } \ No newline at end of file + } diff --git a/codalab/codalab/settings/default.py b/codalab/codalab/settings/default.py index 851f2db2a..7fcbf60c2 100644 --- a/codalab/codalab/settings/default.py +++ b/codalab/codalab/settings/default.py @@ -1,8 +1,7 @@ from .base import DevBase -import os __all__ = ['Dev'] -class Dev(DevBase): - pass +class Dev(DevBase): + pass diff --git a/codalab/codalab/wsgi.py b/codalab/codalab/wsgi.py index 505ff4728..106d21d5b 100644 --- a/codalab/codalab/wsgi.py +++ b/codalab/codalab/wsgi.py @@ -21,7 +21,8 @@ # os.environ["DJANGO_SETTINGS_MODULE"] = "codalab.settings" os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codalab.settings") os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev') -os.environ.setdefault('DJANGO_LOCAL_CONFIGURATION', 'codalab.settings.local_environment') +os.environ.setdefault('DJANGO_LOCAL_CONFIGURATION', + 'codalab.settings.local_environment') from configurations.wsgi import get_wsgi_application diff --git a/codalab/codalabtools/__init__.py b/codalab/codalabtools/__init__.py index 190ba08d9..0e1555696 100644 --- a/codalab/codalabtools/__init__.py +++ b/codalab/codalabtools/__init__.py @@ -18,10 +18,7 @@ def __init__(self, filename='.codalabconfig'): self._filename = os.path.join(os.getcwd(), filename) paths_searched.append(self._filename) if not os.path.exists(self._filename): - if os.environ.has_key("USERPROFILE"): - self._filename = os.path.join(os.environ["USERPROFILE"], filename) - elif os.environ.has_key("HOME"): - self._filename = os.path.join(os.environ["HOME"], filename) + self._filename = os.path.join(os.path.expanduser("~"), filename) paths_searched.append(self._filename) if not os.path.exists(self._filename): msg = "Config file not found. Searched for:\n" + "\n".join(paths_searched) diff --git a/codalab/codalabtools/deploy/fabfile.py b/codalab/codalabtools/deploy/fabfile.py index d4e54a972..a66eb5c77 100644 --- a/codalab/codalabtools/deploy/fabfile.py +++ b/codalab/codalabtools/deploy/fabfile.py @@ -88,8 +88,12 @@ def config(label=None): """ env.cfg_label = label print "Deployment label is: ", env.cfg_label + filename = ".codalabconfig" if 'cfg_path' not in env: - env.cfg_path = os.path.join(os.environ['HOME'], '.codalabconfig') + if os.path.exists(filename): + env.cfg_path = os.path.join(os.getcwd(), filename) + elif os.path.exists(env.cfg_path): + env.cfg_path = os.path.join(os.path.expanduser("~"), filename) print "Loading configuration from: ", env.cfg_path configuration = DeploymentConfig(label, env.cfg_path) print "Configuring logger..." @@ -138,7 +142,8 @@ def provision_web(): Installs required software packages on a newly provisioned web instance. """ packages = ('language-pack-en python2.7 python-setuptools libmysqlclient18 ' + - 'libpcre3 libjpeg8 libpng3 nginx supervisor git') + 'libpcre3 libjpeg8 libpng3 nginx supervisor git python2.7-dev ' + + 'libmysqlclient-dev mysql-client-core-5.5 uwsgi-plugin-python') provision_packages(packages) @task @@ -204,14 +209,14 @@ def build(): """ require('configuration') - pip_cache_dir = os.path.join('builds', 'pip_cache') - if not exists(pip_cache_dir): - run('mkdir -p %s' % pip_cache_dir) - with cd(pip_cache_dir): - pip_download_cache = run('pwd') + #pip_cache_dir = "/".join(['builds', 'pip_cache']) + #if not exists(pip_cache_dir): + # run('mkdir -p %s' % pip_cache_dir) + #with cd(pip_cache_dir): + # pip_download_cache = run('pwd') - build_dir = os.path.join('builds', env.git_user, env.git_repo) - src_dir = os.path.join(build_dir, env.git_tag) + build_dir = "/".join(['builds', env.git_user, env.git_repo]) + src_dir = "/".join([build_dir, env.git_tag]) if exists(src_dir): run('rm -rf %s' % (src_dir.rstrip('/'))) with settings(warn_only=True): @@ -223,13 +228,13 @@ def build(): dep = Deployment(configuration) buf = StringIO() buf.write(dep.getSettingsFileContent()) - settings_file = os.path.join('codalab', 'codalab', 'settings', 'local.py') + settings_file = "/".join(['codalab', 'codalab', 'settings', 'local.py']) put(buf, settings_file) - wheel_dir = os.path.join(src_dir, 'wheel_packages') - requirements_dir = os.path.join(src_dir, 'codalab', 'requirements') - run('pip wheel --download-cache %s --wheel-dir=%s -r %s/dev_azure_nix.txt' % (pip_download_cache, - wheel_dir, - requirements_dir)) + wheel_dir = "/".join([src_dir, 'wheel_packages']) + requirements_dir = "/".join([src_dir, 'codalab', 'requirements']) + #run('pip wheel --download-cache %s --wheel-dir=%s -r %s/dev_azure_nix.txt' % (pip_download_cache, + # wheel_dir, + # requirements_dir)) with cd(build_dir): run('rm -f %s' % env.build_archive) run('tar -cvf - %s | gzip -9 -c > %s' % (env.git_tag, env.build_archive)) @@ -241,7 +246,7 @@ def push_build(): Pushes the output of the build task to the instances where the build artifacts will be installed. """ require('configuration') - build_dir = os.path.join('builds', env.git_user, env.git_repo) + build_dir = "/".join(['builds', env.git_user, env.git_repo]) with cd(build_dir): for host in env.roledefs['web']: parts = host.split(':', 1) @@ -266,10 +271,12 @@ def deploy_web(): DJANGO_CONFIGURATION=env.django_configuration, CONFIG_HTTP_PORT=env.config_http_port, CONFIG_SERVER_NAME=env.config_server_name) + print env.SHELL_ENV with cd(env.deploy_dir): with prefix('source /usr/local/bin/virtualenvwrapper.sh && workon venv'), shell_env(**env.SHELL_ENV): - requirements_path = os.path.join('codalab', 'requirements', 'dev_azure_nix.txt') - pip_cmd = 'pip install --use-wheel --no-index --find-links=wheel_packages -r {0}'.format(requirements_path) + requirements_path = "/".join(['codalab', 'requirements', 'dev_azure_nix.txt']) + #pip_cmd = 'pip install --use-wheel --no-index --find-links=wheel_packages -r {0}'.format(requirements_path) + pip_cmd = 'pip install -r {0}'.format(requirements_path) run(pip_cmd) with cd('codalab'): run('python manage.py config_gen') diff --git a/codalab/manage.py b/codalab/manage.py index 1e03fc163..292f9ecce 100644 --- a/codalab/manage.py +++ b/codalab/manage.py @@ -4,7 +4,7 @@ if __name__ == "__main__": - + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "codalab.settings") os.environ.setdefault('DJANGO_CONFIGURATION', 'Dev') diff --git a/codalab/requirements/common.txt b/codalab/requirements/common.txt index dc852d3b9..d0cdf782a 100644 --- a/codalab/requirements/common.txt +++ b/codalab/requirements/common.txt @@ -1,10 +1,10 @@ Django==1.5.4 pytz==2013b argparse +django-configurations django-allauth==0.11.1 django-compressor==1.3 django-config-gen==1.0.8 -django-configurations django-extensions>=1.1.1 django-guardian==1.1.1 django-js-reverse>=0.2.0 @@ -25,6 +25,5 @@ anyjson==0.3.3 django-appconf==0.6 pyyaml azure==0.7.1 -django-jenkins==0.14.0 django-debug-toolbar==0.9.4 django-nose diff --git a/codalab/requirements/jenkins.txt b/codalab/requirements/jenkins.txt deleted file mode 100644 index 7f93ef11e..000000000 --- a/codalab/requirements/jenkins.txt +++ /dev/null @@ -1,2 +0,0 @@ -django-jenkins -nosexcover diff --git a/codalab/scripts/bootstrap.py b/codalab/scripts/bootstrap.py index e09fb1c91..3278c01d5 100644 --- a/codalab/scripts/bootstrap.py +++ b/codalab/scripts/bootstrap.py @@ -1,14 +1,15 @@ -import os, argparse +import os +import argparse - - -argparser = argparse.ArgumentParser(description='Bootstrap for codalab project') -argparser.add_argument('-v','--venv', help='Virtual Environment Name',required=True) -args = argparser.parse_args() +argparser = argparse.ArgumentParser( + description='Bootstrap for codalab project') +argparser.add_argument( + '-v', '--venv', help='Virtual Environment Name', required=True) +args = argparser.parse_args() VENV_BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -VENV_PATH = os.path.join(VENV_BASE_PATH,args.venv) +VENV_PATH = os.path.join(VENV_BASE_PATH, args.venv) print VENV_BASE_PATH print VENV_PATH @@ -18,4 +19,3 @@ if not os.path.exists(VENV_PATH): print("%s does not exist" % VENV_PATH) - diff --git a/codalab/scripts/competition-modify.py b/codalab/scripts/competition-modify.py index e88ac15a1..403eb4aff 100644 --- a/codalab/scripts/competition-modify.py +++ b/codalab/scripts/competition-modify.py @@ -1,11 +1,13 @@ #!/usr/bin/env python # Run this with the python from the CodaLab virtual environment -# +# -import sys, os.path, os, random, datetime -from django.utils import timezone +import sys +import os.path +import os -root_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") +root_dir = os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") sys.path.append(root_dir) # Set things for django configurations @@ -16,13 +18,9 @@ from configurations import importer importer.install() -from django.contrib.sites.models import Site -from django.core.files import File from apps.web.models import * -from django.conf import settings for c in Competition.objects.all(): print c.id, c.title # if c.id in (1,2): # c.delete() - diff --git a/codalab/scripts/competition_example/program/evaluate.py b/codalab/scripts/competition_example/program/evaluate.py index 737ec6658..f5483f03d 100644 --- a/codalab/scripts/competition_example/program/evaluate.py +++ b/codalab/scripts/competition_example/program/evaluate.py @@ -1,29 +1,31 @@ #!/usr/bin/env python -import sys, os, os.path +import sys +import os +import os.path input_dir = sys.argv[1] output_dir = sys.argv[2] -submit_dir = os.path.join(input_dir, 'res') +submit_dir = os.path.join(input_dir, 'res') truth_dir = os.path.join(input_dir, 'ref') if not os.path.isdir(submit_dir): - print "%s doesn't exist" % submit_dir + print "%s doesn't exist" % submit_dir if os.path.isdir(submit_dir) and os.path.isdir(truth_dir): if not os.path.exists(output_dir): os.makedirs(output_dir) - output_filename = os.path.join(output_dir, 'scores.txt') + output_filename = os.path.join(output_dir, 'scores.txt') output_file = open(output_filename, 'wb') gold_list = os.listdir(truth_dir) for gold in gold_list: - gold_file = os.path.join(truth_dir, gold) - corresponding_submission_file = os.path.join(submit_dir, gold) - if os.path.exists(corresponding_submission_file): - pi = float(open(gold_file, 'rb').read()) - guess = float(open(corresponding_submission_file, 'rb').read()) - diff = abs(pi - guess) - output_file.write("Difference: %f" % diff) - output_file.close() \ No newline at end of file + gold_file = os.path.join(truth_dir, gold) + corresponding_submission_file = os.path.join(submit_dir, gold) + if os.path.exists(corresponding_submission_file): + pi = float(open(gold_file, 'rb').read()) + guess = float(open(corresponding_submission_file, 'rb').read()) + diff = abs(pi - guess) + output_file.write("Difference: %f" % diff) + output_file.close() diff --git a/codalab/scripts/competition_example/program/setup.py b/codalab/scripts/competition_example/program/setup.py index a9824389e..872431dc9 100644 --- a/codalab/scripts/competition_example/program/setup.py +++ b/codalab/scripts/competition_example/program/setup.py @@ -1,4 +1,3 @@ from distutils.core import setup -import py2exe -setup(console=['evaluate.py']) \ No newline at end of file +setup(console=['evaluate.py']) diff --git a/codalab/scripts/competitions.py b/codalab/scripts/competitions.py index 41b5abcbb..6d6bd7366 100644 --- a/codalab/scripts/competitions.py +++ b/codalab/scripts/competitions.py @@ -1,12 +1,18 @@ #!/usr/bin/env python # Run this with the python from the CodaLab virtual environment -# +# -import sys, os.path, os, random, datetime +import sys +import os.path +import os +import random +import datetime from django.utils import timezone # This is a really, really long way around saying that if the script is in -# codalab\scripts\users.py, we need to add, ../../../codalab to the sys.path to find the settings -root_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") +# codalab\scripts\users.py, we need to add, ../../../codalab to the +# sys.path to find the settings +root_dir = os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") sys.path.append(root_dir) # Set things for django configurations @@ -42,50 +48,67 @@ The BRaTS challenge is designed to gauge the current state-of-the-art in automated brain tumor segmentation and to compare between different methods. It is organized in conjuction with the MICCAI 2012 conference. """ -brats2012,_ = Competition.objects.get_or_create(title=brats12_name, creator=guest1, modified_by=guest1,defaults=dict(description=brats12_description)) +brats2012, _ = Competition.objects.get_or_create( + title=brats12_name, creator=guest1, modified_by=guest1, defaults=dict(description=brats12_description)) details_category = ContentCategory.objects.get(name="Learn the Details") participate_category = ContentCategory.objects.get(name="Participate") -pc,_ = PageContainer.objects.get_or_create(object_id=brats2012.id, content_type=ContentType.objects.get_for_model(Competition)) +pc, _ = PageContainer.objects.get_or_create( + object_id=brats2012.id, content_type=ContentType.objects.get_for_model(Competition)) brats2012.save() -Page.objects.get_or_create(category=details_category, container=pc, codename="overview", - defaults=dict(label="Overview", rank=0, - html=open(os.path.join(os.path.dirname(__file__), "brats2012_overview.html")).read())) -Page.objects.get_or_create(category=details_category, container=pc, codename="evaluation", - defaults=dict(label="Evaluation", rank=1, - html=open(os.path.join(os.path.dirname(__file__), "brats2012_evaluation.html")).read())) -Page.objects.get_or_create(category=details_category, container=pc, codename="terms_and_conditions", - defaults=dict(rank=2, label="Terms and Conditions", html=open(os.path.join(os.path.dirname(__file__), "brats2012_terms_and_conditions.html")).read())) - -Page.objects.get_or_create(category=details_category, container=pc, codename="faq", - defaults=dict(label="FAQ", rank=3, html=open(os.path.join(os.path.dirname(__file__), "brats2012_faq.html")).read())) -Page.objects.get_or_create(category=details_category, container=pc, codename="key_dates", - defaults=dict(label="Key Dates", rank=4, html=open(os.path.join(os.path.dirname(__file__), "brats2012_key_dates.html")).read())) -Page.objects.get_or_create(category=details_category, container=pc, codename="organizers", - defaults=dict(label="Organizers", rank=5,html=open(os.path.join(os.path.dirname(__file__), "brats2012_organizers.html")).read())) - -Page.objects.get_or_create(category=participate_category, container=pc, codename="get_data", - defaults=dict(label="Get Data", rank=0, html=open(os.path.join(os.path.dirname(__file__), "brats2012_data.html")).read())) -Page.objects.get_or_create(category=participate_category, container=pc, codename="submit_results", html="", defaults=dict(label="Submit Results", rank=1)) +Page.objects.get_or_create( + category=details_category, container=pc, codename="overview", + defaults=dict(label="Overview", rank=0, + html=open(os.path.join(os.path.dirname(__file__), "brats2012_overview.html")).read())) +Page.objects.get_or_create( + category=details_category, container=pc, codename="evaluation", + defaults=dict(label="Evaluation", rank=1, + html=open(os.path.join(os.path.dirname(__file__), "brats2012_evaluation.html")).read())) +Page.objects.get_or_create( + category=details_category, container=pc, codename="terms_and_conditions", + defaults=dict(rank=2, label="Terms and Conditions", html=open(os.path.join(os.path.dirname(__file__), "brats2012_terms_and_conditions.html")).read())) + +Page.objects.get_or_create( + category=details_category, container=pc, codename="faq", + defaults=dict(label="FAQ", rank=3, html=open(os.path.join(os.path.dirname(__file__), "brats2012_faq.html")).read())) +Page.objects.get_or_create( + category=details_category, container=pc, codename="key_dates", + defaults=dict(label="Key Dates", rank=4, html=open(os.path.join(os.path.dirname(__file__), "brats2012_key_dates.html")).read())) +Page.objects.get_or_create( + category=details_category, container=pc, codename="organizers", + defaults=dict(label="Organizers", rank=5, html=open(os.path.join(os.path.dirname(__file__), "brats2012_organizers.html")).read())) + +Page.objects.get_or_create( + category=participate_category, container=pc, codename="get_data", + defaults=dict(label="Get Data", rank=0, html=open(os.path.join(os.path.dirname(__file__), "brats2012_data.html")).read())) +Page.objects.get_or_create(category=participate_category, container=pc, + codename="submit_results", html="", defaults=dict(label="Submit Results", rank=1)) # Logo -brats2012.image = File( open(os.path.join(root_dir, "fixtures", "images", "brats.jpg"), 'rb')) +brats2012.image = File( + open(os.path.join(root_dir, "fixtures", "images", "brats.jpg"), 'rb')) # Save the updates brats2012.save() # Phases for the competition day_delta = datetime.timedelta(days=30) -p1date = timezone.make_aware(datetime.datetime.combine(datetime.date(2012, 7, 6), datetime.time()), timezone.get_current_timezone()) -p2date = timezone.make_aware(datetime.datetime.combine(datetime.date(2012, 10, 1), datetime.time()), timezone.get_current_timezone()) -p1date = timezone.make_aware(datetime.datetime.combine(datetime.date(2013, 7, 15), datetime.time()), timezone.get_current_timezone()) -p2date = timezone.make_aware(datetime.datetime.combine(datetime.date(2013, 8, 30), datetime.time()), timezone.get_current_timezone()) -p, created = CompetitionPhase.objects.get_or_create(competition=brats2012, phasenumber=1, label="Training Phase", - start_date=p1date, max_submissions=20) -p, created = CompetitionPhase.objects.get_or_create(competition=brats2012, phasenumber=2, label="Competition Phase", - start_date=p2date, max_submissions=5) +p1date = timezone.make_aware(datetime.datetime.combine( + datetime.date(2012, 7, 6), datetime.time()), timezone.get_current_timezone()) +p2date = timezone.make_aware(datetime.datetime.combine( + datetime.date(2012, 10, 1), datetime.time()), timezone.get_current_timezone()) +p1date = timezone.make_aware(datetime.datetime.combine( + datetime.date(2013, 7, 15), datetime.time()), timezone.get_current_timezone()) +p2date = timezone.make_aware(datetime.datetime.combine( + datetime.date(2013, 8, 30), datetime.time()), timezone.get_current_timezone()) +p, created = CompetitionPhase.objects.get_or_create( + competition=brats2012, phasenumber=1, label="Training Phase", + start_date=p1date, max_submissions=20) +p, created = CompetitionPhase.objects.get_or_create( + competition=brats2012, phasenumber=2, label="Competition Phase", + start_date=p2date, max_submissions=5) for phase in CompetitionPhase.objects.filter(competition=brats2012): - # note that we're using the same program and truth files for both phases + # note that we're using the same program and truth files for both phases # but in reality they may be different. prog_file_path = os.path.join(root_dir, "media", "brats", "program.zip") if os.path.exists(prog_file_path): @@ -94,7 +117,8 @@ phase.save() else: print "No program file set for phase: %s" % phase.label - reference_file_path = os.path.join(root_dir, "media", "brats", "testing-ref.zip") + reference_file_path = os.path.join( + root_dir, "media", "brats", "testing-ref.zip") if os.path.exists(reference_file_path): print "Setting reference file for phase: %s" % phase.label phase.reference_data = File(open(reference_file_path, 'rb')) @@ -102,137 +126,164 @@ else: print "No reference file set for phase: %s" % phase.label -## Score Definitions +# Score Definitions brats_leaderboard_group_defs = { - 'patient' : { 'label': 'Patient Data', 'order': 1}, - 'synthetic': { 'label': 'Synthetic Data', 'order': 2} } + 'patient': {'label': 'Patient Data', 'order': 1}, + 'synthetic': {'label': 'Synthetic Data', 'order': 2}} brats_leaderboard_defs = [ - #Patient data - ('PatientDice', { 'label': 'Dice'}), - ('PatientDiceComplete', { 'group': 'patient', 'column_group':'PatientDice', 'label': 'Complete' }), - ('PatientDiceCore', { 'group': 'patient', 'column_group':'PatientDice', 'label': 'Core' }), - ('PatientDiceEnhancing', { 'group': 'patient', 'column_group':'PatientDice', 'label': 'Enhancing' }), - ('PatientSensitivity', { 'label': 'Sensitivity'}), - ('PatientSensitivityComplete', { 'group': 'patient', 'column_group':'PatientSensitivity', 'label': 'Complete' }), - ('PatientSensitivityCore', { 'group': 'patient', 'column_group':'PatientSensitivity', 'label': 'Core' }), - ('PatientSensitivityEnhancing', { 'group': 'patient', 'column_group':'PatientSensitivity', 'label': 'Enhancing' }), - ('PatientSpecificity', { 'label': 'Specificity'}), - ('PatientSpecificityComplete', { 'group': 'patient', 'column_group':'PatientSpecificity', 'label': 'Complete' }), - ('PatientSpecificityCore', { 'group': 'patient', 'column_group':'PatientSpecificity', 'label': 'Core' }), - ('PatientSpecificityEnhancing', { 'group': 'patient', 'column_group':'PatientSpecificity', 'label': 'Enhancing' }), - ('PatientHausdorff', { 'label': 'Hausdorff'}), - ('PatientHausdorffComplete', { 'group': 'patient', 'column_group':'PatientHausdorff', 'label': 'Complete', 'sort': 'asc' }), - ('PatientHausdorffCore', { 'group': 'patient', 'column_group':'PatientHausdorff', 'label': 'Core', 'sort': 'asc' }), - ('PatientHausdorffEnhancing', { 'group': 'patient', 'column_group':'PatientHausdorff', 'label': 'Enhancing', 'sort': 'asc' }), - ('PatientKappa', { 'group': 'patient', 'label': 'Kappa' }), - ('PatientRank', { 'label': 'Rank'}), - ('PatientRankComplete', { 'group': 'patient', 'column_group':'PatientRank', 'label': 'Complete', - 'computed': {'operation': 'Avg', 'fields': ('PatientDiceComplete','PatientSensitivityComplete','PatientSpecificityComplete')} }), - ('PatientRankCore', { 'group': 'patient', 'column_group':'PatientRank', 'label': 'Core', - 'computed': {'operation': 'Avg', 'fields': ('PatientDiceCore','PatientSensitivityCore','PatientSpecificityCore')} }), - ('PatientRankEnhancing', { 'group': 'patient', 'column_group':'PatientRank', 'label': 'Enhancing', - 'computed': {'operation': 'Avg', 'fields': ('PatientDiceEnhancing','PatientSensitivityEnhancing','PatientSpecificityEnhancing')} }), - ('PatientRankOverall', { 'group': 'patient', 'label': 'Overall Rank', 'selection_default': 1, - 'computed': {'operation': 'Avg', 'fields': ('PatientDiceComplete','PatientSensitivityComplete','PatientSpecificityComplete', - 'PatientDiceEnhancing','PatientSensitivityEnhancing','PatientSpecificityEnhancing', - 'PatientDiceEnhancing','PatientSensitivityEnhancing','PatientSpecificityEnhancing')} }), - #Synthetic data - ('SyntheticDice', { 'label': 'Dice'}), - ('SyntheticDiceComplete', { 'group': 'synthetic', 'column_group':'SyntheticDice', 'label': 'Complete' }), - ('SyntheticDiceCore', { 'group': 'synthetic', 'column_group':'SyntheticDice', 'label': 'Core' }), - ('SyntheticSensitivity', { 'label': 'Sensitivity'}), - ('SyntheticSensitivityComplete', { 'group': 'synthetic', 'column_group':'SyntheticSensitivity', 'label': 'Complete' }), - ('SyntheticSensitivityCore', { 'group': 'synthetic', 'column_group':'SyntheticSensitivity', 'label': 'Core' }), - ('SyntheticSpecificity', { 'label': 'Specificity'}), - ('SyntheticSpecificityComplete', { 'group': 'synthetic', 'column_group':'SyntheticSpecificity', 'label': 'Complete' }), - ('SyntheticSpecificityCore', { 'group': 'synthetic', 'column_group':'SyntheticSpecificity', 'label': 'Core' }), - ('SyntheticHausdorff', { 'label': 'Hausdorff'}), - ('SyntheticHausdorffComplete', { 'group': 'synthetic', 'column_group':'SyntheticHausdorff', 'label': 'Complete', 'sort': 'asc' }), - ('SyntheticHausdorffCore', { 'group': 'synthetic', 'column_group':'SyntheticHausdorff', 'label': 'Core', 'sort': 'asc' }), - ('SyntheticKappa', { 'group': 'synthetic', 'label': 'Kappa' }), - ('SyntheticRank', { 'label': 'Rank'}), - ('SyntheticRankComplete', { 'group': 'synthetic', 'column_group':'SyntheticRank', 'label': 'Complete', - 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceComplete','SyntheticSensitivityComplete','SyntheticSpecificityComplete')} }), - ('SyntheticRankCore', { 'group': 'synthetic', 'column_group':'SyntheticRank', 'label': 'Core', - 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceCore','SyntheticSensitivityCore','SyntheticSpecificityCore')} }), - ('SyntheticRankOverall', { 'group': 'synthetic', 'label': 'Overall Rank', 'selection_default': 1, - 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceComplete','SyntheticSensitivityComplete','SyntheticSpecificityComplete', - 'SyntheticDiceCore','SyntheticSensitivityCore','SyntheticSpecificityCore')} }) ] + # Patient data + ('PatientDice', {'label': 'Dice'}), + ('PatientDiceComplete', + {'group': 'patient', 'column_group': 'PatientDice', 'label': 'Complete'}), + ('PatientDiceCore', + {'group': 'patient', 'column_group': 'PatientDice', 'label': 'Core'}), + ('PatientDiceEnhancing', + {'group': 'patient', 'column_group': 'PatientDice', 'label': 'Enhancing'}), + ('PatientSensitivity', {'label': 'Sensitivity'}), + ('PatientSensitivityComplete', + {'group': 'patient', 'column_group': 'PatientSensitivity', 'label': 'Complete'}), + ('PatientSensitivityCore', + {'group': 'patient', 'column_group': 'PatientSensitivity', 'label': 'Core'}), + ('PatientSensitivityEnhancing', + {'group': 'patient', 'column_group': 'PatientSensitivity', 'label': 'Enhancing'}), + ('PatientSpecificity', {'label': 'Specificity'}), + ('PatientSpecificityComplete', + {'group': 'patient', 'column_group': 'PatientSpecificity', 'label': 'Complete'}), + ('PatientSpecificityCore', + {'group': 'patient', 'column_group': 'PatientSpecificity', 'label': 'Core'}), + ('PatientSpecificityEnhancing', + {'group': 'patient', 'column_group': 'PatientSpecificity', 'label': 'Enhancing'}), + ('PatientHausdorff', {'label': 'Hausdorff'}), + ('PatientHausdorffComplete', + {'group': 'patient', 'column_group': 'PatientHausdorff', 'label': 'Complete', 'sort': 'asc'}), + ('PatientHausdorffCore', + {'group': 'patient', 'column_group': 'PatientHausdorff', 'label': 'Core', 'sort': 'asc'}), + ('PatientHausdorffEnhancing', {'group': 'patient', 'column_group': + 'PatientHausdorff', 'label': 'Enhancing', 'sort': 'asc'}), + ('PatientKappa', {'group': 'patient', 'label': 'Kappa'}), + ('PatientRank', {'label': 'Rank'}), + ('PatientRankComplete', {'group': 'patient', 'column_group': 'PatientRank', 'label': 'Complete', + 'computed': {'operation': 'Avg', 'fields': ('PatientDiceComplete', 'PatientSensitivityComplete', 'PatientSpecificityComplete')}}), + ('PatientRankCore', {'group': 'patient', 'column_group': 'PatientRank', 'label': 'Core', + 'computed': {'operation': 'Avg', 'fields': ('PatientDiceCore', 'PatientSensitivityCore', 'PatientSpecificityCore')}}), + ('PatientRankEnhancing', {'group': 'patient', 'column_group': 'PatientRank', 'label': 'Enhancing', + 'computed': {'operation': 'Avg', 'fields': ('PatientDiceEnhancing', 'PatientSensitivityEnhancing', 'PatientSpecificityEnhancing')}}), + ('PatientRankOverall', {'group': 'patient', 'label': 'Overall Rank', 'selection_default': 1, + 'computed': {'operation': 'Avg', 'fields': ('PatientDiceComplete', 'PatientSensitivityComplete', 'PatientSpecificityComplete', + 'PatientDiceEnhancing', 'PatientSensitivityEnhancing', 'PatientSpecificityEnhancing', + 'PatientDiceEnhancing', 'PatientSensitivityEnhancing', 'PatientSpecificityEnhancing')}}), + # Synthetic data + ('SyntheticDice', {'label': 'Dice'}), + ('SyntheticDiceComplete', + {'group': 'synthetic', 'column_group': 'SyntheticDice', 'label': 'Complete'}), + ('SyntheticDiceCore', + {'group': 'synthetic', 'column_group': 'SyntheticDice', 'label': 'Core'}), + ('SyntheticSensitivity', {'label': 'Sensitivity'}), + ('SyntheticSensitivityComplete', + {'group': 'synthetic', 'column_group': 'SyntheticSensitivity', 'label': 'Complete'}), + ('SyntheticSensitivityCore', + {'group': 'synthetic', 'column_group': 'SyntheticSensitivity', 'label': 'Core'}), + ('SyntheticSpecificity', {'label': 'Specificity'}), + ('SyntheticSpecificityComplete', + {'group': 'synthetic', 'column_group': 'SyntheticSpecificity', 'label': 'Complete'}), + ('SyntheticSpecificityCore', + {'group': 'synthetic', 'column_group': 'SyntheticSpecificity', 'label': 'Core'}), + ('SyntheticHausdorff', {'label': 'Hausdorff'}), + ('SyntheticHausdorffComplete', {'group': 'synthetic', 'column_group': + 'SyntheticHausdorff', 'label': 'Complete', 'sort': 'asc'}), + ('SyntheticHausdorffCore', + {'group': 'synthetic', 'column_group': 'SyntheticHausdorff', 'label': 'Core', 'sort': 'asc'}), + ('SyntheticKappa', {'group': 'synthetic', 'label': 'Kappa'}), + ('SyntheticRank', {'label': 'Rank'}), + ('SyntheticRankComplete', {'group': 'synthetic', 'column_group': 'SyntheticRank', 'label': 'Complete', + 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceComplete', 'SyntheticSensitivityComplete', 'SyntheticSpecificityComplete')}}), + ('SyntheticRankCore', {'group': 'synthetic', 'column_group': 'SyntheticRank', 'label': 'Core', + 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceCore', 'SyntheticSensitivityCore', 'SyntheticSpecificityCore')}}), + ('SyntheticRankOverall', {'group': 'synthetic', 'label': 'Overall Rank', 'selection_default': 1, + 'computed': {'operation': 'Avg', 'fields': ('SyntheticDiceComplete', 'SyntheticSensitivityComplete', 'SyntheticSpecificityComplete', + 'SyntheticDiceCore', 'SyntheticSensitivityCore', 'SyntheticSpecificityCore')}})] brats_groups = {} -for (key,vals) in brats_leaderboard_group_defs.iteritems(): - rg,cr = SubmissionResultGroup.objects.get_or_create( - competition=brats2012, - key=key, - defaults=dict(label=vals['label'], - ordering=vals['order']),) +for (key, vals) in brats_leaderboard_group_defs.iteritems(): + rg, cr = SubmissionResultGroup.objects.get_or_create( + competition=brats2012, + key=key, + defaults=dict(label=vals['label'], + ordering=vals['order']),) brats_groups[rg.key] = rg # All phases have the same leaderboard so add the group to each of them for gp in brats2012.phases.all(): - rgp,crx = SubmissionResultGroupPhase.objects.get_or_create(phase=gp, group=rg) + rgp, crx = SubmissionResultGroupPhase.objects.get_or_create( + phase=gp, group=rg) brats_column_groups = {} brats_score_defs = {} -for key,vals in brats_leaderboard_defs: +for key, vals in brats_leaderboard_defs: if 'group' not in vals: # Define a new grouping of scores - s,cr = SubmissionScoreSet.objects.get_or_create( - competition=brats2012, - key=key, - defaults=dict(label=vals['label'])) + s, cr = SubmissionScoreSet.objects.get_or_create( + competition=brats2012, + key=key, + defaults=dict(label=vals['label'])) brats_column_groups[key] = s else: # Create the score definition is_computed = 'computed' in vals sort_order = 'desc' if 'sort' not in vals else vals['sort'] - sdefaults = dict(label=vals['label'],numeric_format="2",show_rank=not is_computed,sorting=sort_order) + sdefaults = dict(label=vals['label'], numeric_format="2", + show_rank=not is_computed, sorting=sort_order) if 'selection_default' in vals: sdefaults['selection_default'] = vals['selection_default'] - sd,cr = SubmissionScoreDef.objects.get_or_create( - competition=brats2012, - key=key, - computed=is_computed, - defaults=sdefaults) + sd, cr = SubmissionScoreDef.objects.get_or_create( + competition=brats2012, + key=key, + computed=is_computed, + defaults=sdefaults) if is_computed: - sc,cr = SubmissionComputedScore.objects.get_or_create(scoredef=sd, operation=vals['computed']['operation']) + sc, cr = SubmissionComputedScore.objects.get_or_create( + scoredef=sd, operation=vals['computed']['operation']) for f in vals['computed']['fields']: - # Note the lookup in brats_score_defs. The assumption is that computed properties are defined in + # Note the lookup in brats_score_defs. The assumption is that computed properties are defined in # brats_leaderboard_defs after the fields they reference. - SubmissionComputedScoreField.objects.get_or_create(computed=sc, scoredef=brats_score_defs[f]) + SubmissionComputedScoreField.objects.get_or_create( + computed=sc, scoredef=brats_score_defs[f]) brats_score_defs[sd.key] = sd # Associate the score definition with its column group if 'column_group' in vals: gparent = brats_column_groups[vals['column_group']] - g,cr = SubmissionScoreSet.objects.get_or_create( - competition=brats2012, - parent=gparent, - key=sd.key, - defaults=dict(scoredef=sd, label=sd.label)) + g, cr = SubmissionScoreSet.objects.get_or_create( + competition=brats2012, + parent=gparent, + key=sd.key, + defaults=dict(scoredef=sd, label=sd.label)) else: - g,cr = SubmissionScoreSet.objects.get_or_create( - competition=brats2012, - key=sd.key, - defaults=dict(scoredef=sd, label=sd.label)) + g, cr = SubmissionScoreSet.objects.get_or_create( + competition=brats2012, + key=sd.key, + defaults=dict(scoredef=sd, label=sd.label)) # Associate the score definition with its result group - sdg,cr = SubmissionScoreDefGroup.objects.get_or_create(scoredef=sd,group=brats_groups[vals['group']]) + sdg, cr = SubmissionScoreDefGroup.objects.get_or_create( + scoredef=sd, group=brats_groups[vals['group']]) # Participant statuses, if they haven't been created before statuses = ParticipantStatus.objects.all() # Participants for the competition -participants = [ (statuses[i-2], User.objects.get(username="guest%d" % i)) for i in range(2,len(statuses)+2)] +participants = [(statuses[i - 2], User.objects.get(username="guest%d" % i)) + for i in range(2, len(statuses) + 2)] # Participant statuses, if they haven't been created before statuses = ParticipantStatus.objects.all() # Add participants to the competition with random statuses for status, participant in participants: - print "Adding %s to competition %s with status %s" % (participant, brats2012, status) - resulting_participant, created = CompetitionParticipant.objects.get_or_create(user=participant, competition=brats2012, defaults={'status':status}) + print "Adding %s to competition %s with status %s" % (participant, brats2012, status) + resulting_participant, created = CompetitionParticipant.objects.get_or_create( + user=participant, competition=brats2012, defaults={'status': status}) # # End BRaTS 2012 ---- # @@ -244,16 +295,19 @@ spine_description = """ Test for server side execution of evaluation program. """ -spine,created = Competition.objects.get_or_create(title=spine_name, creator=guest1, modified_by=guest1, - description=spine_description, has_registration=True) +spine, created = Competition.objects.get_or_create( + title=spine_name, creator=guest1, modified_by=guest1, + description=spine_description, has_registration=True) details_category = ContentCategory.objects.get(name="Learn the Details") participate_category = ContentCategory.objects.get(name="Participate") -pc,_ = PageContainer.objects.get_or_create(object_id=spine.id, content_type=ContentType.objects.get_for_model(Competition)) +pc, _ = PageContainer.objects.get_or_create( + object_id=spine.id, content_type=ContentType.objects.get_for_model(Competition)) spine.save() # Logo -spine.image = File(open(os.path.join(root_dir, "fixtures", "images", "spine.jpg"), 'rb')) +spine.image = File( + open(os.path.join(root_dir, "fixtures", "images", "spine.jpg"), 'rb')) # Save updates spine.save() @@ -261,12 +315,14 @@ # Phases for the competition day_delta = datetime.timedelta(days=30) for phase in [1, 2, 3]: - phase_start = start_date + (day_delta * phase) - p, created = CompetitionPhase.objects.get_or_create(competition=spine, phasenumber=phase, label="Phase %d" % phase, - start_date=phase_start, max_submissions=4) + phase_start = start_date + (day_delta * phase) + p, created = CompetitionPhase.objects.get_or_create( + competition=spine, phasenumber=phase, label="Phase %d" % phase, + start_date=phase_start, max_submissions=4) # Participants for the competition -participants = [ User.objects.get(username="guest%d" % random.choice(range(1,10))) for i in range(random.choice(range(1, 5)))] +participants = [User.objects.get(username="guest%d" % random.choice(range(1, 10))) + for i in range(random.choice(range(1, 5)))] # print participants # Participant statuses, if they haven't been created before @@ -275,10 +331,12 @@ # Add participants to the competition with random statuses for participant in participants: - status = random.choice(statuses) - # print "Adding %s to competition %s with status %s" % (participant, spine, status) - resulting_participant, created = CompetitionParticipant.objects.get_or_create(user=participant, competition=spine, - defaults={'status':status}) + status = random.choice(statuses) + # print "Adding %s to competition %s with status %s" % (participant, + # spine, status) + resulting_participant, created = CompetitionParticipant.objects.get_or_create( + user=participant, competition=spine, + defaults={'status': status}) # # End Spine Localization ---- # @@ -286,28 +344,35 @@ # # Single-phase competition # + + def create_single_phase_sample(): title = "Single-phase competition example" description = "This is an example of a single-phase competition." - competition,created = Competition.objects.get_or_create(title=title, creator=guest1, modified_by=guest1, description=description) + competition, created = Competition.objects.get_or_create( + title=title, creator=guest1, modified_by=guest1, description=description) competition.save() # Note: no logo specified on purpose # The one phase of the competition phase_start = timezone.now() - phase, created = CompetitionPhase.objects.get_or_create(competition=competition, phasenumber=1, label="Game On", - start_date=phase_start, max_submissions=10) + phase, created = CompetitionPhase.objects.get_or_create( + competition=competition, phasenumber=1, label="Game On", + start_date=phase_start, max_submissions=10) # Participants for the competition - participants = [ User.objects.get(username="guest%d" % i) for i in range(1, 5)] + participants = [User.objects.get(username="guest%d" % i) + for i in range(1, 5)] # Participant statuses, if they haven't been created before - statuses = ParticipantStatus.objects.all() + ParticipantStatus.objects.all() # Add participants to the competition with random statuses for participant in participants: - status = ParticipantStatus.objects.get(codename=ParticipantStatus.PENDING) - resulting_participant, created = CompetitionParticipant.objects.get_or_create(user=participant, competition=competition, - defaults={'status':status}) + status = ParticipantStatus.objects.get( + codename=ParticipantStatus.PENDING) + resulting_participant, created = CompetitionParticipant.objects.get_or_create( + user=participant, competition=competition, + defaults={'status': status}) # # End single-phase competition ---- # diff --git a/codalab/scripts/compute.py b/codalab/scripts/compute.py index 591be618e..16798526f 100644 --- a/codalab/scripts/compute.py +++ b/codalab/scripts/compute.py @@ -2,15 +2,16 @@ # # import web -import json urls = ('/api/computation/(.+)', 'computation') + class computation: - def GET(self, id): - print "ID: %s" % id + + def GET(self, id): + print "ID: %s" % id if __name__ == "__main__": - app = web.application(urls, globals()) - app.internalerror = web.debugerror - app.run() \ No newline at end of file + app = web.application(urls, globals()) + app.internalerror = web.debugerror + app.run() diff --git a/codalab/scripts/users.py b/codalab/scripts/users.py index ece238736..d5c0912cd 100644 --- a/codalab/scripts/users.py +++ b/codalab/scripts/users.py @@ -1,11 +1,15 @@ #!/usr/bin/env python # Run this with the python from the CodaLab virtual environment -# +# -import sys, os.path, os +import sys +import os.path +import os # This is a really, really long way around saying that if the script is in -# codalab\scripts\users.py, we need to add, ../../../codalab to the sys.path to find the settings -root_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") +# codalab\scripts\users.py, we need to add, ../../../codalab to the +# sys.path to find the settings +root_dir = os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.abspath(__file__)))), "codalab") sys.path.append(root_dir) # Set things for django configurations @@ -21,13 +25,13 @@ User = get_user_model() # Make some users -for i in range(1,11): - name = "guest%d" % i - email = "%s@live.com" % name - password = "abc123" +for i in range(1, 11): + name = "guest%d" % i + email = "%s@live.com" % name + password = "abc123" - print "Creating user %s with email %s and password %s" % (name, email, password) + print "Creating user %s with email %s and password %s" % (name, email, password) - new_user,_ = User.objects.get_or_create(email=email, username=name) - new_user.set_password(password) - new_user.save() + new_user, _ = User.objects.get_or_create(email=email, username=name) + new_user.set_password(password) + new_user.save() diff --git a/jenkins.sh b/jenkins.sh deleted file mode 100755 index a104010f6..000000000 --- a/jenkins.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# Run jenkins tests / tools -# - -if [ -x 'venv' ]; then - . venv/bin/activate -else - echo "Virtual environment not setup, exiting." - exit 1 -fi - -pip install -r codalab/requirements/jenkins.txt - -python codalab/manage.py jenkins - -#nosetests --with-xcoverage --with-xunit --cover-erase - -#pylint -f parseable . | tee pylint.out \ No newline at end of file