Skip to content

Commit 05e5218

Browse files
committed
add evaluation_round_id and explicit optional_fields dict for organization
1 parent 8ef400a commit 05e5218

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

synapseclient/models/submission.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class Submission(
300300
entity_id: The ID of the entity being submitted.
301301
version_number: The version number of the entity at submission.
302302
evaluation_id: The ID of the Evaluation to which this Submission belongs.
303+
evaluation_round_id: The ID of the EvaluationRound to which this was submitted (auto-filled upon creation).
303304
name: The name of this Submission.
304305
created_on: The date this Submission was created.
305306
team_id: The ID of the team that submitted this submission (if it's a team submission).
@@ -353,6 +354,11 @@ class Submission(
353354
The ID of the Evaluation to which this Submission belongs.
354355
"""
355356

357+
evaluation_round_id: Optional[str] = field(default=None, compare=False)
358+
"""
359+
The ID of the EvaluationRound to which this was submitted. DO NOT specify a value for this. It will be filled in automatically upon creation of the Submission if the Evaluation is configured with an EvaluationRound.
360+
"""
361+
356362
name: Optional[str] = None
357363
"""
358364
The name of this Submission.
@@ -420,6 +426,7 @@ def fill_from_dict(
420426
self.entity_id = synapse_submission.get("entityId", None)
421427
self.version_number = synapse_submission.get("versionNumber", None)
422428
self.evaluation_id = synapse_submission.get("evaluationId", None)
429+
self.evaluation_round_id = synapse_submission.get("evaluationRoundId", None)
423430
self.name = synapse_submission.get("name", None)
424431
self.created_on = synapse_submission.get("createdOn", None)
425432
self.team_id = synapse_submission.get("teamId", None)
@@ -524,16 +531,20 @@ def to_synapse_request(self) -> dict:
524531
}
525532

526533
# Add optional fields if they are set
527-
if self.name is not None:
528-
request_body["name"] = self.name
529-
if self.team_id is not None:
530-
request_body["teamId"] = self.team_id
531-
if self.contributors:
532-
request_body["contributors"] = self.contributors
533-
if self.docker_repository_name is not None:
534-
request_body["dockerRepositoryName"] = self.docker_repository_name
535-
if self.docker_digest is not None:
536-
request_body["dockerDigest"] = self.docker_digest
534+
optional_fields = {
535+
"name": "name",
536+
"team_id": "teamId",
537+
"contributors": "contributors",
538+
"docker_repository_name": "dockerRepositoryName",
539+
"docker_digest": "dockerDigest",
540+
}
541+
542+
for field_name, api_field_name in optional_fields.items():
543+
field_value = getattr(self, field_name)
544+
if field_value is not None and (
545+
field_name != "contributors" or field_value
546+
):
547+
request_body[api_field_name] = field_value
537548

538549
return request_body
539550

0 commit comments

Comments
 (0)