Exemplo n.º 1
0
def get_forum_participants(syn: Synapse,
                           ent: Union[Project, str]) -> List[UserProfile]:
    '''
    Get all forum participants

    Args:
        ent: Synapse Project entity or id
        synid: Synapse Project id

    Return:
        list: user profiles active in forum
    '''
    synid = id_of(ent)
    threads = get_forum_threads(syn, synid)
    users = set()
    for thread in threads:
        unique_users = set(thread.active_authors)
        users.update(unique_users)
    userprofiles = [syn.getUserProfile(user) for user in users]
    return userprofiles
Exemplo n.º 2
0
def get_registered_challenges(syn: Synapse,
                              userid: str = None) -> Iterator[Project]:
    """Get the Synapse Challenge Projects a user is registered to.
    Defaults to the logged in synapse user.

    Args:
        syn: Synapse connection
        userid: Specify userid if you want to know the challenges
                another Synapse user is registered to.

    Yields:
        A synapseclient.Project

    """
    challenge_api = ChallengeApi(syn=syn)
    # This will return the logged in user profile if None is passed in
    profile = syn.getUserProfile(userid)
    userid = profile.ownerId
    registered = challenge_api.get_registered_challenges(participantId=userid)
    for challenge in registered:
        challenge_ent = syn.get(challenge.projectId)
        print(challenge_ent.name)
        yield challenge_ent
Exemplo n.º 3
0
    if ((aws_access_key_id is None) or (aws_secret_access_key is None)):
        break
    else:
        s3Connections.append(S3Connection(aws_access_key_id, aws_secret_access_key))
        iamConnections.append(IAMConnection(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key))
        i=i+1
        
if (len(s3Connections)==0):
    raise("No AWS crdentials provided")

MAXIMUM_USER_NAME_LENGTH = 63

## connect to Synapse
syn = Synapse()
syn.login(synapseUserId, synapseUserPw)
ownUserProfile = syn.getUserProfile()
ownPrincipalId = ownUserProfile['ownerId']

## get all Participants for Evaluation
participants = syn.restGET("/evaluation/"+evaluationId+'/participant?limit=99999')['results']
print "total number of results: "+str(len(participants))

## For each participant
participantList = []
anyNewUsers = False
for i,part in enumerate(participants):
    ## add to a list the user's first name, last name, email address, user name and principal ID
    ## "user name" is defined as <firstName>.<lastName>.<principalId>.wcpe.sagebase.org
    partId = part['userId']
    up = syn.getUserProfile(partId)
    # scrub for illegal characters, control string length, convert to lower case
Exemplo n.º 4
0
    else:
        s3Connections.append(S3Connection(aws_access_key_id, aws_secret_access_key))
        iamConnections.append(
            IAMConnection(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
        )
        i = i + 1

if len(s3Connections) == 0:
    raise ("No AWS crdentials provided")

MAXIMUM_USER_NAME_LENGTH = 63

## connect to Synapse
syn = Synapse()
syn.login(synapseUserId, synapseUserPw)
ownUserProfile = syn.getUserProfile()
ownPrincipalId = ownUserProfile["ownerId"]

## get all Participants for Evaluation
participants = syn.restGET("/evaluation/" + evaluationId + "/participant?limit=99999")["results"]
print "total number of results: " + str(len(participants))

## For each participant
participantList = []
anyNewUsers = False
for i, part in enumerate(participants):
    ## add to a list the user's first name, last name, email address, user name and principal ID
    ## "user name" is defined as <firstName>.<lastName>.<principalId>.wcpe.sagebase.org
    partId = part["userId"]
    up = syn.getUserProfile(partId)
    # scrub for illegal characters, control string length, convert to lower case