Skip to content

Commit 58ca426

Browse files
mxberlotOrbax Authors
authored andcommitted
Internal change
PiperOrigin-RevId: 929755681
1 parent d67048f commit 58ca426

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

checkpoint/orbax/checkpoint/_src/path/atomicity.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
import abc
5656
import asyncio
5757
import concurrent.futures
58-
import pickle
58+
import json
5959
import threading
6060
import time
6161
from typing import Awaitable, Protocol, Sequence, TypeVar
@@ -318,10 +318,10 @@ def to_bytes(self) -> bytes:
318318
Returns:
319319
The serialized object.
320320
"""
321-
return pickle.dumps({
322-
'tmp_path': self._tmp_path,
323-
'final_path': self._final_path,
324-
})
321+
return json.dumps({
322+
'tmp_path': str(self._tmp_path),
323+
'final_path': str(self._final_path),
324+
}).encode('utf-8')
325325

326326
@classmethod
327327
def from_bytes(
@@ -336,10 +336,10 @@ def from_bytes(
336336
Returns:
337337
A ReadOnlyTemporaryPath instance.
338338
"""
339-
data = pickle.loads(data)
339+
parsed_data = json.loads(data.decode('utf-8'))
340340
return cls(
341-
temporary_path=data['tmp_path'],
342-
final_path=data['final_path'],
341+
temporary_path=epath.Path(parsed_data['tmp_path']),
342+
final_path=epath.Path(parsed_data['final_path']),
343343
)
344344

345345
@classmethod

0 commit comments

Comments
 (0)