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

Support pickling #640

Closed
2 tasks done
malcolmbarrett opened this issue Mar 18, 2025 · 0 comments · Fixed by #641
Closed
2 tasks done

Support pickling #640

malcolmbarrett opened this issue Mar 18, 2025 · 0 comments · Fixed by #641

Comments

@malcolmbarrett
Copy link

Prework

Proposal

I'm trying to load pre-computed gt tables in Quarto files using pickling. Unfortunately, unpickling doesn't work

from great_tables import GT
from great_tables.data import islands
import pickle
islands_mini = islands.head(10)
gt_tbl = GT(islands_mini)

with open("gt.pkl", "wb") as f:
    pickle.dump(gt_tbl, f)

with open("gt.pkl", "rb") as f:
    gt_tbl2 = pickle.load(f)

gives me

TypeError: Boxhead.__new__() missing 1 required positional argument: 'data'
Cell In[42], line 11
      8     pickle.dump(gt_tbl, f)
     10 with open("gt.pkl", "rb") as f:
---> 11     gt_tbl2 = pickle.load(f)

It seems that supporting unpickling would require and additional method on the GT side: https://stackoverflow.com/a/37753992

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant