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

Error pickling MCNP_Problem: Cannot pickle 'generator' object #463

Open
tjlaboss opened this issue Jul 25, 2024 · 5 comments
Open

Error pickling MCNP_Problem: Cannot pickle 'generator' object #463

tjlaboss opened this issue Jul 25, 2024 · 5 comments
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". low priority

Comments

@tjlaboss
Copy link
Collaborator

tjlaboss commented Jul 25, 2024

Cannot pickle montepy.MCNP_Problem objects.

Describe the bug

Since v0.3.0, can no longer pickle montepy.MCNP_Problem for more complicated input decks. The MCNP_Problem contains an unpicklable generator object. Rolling back to v0.2.10 fixes this.

This occurs when the problem contains tallies (possibly other non-implemented data cards?).

This is not caught by tests/test_interface.py::TestBrinyFermentation .

To Reproduce / Error Message

>>> deck = montepy.read_input("path/to/input.imcnp")
>>> with open("path/to/pickle.pkl", 'wb') as pkl:
...    pickle.dump(deck, pkl)
TypeError: cannot pickle 'generator' object

MCNP input file snippet

MCNP Test Model for Tallies
1 1 20 -1000  imp:n,p=1 U=350 trcl=5
2 2 8  -1005  imp:n=1    imp:p=0.5
3 3 -1  1000 1005 -1010 imp:n,p=1
99 0 1010     imp:n,p=0
5 0   #99     imp:n,p=3 fill=350 (1 0 0 ) 

C surfaces
1000 SO 1
1005 RCC 0 1.5 -0.5 0 0 1 0.25
1010 SO 3

C data
C materials
C UO2 5 atpt enriched
m1        92235.80c           5 &
92238.80c          95
C Iron
m2        26054.80c        5.85
          26056.80c       91.75
          26057.80c        2.12
          26058.80c        0.28 
C water
m3        1001.80c           2
          8016.80c           1
MT3 lwtr.23t h-zr.20t h/zr.28t
C
C Tallies --> This breaks MontePy!
f7:n 1
C
C execution
ksrc 0 0 0 
kcode 100000 1.000 50 1050
phys:p j 1 2j 1
mode n p 
vol NO 2J 1 1.5 J

Versions

  • 0.3.0,
  • 0.3.1,
  • 0.3.2
@tjlaboss tjlaboss added the bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". label Jul 25, 2024
@MicahGale
Copy link
Collaborator

This sounds familiar to an old issue.

@tjlaboss
Copy link
Collaborator Author

tjlaboss commented Aug 2, 2024

Issue #189

Something broke the ability to pickle inputs between then and now (for inputs with some as-yet unidentified complexity that is not tested tallies).

@tjlaboss
Copy link
Collaborator Author

tjlaboss commented Aug 2, 2024

Created #468 to test this.

@MicahGale
Copy link
Collaborator

Thanks for doing this. I'm not sure if tests/inputs/test.imcnp is the best place for this though. Every time the file is updated a lot of tests have to be updated because I hard code in what the file is in a lot of places. Probably not the best test design.

@MicahGale
Copy link
Collaborator

MicahGale commented Aug 13, 2024

Long term: https://docs.python.org/3/library/pickle.html#handling-stateful-objects this is probably a solution that is needed along with #193.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs A deviation from expected behavior that does not reach the level of being reportable as an "Error". low priority
Projects
None yet
Development

No branches or pull requests

2 participants