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

ndtiff Datasets cannot be pickled #109

Open
ieivanov opened this issue Apr 27, 2023 · 3 comments
Open

ndtiff Datasets cannot be pickled #109

ieivanov opened this issue Apr 27, 2023 · 3 comments

Comments

@ieivanov
Copy link
Collaborator

ieivanov commented Apr 27, 2023

Dask arrays created by the ndtiff library cannot be pickled. Pickling is important for multiprocessing applications.

For example,

dataset = Dataset(\path\to\ndtiff\dataset)
data_dask_array = dataset.as_array()
pickle.dumps(data_dask_array)

first throws a AttributeError: Can't pickle local object 'NDTiffDataset.as_array.<locals>.read_one_image', which is fixed by #108. It then throws TypeError: cannot pickle '_thread.RLock' object, which I don't think I'll be able to fix myself.

A workaround may be to open a new dask array in every worker rather than pickling the opened dask array for distribution to workers.

@henrypinkard
Copy link
Member

The lock is meant to handle synchronization on the the datasets index, so that you cant read data if the index is currently being updated. This is specifically for image saved callbacks. I forget what specific problem/bug it was solving, but there are probably better alternatives. In any case, are you trying to do this on an in progress dataset? If not, you could safely ignore that lock because the dataset is read only

@ieivanov
Copy link
Collaborator Author

No, here I am trying to work with a dataset that has finished acquiring. Could we encode a check if the acquisition is in progress and only use the lock then? I am not sure if pickle will be OK with that logic, we could test on a simpler example first

@henrypinkard
Copy link
Member

Yes, if it works with pickle that should work

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

No branches or pull requests

2 participants