def create_site_bundle(syn: Synapse, question: int, site: str): """Creates workflow and entity bundles for the internal site submissions Args: syn: Synapse connection question: Question number site: Site """ shutil.copyfile( os.path.join(SCRIPT_DIR, "../infrastructure/internal_workflow.cwl"), os.path.join(SCRIPT_DIR, f"../infrastructure/{question}_internal_workflow.cwl")) internal = create_evaluation_queue( syn, f"COVID-19 DREAM {site} - Question {question}") syn.setPermissions(internal, accessType=[ 'DELETE_SUBMISSION', 'DELETE', 'SUBMIT', 'UPDATE', 'CREATE', 'READ', 'UPDATE_SUBMISSION', 'READ_PRIVATE_SUBMISSION', 'CHANGE_PERMISSIONS' ], principalId=3407544) internal_test = create_evaluation_queue( syn, f"COVID-19 DREAM {site} - Question {question} TEST") syn.setPermissions(internal_test, accessType=[ 'DELETE_SUBMISSION', 'DELETE', 'SUBMIT', 'UPDATE', 'CREATE', 'READ', 'UPDATE_SUBMISSION', 'READ_PRIVATE_SUBMISSION', 'CHANGE_PERMISSIONS' ], principalId=3407544) prod_wf = os.path.join("covid19-challenge-master/infrastructure", f"{question}_internal_workflow.cwl") test_wf = os.path.join("covid19-challenge-develop/infrastructure", f"{question}_internal_workflow.cwl") ent = create_entity(syn, name=f"COVID-19 {site} Q{question}", link=MASTER, annotations={'ROOT_TEMPLATE': prod_wf}) test_ent = create_entity(syn, name=f"COVID-19 {site} Q{question} TEST", link=DEV, annotations={'ROOT_TEMPLATE': test_wf}) print(f"Add to {site}'s docker-compose .env") print({internal.id: ent.id, internal_test.id: test_ent.id}) return { "internal_queueid": internal.id, "internal_queue_testid": internal_test.id }
def _set_acl(syn: Synapse, entity: Union[File, Folder, Project], acl_config: dict): """Sets ACLs to Synapse entity Args: syn: Synapse connection entity: Synapse Folder or Project acl_config: ACL template json configuration """ for acl in acl_config: syn.setPermissions(entity=entity, principalId=acl['principal_id'], accessType=acl['access_type'])
def create_main_bundle(syn: Synapse, question: int): """Creates workflow and entity bundles for the main submission Args: syn: Synapse connection question: Question number """ shutil.copyfile( os.path.join(SCRIPT_DIR, "../infrastructure/main_workflow.cwl"), os.path.join(SCRIPT_DIR, f"../infrastructure/{question}_workflow.cwl")) main_queue = create_evaluation_queue( syn, f"COVID-19 DREAM Challenge - Question {question}") # Global view syn.setPermissions(main_queue, accessType=['READ']) # Participant team syn.setPermissions(main_queue, accessType=['READ'], principalId=3407543) # Admin team syn.setPermissions(main_queue, accessType=[ 'DELETE_SUBMISSION', 'DELETE', 'SUBMIT', 'UPDATE', 'CREATE', 'READ', 'UPDATE_SUBMISSION', 'READ_PRIVATE_SUBMISSION', 'CHANGE_PERMISSIONS' ], principalId=3407544) main_queue_test = create_evaluation_queue( syn, f"COVID-19 DREAM Challenge - Question {question} TEST") syn.setPermissions(main_queue_test, accessType=[ 'DELETE_SUBMISSION', 'DELETE', 'SUBMIT', 'UPDATE', 'CREATE', 'READ', 'UPDATE_SUBMISSION', 'READ_PRIVATE_SUBMISSION', 'CHANGE_PERMISSIONS' ], principalId=3407544) prof_wf = os.path.join("covid19-challenge-master/infrastructure", f"{question}_workflow.cwl") test_wf = os.path.join("covid19-challenge-develop/infrastructure", f"{question}_workflow.cwl") main_ent = create_entity(syn, name=f"COVID-19 Q{question}", link=MASTER, annotations={'ROOT_TEMPLATE': prof_wf}) main_test_ent = create_entity(syn, name=f"COVID-19 Q{question} TEST", link=DEV, annotations={'ROOT_TEMPLATE': test_wf}) print("Add to NCAT's docker-compose .env") print({main_queue.id: main_ent.id, main_queue_test.id: main_test_ent.id}) return { "main_queueid": main_queue.id, "main_queue_testid": main_queue_test.id }
def main(): # Parse command-line arguments args = parse_arguments() # Set up Synapse syn = Synapse() syn.login(args.username, args.password, rememberMe=args.remember) # Retrieve Synapse entity (e.g., project, folder) entity = syn.get(args.synid, downloadFile=False) log("Entity", entity) # Retrieve team team = syn.getTeam(args.team) # TODO: Handle users with try-catch log("Team", team) # Assign specified permissions for given entity and team permissions = syn.setPermissions(entity, team.id, accessType=args.permissions) log("Permissions", permissions) # Celebrate print("Success!")