| 135 | } |
| 136 | |
| 137 | Status ModelStore::DetectLatestCheckpointDir() { |
| 138 | TF_RETURN_IF_ERROR(file_system_->IsDirectory(checkpoint_parent_dir_)); |
| 139 | std::vector<string> file_names; |
| 140 | Status s = file_system_->GetMatchingPaths( |
| 141 | io::JoinPath(checkpoint_parent_dir_, "*/checkpoint"), &file_names); |
| 142 | if (!s.ok()) { |
| 143 | LOG(ERROR) << "Get matching files from file system failed, pattern is:" |
| 144 | << io::JoinPath(checkpoint_parent_dir_, "*/checkpoint") |
| 145 | << ", error is: " << s.error_message(); |
| 146 | return s; |
| 147 | } |
| 148 | |
| 149 | int64 latest_mtime_nsec = -1; |
| 150 | for (auto fname : file_names) { |
| 151 | FileStatistics stat; |
| 152 | s = file_system_->Stat(fname, &stat); |
| 153 | if (s.ok()) { |
| 154 | if (stat.mtime_nsec > latest_mtime_nsec) { |
| 155 | latest_mtime_nsec = stat.mtime_nsec; |
| 156 | checkpoint_dir_ = fname.substr(0, fname.rfind('/')); |
| 157 | checkpoint_dir_ += "/"; |
| 158 | } |
| 159 | } else { |
| 160 | LOG(ERROR) << "[Processor] Path: "<< fname |
| 161 | << " not a valid checkpoint_path, msg:" << s.ToString(); |
| 162 | return s; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | LOG(WARNING) << "[Processor] checkpoint_dir: " << checkpoint_dir_; |
| 167 | return Status::OK(); |
| 168 | } |
| 169 | |
| 170 | } // namespace processor |
| 171 | } // namespace tensorflow |
nothing calls this directly
no test coverage detected