16 #include "tensorflow_serving/core/resource_preserving_policy.h"
21 namespace tensorflow {
24 absl::optional<AspiredVersionPolicy::ServableAction>
26 const std::vector<AspiredServableStateSnapshot>& all_versions)
const {
29 for (
const auto& version : all_versions) {
31 VLOG(1) <<
"ResourcePreservingPolicy requesting to unload servable "
39 const bool not_aspired_not_finished =
40 std::any_of(all_versions.begin(), all_versions.end(),
42 return !version.is_aspired &&
43 version.state != LoaderHarness::State::kDisabled &&
44 version.state != LoaderHarness::State::kError;
46 if (not_aspired_not_finished) {
52 absl::optional<ServableId> highest_aspired_new_version_id =
54 if (highest_aspired_new_version_id) {
55 VLOG(1) <<
"ResourcePreservingPolicy requesting to load servable "
56 << highest_aspired_new_version_id.value();
57 return {{
Action::kLoad, highest_aspired_new_version_id.value()}};
@ kUnload
Call unload on the servable.
@ kLoad
Call load on the servable.
static absl::optional< ServableId > GetHighestAspiredNewServableId(const std::vector< AspiredServableStateSnapshot > &all_versions)
@ kReady
'loader_->Load()' has succeeded.
absl::optional< ServableAction > GetNextAction(const std::vector< AspiredServableStateSnapshot > &all_versions) const override
A snapshot of a servable's state and aspiredness.