-
Notifications
You must be signed in to change notification settings - Fork 75
[SYNPY-1861] remove submissionInstructionsMessage and submissionReceiptMessage from required attributes #1401
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
base: develop
Are you sure you want to change the base?
Changes from all commits
385c8cb
5800f93
ccb2709
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,11 +33,11 @@ class Evaluation(EvaluationSynchronousProtocol): | |
| etag: Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. | ||
| The eTag changes every time an Evaluation is updated; it is used to detect when a client's copy | ||
| of an Evaluation is out-of-date. | ||
| name: The name of this Evaluation. | ||
| description: A text description of this Evaluation. | ||
| name: **Required to store.** The name of this Evaluation. | ||
| description: **Required to store.** A text description of this Evaluation. | ||
| owner_id: The ID of the Synapse user who created this Evaluation. | ||
| created_on: The date on which Evaluation was created. | ||
| content_source: The Synapse ID of the Entity to which this Evaluation belongs, | ||
| content_source: **Required to store.** The Synapse ID of the Entity to which this Evaluation belongs, | ||
| e.g. a reference to a Synapse project. | ||
| submission_instructions_message: Message to display to users detailing acceptable formatting for Submissions to this Evaluation. | ||
| submission_receipt_message: Message to display to users upon successful submission to this Evaluation. | ||
|
|
@@ -56,8 +56,6 @@ class Evaluation(EvaluationSynchronousProtocol): | |
| name="My Challenge Evaluation", | ||
| description="Evaluation for my data challenge", | ||
| content_source="syn123456", | ||
| submission_instructions_message="Submit CSV files only", | ||
| submission_receipt_message="Thank you for your submission!", | ||
| ) | ||
| created = evaluation.store() | ||
| ``` | ||
|
|
@@ -123,10 +121,10 @@ class Evaluation(EvaluationSynchronousProtocol): | |
| of an Evaluation is out-of-date.""" | ||
|
|
||
| name: Optional[str] = None | ||
| """The name of this Evaluation.""" | ||
| """**Required to store.** The name of this Evaluation.""" | ||
|
Comment on lines
123
to
+124
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For discussion, should there be an
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the idea is that "name" is required when calling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Lingling here on both counts.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should type hinting be... instead of |
||
|
|
||
| description: Optional[str] = None | ||
| """A text description of this Evaluation.""" | ||
| """**Required to store.** A text description of this Evaluation.""" | ||
|
|
||
| owner_id: Optional[str] = None | ||
| """The ID of the Synapse user who created this Evaluation.""" | ||
|
|
@@ -135,7 +133,7 @@ class Evaluation(EvaluationSynchronousProtocol): | |
| """The date on which Evaluation was created.""" | ||
|
|
||
| content_source: Optional[str] = None | ||
| """The Synapse ID of the Entity to which this Evaluation belongs, | ||
| """**Required to store.** The Synapse ID of the Entity to which this Evaluation belongs, | ||
| e.g. a reference to a Synapse project.""" | ||
|
|
||
| submission_instructions_message: Optional[str] = None | ||
|
|
@@ -255,8 +253,6 @@ def to_synapse_request(self, request_type: RequestType): | |
| "name", | ||
| "description", | ||
| "content_source", | ||
| "submission_instructions_message", | ||
| "submission_receipt_message", | ||
| ] | ||
|
|
||
| # For "update" requests, add id and etag | ||
|
|
@@ -274,9 +270,13 @@ def to_synapse_request(self, request_type: RequestType): | |
| "name": self.name, | ||
| "description": self.description, | ||
| "contentSource": self.content_source, | ||
| "submissionInstructionsMessage": self.submission_instructions_message, | ||
| "submissionReceiptMessage": self.submission_receipt_message, | ||
| } | ||
| if self.submission_instructions_message is not None: | ||
| request_body["submissionInstructionsMessage"] = ( | ||
| self.submission_instructions_message | ||
| ) | ||
| if self.submission_receipt_message is not None: | ||
| request_body["submissionReceiptMessage"] = self.submission_receipt_message | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't |
||
| # For UPDATE request types, add id and etag | ||
| if request_type == RequestType.UPDATE: | ||
|
|
@@ -307,7 +307,7 @@ async def store_async( | |
|
|
||
| Example: Creating a new evaluation | ||
| | ||
| Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised. | ||
| Create a new evaluation on Synapse by storing an evaluation object with the required fields. | ||
| ```python | ||
| from synapseclient.models import Evaluation | ||
| from synapseclient import Synapse | ||
|
|
@@ -321,8 +321,6 @@ async def create_evaluation(): | |
| name="My Challenge Evaluation", | ||
| description="Evaluation for my data challenge", | ||
| content_source="syn123456", | ||
| submission_instructions_message="Submit CSV files only", | ||
| submission_receipt_message="Thank you for your submission!" | ||
| ).store_async() | ||
|
|
||
| return evaluation | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,23 @@ def init(self, syn: Synapse, schedule_for_cleanup: Callable[..., None]) -> None: | |
| self.syn = syn | ||
| self.schedule_for_cleanup = schedule_for_cleanup | ||
|
|
||
| async def test_create_evaluation(self): | ||
| # GIVEN a project to work with | ||
| @pytest.fixture(scope="class") | ||
| async def test_project( | ||
| self, syn: Synapse, schedule_for_cleanup: Callable[..., None] | ||
| ) -> Project: | ||
| """Create a test project for evaluation creation tests.""" | ||
| project = await Project(name=f"test_project_{uuid.uuid4()}").store_async( | ||
| synapse_client=self.syn | ||
| synapse_client=syn | ||
| ) | ||
| self.schedule_for_cleanup(project.id) | ||
| schedule_for_cleanup(project.id) | ||
| return project | ||
|
|
||
| async def test_create_evaluation(self, test_project: Project): | ||
| # WHEN I create an evaluation using the dataclass method | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="A test evaluation for testing purposes", | ||
| content_source=project.id, | ||
| content_source=test_project.id, | ||
| submission_instructions_message="Please submit your results in CSV format", | ||
| submission_receipt_message="Thank you for your submission!", | ||
| ) | ||
|
|
@@ -42,10 +47,28 @@ async def test_create_evaluation(self): | |
| assert ( | ||
| created_evaluation.description == "A test evaluation for testing purposes" | ||
| ) | ||
| assert created_evaluation.content_source == project.id | ||
| assert created_evaluation.content_source == test_project.id | ||
| assert created_evaluation.owner_id is not None # Check that owner_id is set | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the entire
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
| assert created_evaluation.created_on is not None # Check that created_on is set | ||
|
|
||
| async def test_create_evaluation_without_optional_message_fields( | ||
| self, test_project: Project | ||
| ): | ||
| # WHEN I create an evaluation without submission_instructions_message or submission_receipt_message | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="A test evaluation without optional message fields", | ||
| content_source=test_project.id, | ||
| ) | ||
| created_evaluation = await evaluation.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_evaluation.id) | ||
|
|
||
| # THEN the evaluation should be created successfully | ||
| assert created_evaluation.id is not None | ||
| assert created_evaluation.etag is not None | ||
| assert created_evaluation.name == evaluation.name | ||
| assert created_evaluation.content_source == test_project.id | ||
|
|
||
|
|
||
| class TestGetEvaluation: | ||
| @pytest.fixture(autouse=True, scope="function") | ||
|
|
@@ -294,6 +317,31 @@ async def test_update_multiple_fields(self, test_evaluation: Evaluation): | |
| assert updated_evaluation.etag is not None | ||
| assert updated_evaluation.etag != old_etag | ||
|
|
||
| async def test_update_evaluation_without_optional_message_fields( | ||
| self, test_project: Project | ||
| ): | ||
| # GIVEN an evaluation created without submission message fields | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="A test evaluation without optional messages", | ||
| content_source=test_project.id, | ||
| ) | ||
| created_evaluation = await evaluation.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_evaluation.id) | ||
|
|
||
| # WHEN I update a field on that evaluation (still without message fields) | ||
| new_description = f"Updated description {uuid.uuid4()}" | ||
| created_evaluation.description = new_description | ||
| updated_evaluation = await created_evaluation.store_async( | ||
| synapse_client=self.syn | ||
| ) | ||
|
|
||
| # THEN the update should succeed | ||
| assert updated_evaluation.description == new_description | ||
| assert updated_evaluation.id == created_evaluation.id | ||
| assert updated_evaluation.submission_instructions_message is None | ||
| assert updated_evaluation.submission_receipt_message is None | ||
|
jaymedina marked this conversation as resolved.
|
||
|
|
||
| async def test_store_unchanged_evaluation( | ||
| self, test_evaluation: Evaluation, monkeypatch | ||
| ): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,40 @@ async def test_store_submission_successfully_async( | |
| assert created_submission.created_on is not None | ||
| assert created_submission.version_number is not None | ||
|
|
||
| async def test_store_submission_to_evaluation_without_message_fields_async( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the submission tests shouldn't care whether
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: This comment has been generated with AI assistance and reviewed by me ✍️ The intent of |
||
| self, | ||
| test_project: Project, | ||
| test_file: File, | ||
| ): | ||
| # GIVEN an evaluation created without submission_instructions_message or submission_receipt_message | ||
| evaluation = Evaluation( | ||
| name=f"test_evaluation_{uuid.uuid4()}", | ||
| description="Evaluation without optional message fields", | ||
| content_source=test_project.id, | ||
| ) | ||
| created_evaluation = await evaluation.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_evaluation.id) | ||
|
|
||
| # WHEN I submit to that evaluation | ||
| submission = Submission( | ||
| entity_id=test_file.id, | ||
| evaluation_id=created_evaluation.id, | ||
| name=f"Test Submission {uuid.uuid4()}", | ||
| ) | ||
| created_submission = await submission.store_async(synapse_client=self.syn) | ||
| self.schedule_for_cleanup(created_submission.id) | ||
|
|
||
| # THEN the submission should be created successfully | ||
| assert created_submission.id is not None | ||
| assert created_submission.entity_id == test_file.id | ||
| assert created_submission.evaluation_id == created_evaluation.id | ||
|
|
||
| # AND retrieving the submission should also work | ||
| retrieved = await Submission(id=created_submission.id).get_async( | ||
| synapse_client=self.syn | ||
| ) | ||
| assert retrieved.id == created_submission.id | ||
|
|
||
| async def test_store_submission_without_entity_id_async( | ||
| self, test_evaluation: Evaluation | ||
| ): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.