Challenge Wiki

Create

The skeleton for two challenges site with initial wiki, four teams (admin, participants, organizers, and preregistrants), and a challenge widget added on live site with a participant team associated with it.

For more information on challenges administration: https://docs.synapse.org/articles/challenge_administration.html

Example:

import challengeutils
import synapseclient
syn = synapseclient.login()
challengeutils.createchallenge.main(syn, "Plouf Challenge")
challengeutils.createchallenge.check_existing_and_delete_wiki(syn, synid)[source]

Checks if wiki exists, and if so prompt to delete

Parameters
  • syn – Synapse connection

  • synid – Synapse id of an Entity

challengeutils.createchallenge.create_challenge_widget(syn, project_live, team_part_id)[source]

Creates challenge widget - activates a Synapse project If challenge object exists, it retrieves existing object

Parameters
  • syn – Synpase object

  • project_live – Synapse id of live challenge project

  • team_part_id – Synapse team id of participant team

challengeutils.createchallenge.create_evaluation_queue(syn, name, description, parentid)[source]

Creates Evaluation Queues

Parameters
  • syn – Synpase object

  • name – Name of evaluation queue

  • description – Description of queue

  • parentid – Synapse project id

Returns

Evalation Queue

challengeutils.createchallenge.create_project(syn, project_name)[source]

Creates Synapse Project

Parameters
  • syn – Synpase object

  • project_name – Name of project

Returns

Project Entity

challengeutils.createchallenge.create_team(syn, team_name, desc, can_public_join=False)[source]

Creates Synapse Team

Parameters
  • syn – Synpase object

  • team_name – Name of team

  • desc – Description of team

  • can_public_join – true for teams which members can join without an invitation or approval. Default to False

Returns

Synapse Team id

challengeutils.createchallenge.main(syn, challenge_name, live_site=None)[source]

Creates two project entity for challenge sites. 1) live (public) and 2) staging (private until launch) Allow for users to set up the live site themselves

Parameters
  • syn – Synapse object

  • challenge_name – Name of the challenge

  • live_site – If there is already a live site, specify live site Synapse id. (Default is None)

Returns

dict:

{
    "live_projectid": projectid,
    "staging_projectid": projectid,
    "admin_teamid": teams['team_admin_id'],
    "organizer_teamid": teams['team_org_id'],
    "participant_teamid": teams['team_part_id'],
    "preregistrantrant_teamid": teams['team_prereg_id']
}

Updating

Mirrors (sync) wiki pages by using the wikipage titles between two Synapse Entities. This function only works if entity and destination`are the same type and both must have wiki pages. Only wiki pages with the same titles will be copied from `entity to destination - if there is a wiki page that you want to add, you will have to create a wiki page first in the destination with the same name.

Example:

import challengeutils
import synapseclient
syn = synapseclient.login()
source_project = syn.get("syn123")
target_project = syn.get("syn234")
challengeutils.mirrorwiki.mirror(syn=syn, entity=source_project,
                                 destination=target_project)
challengeutils.mirrorwiki.mirror(syn: synapseclient.client.Synapse, entity: Union[synapseclient.entity.File, synapseclient.entity.Folder, synapseclient.entity.Project], destination: Union[synapseclient.entity.File, synapseclient.entity.Folder, synapseclient.entity.Project], force: bool = False, dryrun: bool = False)[source]

Mirrors (sync) wiki pages by using the wikipage titles between two Synapse Entities. This function only works if entity and destination are the same type and both must have wiki pages. Only wiki pages with the same titles will be copied from entity to destination - if there is a wiki page that you want to add, you will have to create a wiki page first in the destination with the same name.

Parameters
  • entity – Synapse File, Project, Folder Entity or Id with Wiki you want to copy

  • destination – Synapse File, Project, Folder Entity or Id with Wiki that matches entity

  • force – Update a page even if its the same. Default to False.

  • dryrun – Show the pages that have changed but don’t update. Default is False.

Synapse Wiki Tools

Pull and push wiki tools

challengeutils.wiki.pull_wiki(syn: synapseclient.client.Synapse, project: str, workdir: str = './') → List[dict][source]

Downloads each wikipage’s content into a markdown file and stores a configuration file

Parameters
  • syn – Synapse connection

  • project – synapseclient.Project or its id

  • workdir – Location to download markdown files and wiki_config.json into. Defaults to location of where code is being executed.

Returns

Wiki Configuration:

[
    {
        "id": "111",
        "title": "homepage",
        "markdown_path": "111-homepage.md"
    },
    {...}
]

challengeutils.wiki.push_wiki(syn: synapseclient.client.Synapse, projectid: str, workdir: str = './') → List[dict][source]

Pushes Wiki from configuration

Parameters
  • syn – Synapse connection

  • project – synapseclient.Project or its id

  • workdir – Location to download markdown files and wiki_config.json. Defaults to location of where code is being executed.

Returns

Wiki Configuration:

[
    {
        "id": "111",
        "title": "title",
        "parentId": "33333",
        "markdown_path": "home.md"
    },
    {...}
]

challengeutils.wiki.read_wiki_config(workdir: str) → List[dict][source]

Read wiki config file from working directory

Parameters

workdir – Working directory

Returns

Wiki Configuration:

[
    {
        "id": "111",
        "title": "title",
        "parentId": "33333",
        "markdown_path": "home.md"
    },
    {...}
]

challengeutils.wiki.validate_config(workdir: str) → List[dict][source]

Validates wiki configuration

Parameters

workdir – Workfing directory with markdown and wiki_config.json

Returns

Wiki Configuration:

[
    {
        "id": "111",
        "title": "title",
        "parentId": "33333",
        "markdown_path": "home.md"
    },
    {...}
]

Raises

ValueErrormarkdown_path is specified but cannot be located. There are duplicated wiki ids. id is not specified and (markdown_path/parentId/title is missing or parentId not one of the id`s.) `id cannot be the same as parentId.