-
Notifications
You must be signed in to change notification settings - Fork 72
[SYNPY-1589] Implement "Evaluation" OOP model #1244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaymedina
wants to merge
7
commits into
develop
Choose a base branch
from
synpy-1589-evaluation-model-main
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c7d24fd
TDD: initial proof of concept integration tests (async)
jaymedina fc79d2e
[SYNPY-1589] Implement core functionality of Evaluation OOP model (#1…
jaymedina 69a713e
[SYNPY-1589] Implement documentation of Evaluation OOP model (#1247)
jaymedina 2700e51
no colons.
jaymedina 2c7df90
always rely on client logger
jaymedina 74406c4
document refresh
jaymedina 50e6095
update sync update_acl examples
jaymedina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Evaluation | ||
|
|
||
| Contained within this file are experimental interfaces for working with the Synapse Python | ||
| Client. Unless otherwise noted these interfaces are subject to change at any time. Use | ||
| at your own risk. | ||
|
|
||
| ## API reference | ||
|
|
||
| ::: synapseclient.models.Evaluation | ||
| options: | ||
| inherited_members: true | ||
| members: | ||
| - store_async | ||
| - get_async | ||
| - delete_async | ||
| - get_all_evaluations_async | ||
| - get_available_evaluations_async | ||
| - get_evaluations_by_project_async | ||
| - get_acl_async | ||
| - update_acl_async | ||
| - get_permissions_async |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Evaluation | ||
|
|
||
| Contained within this file are experimental interfaces for working with the Synapse Python | ||
| Client. Unless otherwise noted these interfaces are subject to change at any time. Use | ||
| at your own risk. | ||
|
|
||
| ## API reference | ||
|
|
||
| ::: synapseclient.models.Evaluation | ||
| options: | ||
| inherited_members: true | ||
| members: | ||
| - store | ||
| - get | ||
| - delete | ||
| - get_all_evaluations | ||
| - get_available_evaluations | ||
| - get_evaluations_by_project | ||
| - get_acl | ||
| - update_acl | ||
| - get_permissions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Evaluations | ||
| An Evaluation is essentially a container that organizes and manages the submission, assessment, and scoring of data, models, or other research artifacts. | ||
| It allows teams to set up challenges where participants contribute their work, and those contributions can be systematically reviewed or scored. | ||
|
|
||
| This tutorial will walk you through the basics of working with Evaluations using the Synapse Python client. | ||
|
|
||
| ## Tutorial Purpose | ||
| In this tutorial you will: | ||
|
|
||
| 1. Create and update an Evaluation on Synapse | ||
| 1. Update the ACL (Access Control List) of an Evaluation on Synapse | ||
| 1. Retrieve and delete all Evaluations from a given Project | ||
|
|
||
| ## Prerequisites | ||
| * You have completed the [Project](./project.md) tutorial, or have an existing Project on Synapse to work from | ||
| * You have a Synapse user or team ID to share the evaluation with | ||
|
|
||
| ## 1. Create and update an Evaluation on Synapse | ||
|
|
||
| In this first part, we'll be showing you how to interact with an Evaluation object as well as introducing you to its two core functionalities `store()` and `get()`. | ||
|
|
||
| ```python | ||
| {!docs/tutorials/python/tutorial_scripts/evaluation.py!lines=5-46} | ||
| ``` | ||
|
|
||
| ## 2. Update the ACL of an Evaluation on Synapse | ||
|
|
||
| Like Synapse entities, Evaluations have ACLs that can be used to control who has access to your evaluations and what level of access they have. Updating the ACL of an Evaluation object is slightly different from updating other Evaluation components, because the ACL is not an attribute of the Evaluation object. Let's see an example of how this looks: | ||
|
|
||
| ```python | ||
| {!docs/tutorials/python/tutorial_scripts/evaluation.py!lines=54-64} | ||
| ``` | ||
|
|
||
| You can also remove principals from an ACL by simply feeding `update_acl` an empty list for the `access_type` argument, like so: | ||
|
|
||
| ```python | ||
| {!docs/tutorials/python/tutorial_scripts/evaluation.py!lines=66-67} | ||
| ``` | ||
|
|
||
| ## 3. Retrieve and delete all Evaluations from a given Project | ||
|
|
||
| Now we will show how you can retrieve lists of Evaluation objects, rather than retrieving them one-by-one with `get()`. This is a powerful tool if you want to perform the same action on all the evaluations in a given project, for example, like what we're about to do here: | ||
|
|
||
| ```python | ||
| {!docs/tutorials/python/tutorial_scripts/evaluation.py!lines=69-75} | ||
| ``` | ||
|
|
||
| ## Source code for this tutorial | ||
|
|
||
| <details class="quote"> | ||
| <summary>Click to show me</summary> | ||
|
|
||
| ```python | ||
| {!docs/tutorials/python/tutorial_scripts/evaluation.py!} | ||
| ``` | ||
| </details> | ||
|
|
||
| ## References | ||
| - [Evaluation][synapseclient.models.Evaluation] | ||
| - [Project][synapseclient.models.Project] | ||
| - [syn.login][synapseclient.Synapse.login] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """ | ||
| Here is where you'll find the code for the Evaluation tutorial. | ||
| """ | ||
|
|
||
| from synapseclient import Synapse | ||
| from synapseclient.models import Evaluation, Project | ||
|
|
||
| syn = Synapse() | ||
| syn.login() | ||
|
|
||
| # REQUIRED: Set this to the Synapse user ID or team ID you want to grant permissions to | ||
| # Do NOT leave this as None - the script will not work properly | ||
| PRINCIPAL_ID = None # Replace with actual user/team ID | ||
|
|
||
| # Retrieve the Project where your Evaluation will be stored | ||
| project = Project(name="My uniquely named project about Alzheimer's Disease").get() | ||
| project_id = project.id | ||
|
|
||
| print(f"Working within Project: {project_id}") | ||
|
|
||
| # Create a new Evaluation object | ||
| evaluation = Evaluation( | ||
| name="My Challenge Evaluation for Study ABC - Round 1", | ||
| description="Evaluation for my data challenge", | ||
| content_source=project_id, | ||
| submission_instructions_message="Submit CSV files only", | ||
| submission_receipt_message="Thank you for your submission!", | ||
| ) | ||
|
|
||
| # Create the Evaluation on Synapse | ||
| evaluation.store() | ||
|
|
||
| print("Evaluation has been created with the following name and description:") | ||
| print(evaluation.name) | ||
| print(evaluation.description) | ||
|
|
||
| # Update the Evaluation object's name and description | ||
| evaluation.name = "My Challenge Evaluation for Study XYZ - Round 1" | ||
| evaluation.description = "Updated description for my evaluation" | ||
|
|
||
| # Update the Evaluation on Synapse | ||
| evaluation.store() | ||
|
|
||
| print("Evaluation has been updated with the following name and description:") | ||
| print(evaluation.name) | ||
| print(evaluation.description) | ||
|
|
||
| # Confirm what's in Synapse matches the evaluation stored | ||
| from_synapse = Evaluation(id=evaluation.id).get() | ||
|
|
||
| print("The following evaluation has been retrieved from Synapse:") | ||
| print(from_synapse) | ||
|
|
||
| # Update the Evaluation's ACL on Synapse by adding a new user | ||
| assert ( | ||
| PRINCIPAL_ID is not None | ||
| ), "PRINCIPAL_ID must be set to the Synapse user ID or team ID you want to grant permissions to." | ||
|
|
||
| evaluation.update_acl(principal_id=PRINCIPAL_ID, access_type=["READ", "SUBMIT"]) | ||
|
|
||
| # Get the Evaluation's ACL to confirm the update | ||
| acl = evaluation.get_acl() | ||
| print("The following ACL has been retrieved from Synapse:") | ||
| print(acl) | ||
|
|
||
| # Now let's remove the user we just added from the Evaluation's ACL | ||
| evaluation.update_acl(principal_id=PRINCIPAL_ID, access_type=[]) | ||
|
|
||
| # Finally let's retrieve all Evaluations stored within this project, including the one we just created | ||
| evaluations_list = Evaluation.get_evaluations_by_project(project_id) | ||
|
|
||
| # Let's delete the evaluation we created for this tutorial, and any other evaluations in this project (uncomment below to enable deletion) | ||
| # for evaluation_to_delete in evaluations_list: | ||
| # print(f"Deleting evaluation: {evaluation_to_delete.name}") | ||
| # evaluation_to_delete.delete() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intead of having the user going through a loop to delete evaluation, I am thinking if it is possible to just do
evaluation.delete()since the evaluation object was created in previous step.