Skip to content

[SYNPY-1863] deepcopy annotations in SubmissionStatus._set_last_persistent_instance#1414

Merged
jaymedina merged 5 commits into
developfrom
synpy-1863-submissionstatus-updates
Jun 26, 2026
Merged

[SYNPY-1863] deepcopy annotations in SubmissionStatus._set_last_persistent_instance#1414
jaymedina merged 5 commits into
developfrom
synpy-1863-submissionstatus-updates

Conversation

@jaymedina

@jaymedina jaymedina commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Problem:

When calling <SubmissionStatusObject>.submission_annotations.update() on a SubmissionStatus object, the dataclass does not register a change and throws a warning that the object has not been modified, resulting in the annotations never being correctly posted to Synapse.

Solution:

Implement the pattern already established in the repository (example: Project OOP model) by performing deepcopy on mutable objects, such as dicts, while performing replace (shallow copy) on immutable objects where it doesn't matter if the 2 instances (last and current) share references.

This should prevent issues with the client not detecting changes to the dataclass instance when a user performs in-place mutations instead of re-assigning the attribute, i.e:

# doing this
my_status.annotations.update({"status": "PASSED"})

# instead of this
my_status.annotations = {"status": "PASSED"}

Testing:

✅ Can no longer reproduce user-error

image

New tests that cover in-place mutation scenarios are passing:

image

@jaymedina jaymedina marked this pull request as ready for review June 26, 2026 18:42
@jaymedina jaymedina requested a review from a team as a code owner June 26, 2026 18:42
Copilot AI review requested due to automatic review settings June 26, 2026 18:42
Comment thread tests/integration/synapseclient/models/async/test_submission_status_async.py Outdated

@BryanFauble BryanFauble left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get away with a unit test only for this change to verify the has_changed and this _set_last_persistent_instance logic?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes change-tracking on SubmissionStatus so in-place mutations to mutable annotation fields (e.g., dict.update()) are detected and persisted, avoiding “object has not been modified” warnings and missed updates.

Changes:

  • Deep-copies annotations and submission_annotations when stashing _last_persistent_instance to prevent shared references.
  • Adds async integration tests covering in-place mutation scenarios for both annotation containers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
synapseclient/models/submission_status.py Adjusts last-persistent snapshotting to avoid shared references for mutable annotation fields.
tests/integration/synapseclient/models/async/test_submission_status_async.py Adds integration tests asserting in-place dict mutations are detected and stored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread synapseclient/models/submission_status.py
Comment thread tests/integration/synapseclient/models/async/test_submission_status_async.py Outdated
Comment thread tests/integration/synapseclient/models/async/test_submission_status_async.py Outdated

@andrewelamb andrewelamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jaymedina jaymedina requested a review from BryanFauble June 26, 2026 20:03
@jaymedina jaymedina enabled auto-merge (squash) June 26, 2026 20:04
@jaymedina jaymedina merged commit be5b55d into develop Jun 26, 2026
17 of 23 checks passed
@jaymedina jaymedina deleted the synpy-1863-submissionstatus-updates branch June 26, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants