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

Saving and loading Partition object #409

Closed
itsSauravK opened this issue Apr 8, 2023 · 3 comments
Closed

Saving and loading Partition object #409

itsSauravK opened this issue Apr 8, 2023 · 3 comments

Comments

@itsSauravK
Copy link

itsSauravK commented Apr 8, 2023

I have been going through the documentation and previous issues. I was looking for a way to save Partition objects generated from the Markov chain once, save it as a Json file and then load the same Json as a Partition object in other code so I can recompute everything using the same data

Would really appreciate any help on this.

@cdonnay
Copy link
Contributor

cdonnay commented Jun 13, 2023

My work around for this is to use the pickle module, and to only try to save the assignment dictionary from each Partition object, rather than the entire Partition object. Then, to use it later, I load in the pickle file with the assignments, and create Partitions using the assignments.

@peterrrock2
Copy link
Collaborator

Ah, there is a bit of nuance that is worth mentioning here.

So, in general, using the pickle module is a good approach for saving intermediate Partition objects, but this will not work in general as is evidenced in #325. In fact, making these work in general is undesirable behavior since we sometimes need/want to write updaters in terms of lambda functions which are inherently unpickle-able. However, if you are looking to just replay your chain so that you can either use PCompress, or if you would like to save intermediate stats, you may reference the "Good Data Practices" section of the documentation coming out in version 0.3.0 here in the next couple of days. If you need any other assistance, please let us know!

@peterrrock2 peterrrock2 mentioned this issue Feb 1, 2024
@itsSauravK
Copy link
Author

Thank you!

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

3 participants