Skip to content

Commit

Permalink
Release 3.1 (#198)
Browse files Browse the repository at this point in the history
* Use dataclass

* add uri into challenge class

* Use dataclass and dataclass json

* Add challenge service

* Fix

* Add in dataclasses req

* Add in requirement

* Use specific version

* Fix tests

* Remove last line

* Revise challenge data obj + add challengeApi

* Add tests

* Add tests for challenge service

* test rest calls

* Move synapse services to within challengeutils folder

* Fix tests

* Fix tests

* Fix functions

* Rename

* Switch to challenge instead of util

* Fix tests and finish up refactor

* Remove duplicate

* Remove unused var

* Push dev version

* Fix

* Have consistent spacing

* Setter functions don't return anything

* Update to 1.6.1

* Fix client issue

* Only the getter needs to be documented'

* Create list registered challenges function + command line tool

* Add to client docs

* Split up admin/user guide

* lint

* Remove dependency for synapseclient < 2, fix setup.py, fix imports

* import mock from unittest

* Software untested for 3.9

* Fix import

* ADd in downloading of submissions

* Update challengeutils/challenge.py

* Update challengeutils/__version__.py

* Remove

* update docs theme; rearrange toc and pages (#155)

* update docs theme; rearrange toc and pages

* fixed requirements; added more pages and docs

* fixed changelog description

* fix versioning

* added v2.0 information to changelog

* add link to GitHub contributors in authors

* update badges; reformat word for consistency

* minor fixes

* added remaining commands to CLI page

* temporarily removing client overview for doc release; will re-add later

* remove emoji from v1.5.2 release notes and add actual info

Co-authored-by: verena <vpchung@users.noreply.github.com>

* Push 2.0.1

* Create CODE_OF_CONDUCT.md (#158)

* Create CONTRIBUTING.md (#159)

* Remove image

* update readme

* Edit

* Fix contributing guide path

* Add space

* Add to change log

* Remove travis dependency (#163)

* Create pythonapp.yml

* Install challengeutils

* Remove travis dependency

* Only run test on PR

* update version

* Remove functionality to invite members to team (#167)

* Create _copy_thread which just copies the threads, copy_thread now copies replies (#169)

* Fix createchallenge bug (#171)

* Make sure to not redefine 'challenge'

* Dont pass object into rest post call

* Fix tests

* Add in sage name and year

* Automate code coverage (#165)

* Add in testing of synapse service module

* Test code coverage

* Fix

* Add init

* Update

* Remove

* Add inits

* Add inits

* Remove

* Try uploading artifact

* Add in flake8

* install all dependencies

* Rename to build

* Remove duplicated test func

* Refactor mirror wiki (#143)

* Update version

* Refactor mirrowiki

* Update mirrorwiki

* Add dry run flag, fix docs

* Remove comments

* Increase update wiki pages and maps helper

* Add test mirrorwiki

* Make most functions convenience functions

* Fix indent

* add tests

* Add test

* Fix

* Add integration test

* Add integration tests

* Remove synapseclient<2 support for challenge.py

* Add -f

* Add in stdout for wiki titles that exist in destionation but not entity

* Update tests/test_mirrorwiki.py

* Add to documentation (#175)

* Add in development requirements

* Add to contributing guide on how to develop

* Update documentation

* Update version and add to changelog

* Update CONTRIBUTING.md

* Add release procedure

* Add in more contributing guide

* Edit PR template

* Update .github/PULL_REQUEST_TEMPLATE.md

Co-authored-by: Verena Chung <9377970+vpchung@users.noreply.github.com>

Co-authored-by: Verena Chung <9377970+vpchung@users.noreply.github.com>

* writeup commands (#130)

* validate project function

* added output param to command; added unittest plans

* bug fix; add archive_project function

* refactor writeups into smaller functions

* added tests

* adding validation status to return value of validate_project()

* updated validateproject doc; changed default "public" value to False

* added tests for overall command functionality

* added docstrings to tests

* Update docstring to follow Google standards

Co-Authored-By: Thomas Yu <thomas.yu@sagebase.org>

* update names; modularize permissions function further; update tests

* fixed and added remaining tests; update package paths

* use entity name as new archive name

* Update challengeutils/project_submission.py

Co-authored-by: Thomas Yu <thomas.yu@sagebase.org>

* removed import alias and unused imports; parametrized tests

Co-authored-by: verena <vpchung@users.noreply.github.com>
Co-authored-by: Thomas Yu <thomas.yu@sagebase.org>

* Updating annotations (#180)

* Test annotations

* Add in support to update a submission's status in annotation submission

* Fix tess

* Add tests for converting dict or synapse style annotations to Annotations cls

* Test updating annotations

* Add EOL

* Add line

* Fix

* Increase version

* Increase version in conf.py

* Add to docs

* Add function

* Add to docs

* Patch convert to synapse cls

* Add in function to delete submission (#182)

* Add to docs and update cli syntax

* Upgrade synapseclient to 2.1.0 (#185)

* Update required synapseclient version to 2.1.0

* Remove redundant functions that are already in synapseclient

* No need to mock a response

* No longer need to return status code while using with_retry function

* Rename cli (#188)

* Add thread service (#184)

* Add Thread model

* Add in typing

* use kwargs when possible

* Add typing

* Fix comments

* Fix tests

* Update challengeutils/synapseservices/discussion.py

* Add reply service (#189)

* Add in reply service

* Use kwargs and use Reply obj

* use Reply obj

* Fix

* Fix test

* Fix discussion tests

* Update challengeutils/synapseservices/discussion.py

* Update challengeutils/discussion.py

* Patch project sub (#191)

* Fix

* add tests

* update conditional for private writeup with admin access

Co-authored-by: verena <9377970+vpchung@users.noreply.github.com>

* validate docker submission (#86)

* validate docker

* Add in validate docker script

* Remove

* Remove

* Add doc string

* Add doc string

* Add validate docker submission

* Lint

* Remove params

* Rework validate docker

* Rename

* Simply code

* Update

* Remove extra line

* Simply cli

* Define invalid reasons first

* Add command validate docker to docs

* Test docker tools

* Add tests

* Test validate docker

* Complete tests for validate docker

* Fix

* Import Response model

* Fix dockertools

* Create submission module

* Change project_submission to submission

* Move functions arond

* Rename

* Fix tests and shift functions around

* Remove download current leading submission and put in submission.py (#193)

* Fix tests

* Remove test and fix cli

* Fix validate docker

* Remove

* lint

* add logic for private writeup that must be shared with admin (#195)

* add logic for private writeup that must be shared with admin

* error message for admin permissions should not print if `public` is flagged

* move try-catch to each permissions check; add and edit tests

Co-authored-by: verena <vpchung@users.noreply.github.com>

* Add annotate sub (#194)

* add annotate_submission that just takes in json

* Fix tests

* Don't add in annotations if None or empty list

* Test None and [] annotation values aren't added

* Update docs (#192)

* Update docs

* update docs and version

* Fix

* No longer support synapseclient<2.1.0

* Add submission id

* Add in docker validate

* Fix

* Fix docs

* Add -dev

* Add in function to remove members from team (#197)

* Add in function to remove members from team

* Remove extra space

* Use github token instead of personal access token (#199)

* update synapse to at least v2.2.0 (#200)

* Update challengeutils/__version__.py

* Get team member count rest call (#201)

* Get team member count rest call

* Add tests

* Add tests

* Update tests/test_teams.py

* Update challengeutils/__version__.py

* Move to team module (#202)

* move team related functions to team module

* ilnt

Co-authored-by: Verena Chung <9377970+vpchung@users.noreply.github.com>
Co-authored-by: verena <vpchung@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 1, 2021
1 parent e2c5331 commit 496535f
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sphinx-ghpages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:
with:
branch: gh-pages
directory: gh-pages
github_token: ${{ secrets.ACCESS_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
# ===============================
2 changes: 1 addition & 1 deletion challengeutils/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.0"
__version__ = "3.1.0"
120 changes: 120 additions & 0 deletions challengeutils/teams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
"""Team related functions"""
from typing import Union

from synapseclient import Synapse, Team, UserProfile
from synapseclient.core.utils import id_of


def _get_team_count(syn: Synapse, teamid: int) -> dict:
"""Rest call wrapper for getting team member count
Args:
syn: Synapse object
teamid: Synapse team id
"""
count = syn.restGET(f"/teamMembers/count/{teamid}")
return count


def get_team_count(syn: Synapse, team: Union[int, str, Team]) -> int:
"""Get number of team members
Args:
syn: Synapse object
team: synaspeclient.Team, its id, or name.
"""
team_obj = syn.getTeam(team)
count = _get_team_count(syn, team_obj.id)
return count['count']


def remove_team_member(syn, team, user):
"""Removes team member
Args:
syn: Synapse object
team: synaspeclient.Team or its id
user: synapseclient.UserProfile or its id
"""
teamid = id_of(team)
userid = id_of(user)
syn.restDELETE(f"/team/{teamid}/member/{userid}")


class NewUserProfile(UserProfile):
'''
Create new user profile that makes Userprofiles hashable
SYNPY-879
'''
def __hash__(self):
return int(self['ownerId'])


def _get_team_set(syn, team):
'''
Helper function to return a set of usernames
Args:
syn: Synapse object
team: Synapse team id, name or object
Returns:
Set of synapse user profiles in team
'''
members = syn.getTeamMembers(team)
members_set = set(NewUserProfile(**member['member']) for member in members)
return members_set


def team_members_diff(syn, a, b):
'''
Calculates the diff between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of synapse user profiles in teama but not in teamb
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
members_not_in_teamb = uniq_teama_members.difference(uniq_teamb_members)
return members_not_in_teamb


def team_members_intersection(syn, a, b):
'''
Calculates the intersection between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of synapse user profiles that belong in both teams
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
intersect_members = uniq_teama_members.intersection(uniq_teamb_members)
return intersect_members


def team_members_union(syn, a, b):
'''
Calculates the union between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of a combination of synapse user profiles from both teams
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
union_members = uniq_teama_members.union(uniq_teamb_members)
return union_members
80 changes: 1 addition & 79 deletions challengeutils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from synapseclient.annotations import (is_submission_status_annotations,
to_submission_status_annotations)
from synapseclient.core.exceptions import SynapseHTTPError
from synapseclient.core.utils import id_of

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -285,85 +286,6 @@ def change_all_submission_status(syn, evaluationid, submission_status='SCORED',
syn.store(status)


class NewUserProfile(synapseclient.team.UserProfile):
'''
Create new user profile that makes Userprofiles hashable
SYNPY-879
'''
def __hash__(self):
return int(self['ownerId'])


def _get_team_set(syn, team):
'''
Helper function to return a set of usernames
Args:
syn: Synapse object
team: Synapse team id, name or object
Returns:
Set of synapse user profiles in team
'''
members = syn.getTeamMembers(team)
members_set = set(NewUserProfile(**member['member']) for member in members)
return members_set


def team_members_diff(syn, a, b):
'''
Calculates the diff between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of synapse user profiles in teama but not in teamb
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
members_not_in_teamb = uniq_teama_members.difference(uniq_teamb_members)
return members_not_in_teamb


def team_members_intersection(syn, a, b):
'''
Calculates the intersection between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of synapse user profiles that belong in both teams
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
intersect_members = uniq_teama_members.intersection(uniq_teamb_members)
return intersect_members


def team_members_union(syn, a, b):
'''
Calculates the union between teama and teamb
Args:
syn: Synapse object
a: Synapse Team id or name
b: Synapse Team id or name
Returns:
Set of a combination of synapse user profiles from both teams
'''
uniq_teama_members = _get_team_set(syn, a)
uniq_teamb_members = _get_team_set(syn, b)
union_members = uniq_teama_members.union(uniq_teamb_members)
return union_members


def _check_date_range(date_str, start_datetime, end_datetime):
'''
Helper function to check if the date is within range
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pandas==1.0.1
synapseclient==2.1.0
synapseclient==2.2.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
scripts=['bin/runqueue.py'],
entry_points={'console_scripts': ['challengeutils = challengeutils.__main__:main']},
install_requires=['pandas>=1.0.0',
'synapseclient>2'])
'synapseclient>=2.2.0'])
57 changes: 0 additions & 57 deletions tests/test_get_team_stats.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
evaluationId=2, versionNumber=1,
id="syn222", filePath="foo",
userId="222")
SUBMISSION_STATUS = synapseclient.SubmissionStatus(status="RECEIVED")
SUBMISSION_STATUS = synapseclient.SubmissionStatus(status="RECEIVED", id="111", etag="222")
EVALUATION = synapseclient.Evaluation(name="foo", id="222",
contentSource=CHALLENGE_SYNID)
SYN_USERPROFILE = synapseclient.UserProfile(ownerId="111", userName="foo")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
evaluationId=2, versionNumber=1,
id="syn222", filePath="foo",
userId="222")
SUBMISSION_STATUS = synapseclient.SubmissionStatus(status="RECEIVED")
SUBMISSION_STATUS = synapseclient.SubmissionStatus(status="RECEIVED", id="111", etag="222")
EVALUATION = synapseclient.Evaluation(name="foo", id="222",
contentSource=CHALLENGE_SYNID)
SYN_USERPROFILE = synapseclient.UserProfile(ownerId="111", userName="foo")
Expand Down
Loading

0 comments on commit 496535f

Please sign in to comment.