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

Harmonic bias results unaccessible during unpickling due to lack of 'ncalls' parameter provided during __new__ #298

Closed
ap-uchi opened this issue Feb 9, 2024 · 1 comment · Fixed by #304

Comments

@ap-uchi
Copy link

ap-uchi commented Feb 9, 2024

Issue: When unpickling harmonic bias results, HarmonicBiasState requires ncalls but SamplingMethodMeta fails to provide that parameter.

TypeError                                 Traceback (most recent call last)
Cell In[10], [line 2](vscode-notebook-cell:?execution_count=10&line=2)
      [1](vscode-notebook-cell:?execution_count=10&line=1) with open('results.pkl', 'rb') as f:
----> [2](vscode-notebook-cell:?execution_count=10&line=2)     results = pickle.load(f)

TypeError: HarmonicBiasState.__new__() missing 1 required positional argument: 'ncalls'

Steps to reproduce: run a harmonic bias simulation and try to unpickle the results.

PySAGES version: 0.4.1.dev3+gcd6b0a9

@pabloferz
Copy link
Member

pabloferz commented Feb 13, 2024

By any chance are you trying to deserialize an "older" pickle file. In #292 we introduced a breaking change that changed our serialization. We are trying to figure out a way to fix this for existing users. For the time being you'd have to install a version that does not contain the changes in #292 and onwards.

@trunk-io trunk-io bot closed this as completed in #304 Feb 28, 2024
trunk-io bot pushed a commit that referenced this issue Feb 28, 2024
This adds two new functions `pysages.save` and `pysages.load` that handle serialize+write to and read+deserialize from a file, respectively.

If a file was pickled before #292, `pysages.load` tries to workaround the fact that previous sampling method classes didn't contain a `ncalls` field.

Closes #298
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 a pull request may close this issue.

2 participants