-
Notifications
You must be signed in to change notification settings - Fork 543
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
Dataset is not unpickled correctly #893
Comments
iddan
changed the title
Dataset is not pickled correctly
Dataset is not unpickled correctly
Jan 20, 2019
I've managed to fix it: from rdflib.graph import Dataset
class FixedDataset(Dataset):
def __reduce__(self):
return (type(self), (self.store, self.default_union))
def __getstate__(self):
return self.store, self.identifier, self.default_context, self.default_union
def __setstate__(self, state):
self.store, self.identifier, self.default_context, self.default_union = state
# TEST
import pickle
from rdflib.namespace import Namespace
example = Namespace("http://example.com#")
fixed = FixedDataset()
one = fixed.graph(example.one)
one.add((example.dan, example.knows, example.lisa))
one.add((example.lisa, example.knows, example.dan))
two = fixed.graph(example.two)
two.add((example.ben, example.knows, example.lisa))
two.add((example.lisa, example.knows, example.ben))
assert set(fixed.quads((None, None, None, None))) == set(fixed.quads((None, None, None, None)))
picklestring = pickle.dumps(fixed)
new_fixed = pickle.loads(picklestring)
for new_graph, graph in zip(new_fixed.graphs(), fixed.graphs()):
assert new_graph.identifier == graph.identifier
for new_triple, triple in zip(new_graph.triples((None, None, None)), graph.triples((None, None, None))):
assert new_triple == triple |
ghost
mentioned this issue
Dec 12, 2021
Merged
Fixed in #1501 |
ghost
closed this as completed
Dec 19, 2021
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dataset is unpickeld as ConjuctiveGraph because it extends ConjuctiveGraph and inherits the
__reduce__()
method. It should be unpickled as Dataset instead.The text was updated successfully, but these errors were encountered: