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:
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.
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:
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"
Problem:
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.Solution:
get_async
calls during this line besidesself
- So we won't run into issues where a dataclass is getting replaced by a dict.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:
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()