| 357 | |
| 358 | |
| 359 | void TLearnContext::SaveProgress(std::function<void(IOutputStream*)> onSaveSnapshot) { |
| 360 | if (!OutputOptions.SaveSnapshot()) { |
| 361 | return; |
| 362 | } |
| 363 | const auto snapshotBackup = Files.SnapshotFile + ".bak"; |
| 364 | TProgressHelper(ToString(ETaskType::CPU)).Write( |
| 365 | snapshotBackup, |
| 366 | [&](IOutputStream* out) { |
| 367 | onSaveSnapshot(out); |
| 368 | ::SaveMany(out, *LearnProgress, Profile.DumpProfileInfo()); |
| 369 | } |
| 370 | ); |
| 371 | TFsPath(snapshotBackup).ForceRenameTo(Files.SnapshotFile); |
| 372 | } |
| 373 | |
| 374 | bool TLearnContext::TryLoadProgress(std::function<bool(IInputStream*)> onLoadSnapshot) { |
| 375 | if (!OutputOptions.SaveSnapshot() || !NFs::Exists(Files.SnapshotFile)) { |
no test coverage detected