From 03cd69c6703fddac1a35768833b5e639f0ce795d Mon Sep 17 00:00:00 2001 From: verena <9377970+vpchung@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:30:10 -0800 Subject: [PATCH 1/5] add `private` option --- challengeutils/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/challengeutils/__main__.py b/challengeutils/__main__.py index 11d4cfcb..dfeac245 100644 --- a/challengeutils/__main__.py +++ b/challengeutils/__main__.py @@ -88,7 +88,7 @@ def command_create_portal_challenge(syn, args): >>> challengeutils create-portal-challenge "Challenge Name Here" [-n ] """ challenge_components = create_portal_challenge.main( - syn, args.challenge_name, args.tasks_count, args.livesiteid + syn, args.challenge_name, args.tasks_count, args.livesiteid, args.private ) # component: project or team # componentid: project id or teamid @@ -485,7 +485,11 @@ def build_parser(): "Option to specify the live site synapse Id" " there is already a live site" ), ) - parser_create_portal_challenge.set_defaults(func=command_create_portal_challenge) + parser_create_portal_challenge.add_argument( + "--private", + help="Option to not share the challenge with the Sage CNB Team", + ) + parser_create_portal_challenge.set_defaults(func=command_create_challenge) parser_mirrorwiki = subparsers.add_parser( "mirror-wiki", From 9999bcb673ec01d271acb1bfe83514d1dd9d1a3a Mon Sep 17 00:00:00 2001 From: verena <9377970+vpchung@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:31:24 -0800 Subject: [PATCH 2/5] add Sage CNB Team as admin to challenge sites by default --- challengeutils/create_portal_challenge.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/challengeutils/create_portal_challenge.py b/challengeutils/create_portal_challenge.py index f91be7a7..3e89f8d0 100644 --- a/challengeutils/create_portal_challenge.py +++ b/challengeutils/create_portal_challenge.py @@ -29,6 +29,7 @@ TABLE_TEMPLATE_SYNID = "syn52955244" CHALLENGE_ROLES = ["organizer", "contributor", "sponsor"] TASK_WIKI_ID = "624554" +SAGE_CNB_TEAM = "3379097" def create_project(syn, project_name): @@ -299,7 +300,7 @@ def create_annotations(syn, project_id, table_ids, folder_ids): return project -def main(syn, challenge_name, tasks_count, live_site=None): +def main(syn, challenge_name, tasks_count, live_site=None, private=False): """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 @@ -331,6 +332,10 @@ def main(syn, challenge_name, tasks_count, live_site=None): permissions.set_entity_permissions( syn, project_live, teams["team_org_id"], permission_level="moderate" ) + if not private: + permissions.set_entity_permissions( + syn, project_live, SAGE_CNB_TEAM, "admin" + ) _create_live_wiki(syn, project_live) else: project_live = syn.get(live_site) @@ -369,6 +374,8 @@ def main(syn, challenge_name, tasks_count, live_site=None): permissions.set_entity_permissions( syn, project_staging, teams["team_org_id"], permission_level="edit" ) + if not private: + permissions.set_entity_permissions(syn, project_staging, SAGE_CNB_TEAM, "admin") # Checks if staging wiki exists, if so delete check_existing_and_delete_wiki(syn, project_staging.id) From 28dc8a916ef24e1a47cd35c953d9d2d1a34898af Mon Sep 17 00:00:00 2001 From: verena <9377970+vpchung@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:31:58 -0800 Subject: [PATCH 3/5] add Sage CNB Team as admin to queues by default --- challengeutils/create_portal_challenge.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/challengeutils/create_portal_challenge.py b/challengeutils/create_portal_challenge.py index 3e89f8d0..28968d5b 100644 --- a/challengeutils/create_portal_challenge.py +++ b/challengeutils/create_portal_challenge.py @@ -342,12 +342,14 @@ def main(syn, challenge_name, tasks_count, live_site=None, private=False): challenge_obj = create_challenge_widget(syn, project_live, teams["team_part_id"]) for i in range(0, tasks_count): - create_evaluation_queue( + queue = create_evaluation_queue( syn, f"{challenge_name} Task {i + 1}", f"Task {i + 1} Submission", project_live.id, ) + if not private: + permissions.set_evaluation_permissions(syn, queue, SAGE_CNB_TEAM, "admin") # TODO: the following function does not work for some reason; see function # for details # tables = create_organizer_tables(syn, project_live.id) From cfddd84e46378263cf85ec0b33ce59adf0ccbd3c Mon Sep 17 00:00:00 2001 From: verena <9377970+vpchung@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:32:37 -0800 Subject: [PATCH 4/5] update CLI command names and descriptions --- challengeutils/__main__.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/challengeutils/__main__.py b/challengeutils/__main__.py index dfeac245..556d3164 100644 --- a/challengeutils/__main__.py +++ b/challengeutils/__main__.py @@ -50,13 +50,13 @@ def command_mirrorwiki(syn, args): ) -def command_createchallenge(syn, args): +def command_create_challenge_legacy(syn, args): """Creates a challenge space in Synapse. This pulls from a standard DREAM template and creates the Projects and Teams that you will need for a challenge. For more information on all the components this function creates, please head to `challenge administration `_. - >>> challengeutils createchallenge "Challenge Name Here" + >>> challengeutils create-legacy-challenge "Challenge Name Here" """ challenge_components = createchallenge.main( syn, args.challengename, args.livesiteid @@ -82,10 +82,10 @@ def command_createchallenge(syn, args): return challenge_components -def command_create_portal_challenge(syn, args): +def command_create_challenge(syn, args): """Creates a challenge on the Sage Challenge Portal. - >>> challengeutils create-portal-challenge "Challenge Name Here" [-n ] + >>> challengeutils create-challenge "Challenge Name Here" [-n ] """ challenge_components = create_portal_challenge.main( syn, args.challenge_name, args.tasks_count, args.livesiteid, args.private @@ -455,21 +455,21 @@ def build_parser(): help='For additional help: "challengeutils -h"', ) - parser_createchallenge = subparsers.add_parser( - "create-challenge", help="Creates a challenge from a template" + parser_create_legacy_challenge = subparsers.add_parser( + "create-challenge-legacy", help="Creates a challenge from a legacy template" ) - parser_createchallenge.add_argument("challengename", help="Challenge name") - parser_createchallenge.add_argument( + parser_create_legacy_challenge.add_argument("challengename", help="Challenge name") + parser_create_legacy_challenge.add_argument( "--livesiteid", help=( "Option to specify the live site synapse Id" " there is already a live site" ), ) - parser_createchallenge.set_defaults(func=command_createchallenge) + parser_create_legacy_challenge.set_defaults(func=command_create_challenge_legacy) parser_create_portal_challenge = subparsers.add_parser( - "create-portal-challenge", - help="Create a Sage Challenge Portal challenge from template", + "create-challenge", + help="(recommended) Create a challenge from the Sage Challenge Portal template", ) parser_create_portal_challenge.add_argument("challenge_name", help="Challenge name") parser_create_portal_challenge.add_argument( From 8d86a06443cab51010dca88d46967c1eef80adc2 Mon Sep 17 00:00:00 2001 From: verena <9377970+vpchung@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:32:57 -0800 Subject: [PATCH 5/5] lint --- challengeutils/__main__.py | 13 +++++++------ challengeutils/create_portal_challenge.py | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/challengeutils/__main__.py b/challengeutils/__main__.py index 556d3164..66bc4f79 100644 --- a/challengeutils/__main__.py +++ b/challengeutils/__main__.py @@ -1,4 +1,5 @@ """challengeutils command line client""" + import argparse import json import logging @@ -6,19 +7,19 @@ import pandas as pd import synapseclient -from synapseclient.core.retry import with_retry -from synapseclient.core.utils import from_unix_epoch_time from synapseclient.core.exceptions import ( - SynapseNoCredentialsError, SynapseAuthenticationError, + SynapseNoCredentialsError, ) +from synapseclient.core.retry import with_retry +from synapseclient.core.utils import from_unix_epoch_time from . import ( annotations, - createchallenge, - create_portal_challenge, challenge, cheat_detection, + create_portal_challenge, + createchallenge, evaluation_queue, mirrorwiki, permissions, @@ -482,7 +483,7 @@ def build_parser(): parser_create_portal_challenge.add_argument( "--livesiteid", help=( - "Option to specify the live site synapse Id" " there is already a live site" + "Option to specify the live site synapse Id there is already a live site" ), ) parser_create_portal_challenge.add_argument( diff --git a/challengeutils/create_portal_challenge.py b/challengeutils/create_portal_challenge.py index 28968d5b..a168cb88 100644 --- a/challengeutils/create_portal_challenge.py +++ b/challengeutils/create_portal_challenge.py @@ -13,12 +13,13 @@ challengeutils.create_portal_challenge.main(syn, "Foo Challenge") """ + import logging import sys import synapseclient -from synapseclient.core.exceptions import SynapseHTTPError import synapseutils +from synapseclient.core.exceptions import SynapseHTTPError from . import challenge, permissions