Skip to content

Instantly share code, notes, and snippets.

@cbare
Created February 5, 2014 17:27
Show Gist options
  • Select an option

  • Save cbare/8828964 to your computer and use it in GitHub Desktop.

Select an option

Save cbare/8828964 to your computer and use it in GitHub Desktop.
Template for Synapse challenges

##Background Why is this an important question and why is it interesting for the participants?

##Registration

${{jointeam?teamId={team[id]}&showProfileForm=true&isMemberMessage=You have successfully joined the {name}}}

##Data description What data types and how many samples are provided. The Data Description page has more details.

Upload training data to the data folder ({data_folder.id}).

##The Challenge What is the question? What prediction or inference task are solvers asked to perform? Find more details in Submitting results.

##Scoring How will submissions be evaluated?

To see how you did, check the leaderboard.

##Timeline Deadlines and important dates. Are there rounds or stages?

##Help Should you have any questions related to the Challenge, please visit the Community Forum.

Check the News page for announcements.

##Credits Acknowledge partners, sponsors, data providers.

This challenge is presented by DREAM and Sage Bionetworks.

from synapseclient import Activity
from synapseclient import Entity, Project, Folder, File
from synapseclient import Evaluation, Submission, SubmissionStatus
from synapseclient import Wiki
from datetime import date as Date
from synapseclient.client import PUBLIC
import json
def create_team(syn, name, can_public_join=True):
team = {
"name":name,
"canPublicJoin":can_public_join}
return syn.restPOST('/team/', json.dumps(team))
def create_challenge(syn, name, subchallenges=1, initial_status='PLANNED', can_public_join=True):
project = syn.store(Project(name))
data_folder = syn.store(Folder("Data", parent=project))
example_folder = syn.store(Folder("Example submission", parent=project))
evaluations = []
if subchallenges > 1:
for i in range(1,subchallenges+1):
evaluations.append(syn.store(Evaluation(name="{name} Subchallenge {i}".format(name=name, i=i), description='', status=initial_status, contentSource=project.id)))
else:
evaluations.append(syn.store(Evaluation(name=name, description='', status=initial_status, contentSource=project.id)))
## this is needed in the challenge-intro template
evaluation_ids = [e.id for e in evaluations]
team = create_team(syn, name + " Participants", can_public_join=can_public_join)
for evaluation in evaluations:
acl = syn.restGET('/evaluation/{id}/acl'.format(id=evaluation.id))
acl['resourceAccess'].append({u'accessType': [u'PARTICIPATE', u'SUBMIT', u'READ'], u'principalId': team['id']})
acl = syn.restPUT('/evaluation/acl', json.dumps(acl))
intro_page = syn.store(Wiki(
title=name,
owner=project,
markdown="**To be announced**"))
data_md = "##Data Access Approval\nThis is the process for gaining access to the challenge data.\n##Downloading Data\nChallenge data can be found in {data_folder.id}.\n".format(**locals())
data_description_page = syn.store(Wiki(
title="1. Data Description",
owner=project,
markdown=data_md,
parentWikiId=intro_page.id))
compute_md = "##Compute resources\nAre cloud or other dedicated compute services provided for challenge participants?\n".format(**locals())
compute_page = syn.store(Wiki(
title="2. Computing",
owner=project,
markdown=compute_md,
parentWikiId=intro_page.id))
submitting_md = "##Example submission\nAn example of the required format for submissions is in ({example_folder.id}).\n".format(**locals())
submitting_page = syn.store(Wiki(
title="3. Submitting Results",
owner=project,
markdown=submitting_md,
parentWikiId=intro_page.id))
if subchallenges > 1:
leaderboard_md = ""
for i in range(1,subchallenges+1):
leaderboard_md += "##Subchallenge {i}\n\n".format(**locals())
else:
leaderboard_md = "##Leaderboard\nInsert leaderboard here!\n"
leaderboard_page = syn.store(Wiki(
title="4. Leaderboard",
owner=project,
markdown=leaderboard_md,
parentWikiId=intro_page.id))
today = Date.today()
news_md = "##{month} {today.day}, {today.year}\nA new challenge begins!\n".format(month=today.strftime("%B"), today=today)
news_page = syn.store(Wiki(
title="5. News",
owner=project,
markdown=news_md,
parentWikiId=intro_page.id))
with open('templates/challenge-intro.template.md') as f:
intro_md = f.read()
intro_page.markdown = intro_md.format(**locals())
intro_page = syn.store(intro_page)
syn.setPermissions(project, PUBLIC, ['READ', 'DOWNLOAD'])
def delete_challenge(syn, project):
if not isinstance(project, Project):
project = syn.get(project)
for evaluation in syn.getEvaluationByContentSource(project):
syn.delete(evaluation)
team = syn.restGET('/teams?fragment=%s' % project.name)
if team['results']:
syn.restDELETE('/team/{team[id]}'.format(team=team['results'][0]))
syn.delete(project)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment