Skip to content

Commit 4a42fe1

Browse files
author
The TensorFlow Datasets Authors
committed
Allow pickling support for sub classes of DatasetBuilder.
PiperOrigin-RevId: 681701404
1 parent e857b29 commit 4a42fe1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tensorflow_datasets/core/dataset_builder.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,13 @@ def code_path(cls) -> Optional[epath.Path]:
354354
return epath.Path(filepath)
355355

356356
def __getstate__(self):
357-
return self._original_state
357+
# This needs to be of the same format as __dict__,
358+
# to match with the pickling implementation of the derived classes.
359+
return dict(_original_state=self._original_state)
358360

359361
def __setstate__(self, state):
360-
self.__init__(**state)
362+
original_state = state["_original_state"]
363+
self.__init__(**original_state)
361364

362365
@functools.cached_property
363366
def canonical_version(self) -> utils.Version:

0 commit comments

Comments
 (0)