Skip to content
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

[SYNPY-1443] Correct which fields are merged if there is a change #1072

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

BryanFauble
Copy link
Contributor

Problem:

  1. The usage of asdict was converting the folder/file dataclasses to a dict on the Project class - This pevented further code from calling methods on the Folder/File class.
  File "/home/bfauble/BryansGreatWorkspace/synapsePythonClient/synapseclient/models/project.py", line 308, in store_async
    await store_entity_components(
  File "/home/bfauble/BryansGreatWorkspace/synapsePythonClient/synapseclient/models/services/storable_entity_components.py", line 80, in store_entity_components
    folder.store_async(
AttributeError: 'dict' object has no attribute 'store_async'

Solution:

  1. Only apply changes for modified items. We are not retrieving any dataclasses during the get_async calls during this line besides self - So we won't run into issues where a dataclass is getting replaced by a dict.
  2. If we are to retrieve dataclasses during the get_async calls we'll need to make a small modification to this code to ensure the merge occurs in that dataclass (recursively) and is converted back into the correct class instance. I will take ownership of this problem when we need to cross that bridge.

Testing:

  1. Verified the broken script works as expected:
import synapseclient
from synapseclient.models import Project, Folder, File

syn = synapseclient.login()
file_for_demo = "/home/bfauble/temp/my_file_with_random_data.txt"
my_project_name = "My Super Cool Project"


my_project = Project(name=my_project_name)

my_folder = Folder(name="my folder")

my_file = File(path=file_for_demo)

my_folder.files.append(my_file)

my_project.folders.append(my_folder)

my_project.store()
  1. Integration test around this logic

@BryanFauble BryanFauble requested a review from a team as a code owner February 23, 2024 20:00
Copy link

sonarcloud bot commented Feb 24, 2024

Copy link
Contributor

@danlu1 danlu1 left a comment

Choose a reason for hiding this comment

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

LGTM

@BryanFauble BryanFauble merged commit 75f15e2 into develop Feb 26, 2024
38 checks passed
@BryanFauble BryanFauble deleted the SYNPY-1443-store-before-get-for-containers branch February 26, 2024 16:49
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.

None yet

2 participants