| 216 | |
| 217 | |
| 218 | class lazy_load: |
| 219 | def __init__(self, fn): |
| 220 | self.zf = torch._C.PyTorchFileReader(str(fn)) |
| 221 | with BytesIO(self.zf.get_record("data.pkl")) as pkl: |
| 222 | mup = LazyLoadingUnpickler(pkl, self) |
| 223 | self.sd = mup.load() |
| 224 | |
| 225 | def __enter__(self): |
| 226 | return self.sd |
| 227 | |
| 228 | def __exit__(self, exc_type, exc_val, exc_tb): |
| 229 | del self.zf # I don't think there is a way to force closing... |
| 230 | self.zf = None |
| 231 | |
| 232 | |
| 233 | def check_valid_checkpoint_dir(checkpoint_dir: Path) -> None: |
no outgoing calls
no test coverage detected