-
Notifications
You must be signed in to change notification settings - Fork 36
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
deep copy not copying data #153
Comments
Thank you for reporting! Which Python version are you running? |
@berceanu I'm having trouble reproducing the bug. Can you verify that this unit test should trigger the described behavior? |
This triggers the confusing behavior: import copy
import os
import signac
pr = signac.init_project('issue_153')
job = pr.open_job({'a': 1})
job.init()
print(job._id) # 42b7b4f2921788ea14dac5566e6f06d0
copy_sp_bug = copy.deepcopy(job.sp)
copy_sp_bug['a'] = '🐛'
print(job.sp) # {'a': 1}
print(copy_sp_bug) # {'a': '🐛'}
print(list(iter(project))) # [signac.contrib.job.Job(project=signac.contrib.project.Project({'project': 'issue_153', 'project_dir': '/home/bdice/tmp_signac_153', 'workspace_dir': '/home/bdice/tmp_signac_153/workspace'}), statepoint={'a': '🐛'})]
assert job in project # fails! We have a job handle that doesn't exist in the project anymore...? |
After looking more closely at this issue, we have come to the conclusion that it actually makes most sense that a copy or a deepcopy will still modify the underlying state point and thus job albeit operating on a different in-memory reference. That is because a state point and a job for that matter are directly tied to a specific location on the file system and that doesn't change just because we have a different reference. What users actually intend when they create a deepcopy of a state point is to generate a We have fixed the deepcopy behavior of To help avoid user confusion, we will need to improve the documentation on how to convert state points to dicts (glotzerlab/signac-docs#39). |
results in changes to the workspace folder, i.e. the removing of parameter 'a' from
signac_statepoint.json
.The text was updated successfully, but these errors were encountered: