1*14675a02SAndroid Build Coastguard Worker /* 2*14675a02SAndroid Build Coastguard Worker * Copyright 2020 Google LLC 3*14675a02SAndroid Build Coastguard Worker * 4*14675a02SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*14675a02SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*14675a02SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*14675a02SAndroid Build Coastguard Worker * 8*14675a02SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*14675a02SAndroid Build Coastguard Worker * 10*14675a02SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*14675a02SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*14675a02SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*14675a02SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*14675a02SAndroid Build Coastguard Worker * limitations under the License. 15*14675a02SAndroid Build Coastguard Worker */ 16*14675a02SAndroid Build Coastguard Worker #ifndef FCP_CLIENT_LC_RUNNER_H_ 17*14675a02SAndroid Build Coastguard Worker #define FCP_CLIENT_LC_RUNNER_H_ 18*14675a02SAndroid Build Coastguard Worker 19*14675a02SAndroid Build Coastguard Worker #include <string> 20*14675a02SAndroid Build Coastguard Worker 21*14675a02SAndroid Build Coastguard Worker #include "absl/container/flat_hash_map.h" 22*14675a02SAndroid Build Coastguard Worker #include "absl/status/status.h" 23*14675a02SAndroid Build Coastguard Worker #include "fcp/base/monitoring.h" 24*14675a02SAndroid Build Coastguard Worker #include "fcp/client/event_publisher.h" 25*14675a02SAndroid Build Coastguard Worker #include "fcp/client/flags.h" 26*14675a02SAndroid Build Coastguard Worker #include "fcp/client/log_manager.h" 27*14675a02SAndroid Build Coastguard Worker #include "fcp/client/opstats/opstats_logger.h" 28*14675a02SAndroid Build Coastguard Worker #include "fcp/client/phase_logger.h" 29*14675a02SAndroid Build Coastguard Worker #include "fcp/client/simple_task_environment.h" 30*14675a02SAndroid Build Coastguard Worker 31*14675a02SAndroid Build Coastguard Worker namespace fcp { 32*14675a02SAndroid Build Coastguard Worker namespace client { 33*14675a02SAndroid Build Coastguard Worker 34*14675a02SAndroid Build Coastguard Worker // Prod entry point for running a local computation. Concurrent calls, with 35*14675a02SAndroid Build Coastguard Worker // the same SimpleTaskEnvironment::GetBaseDir(), are not supported. 36*14675a02SAndroid Build Coastguard Worker // If the training conditions are not met, return CANCELLED status. 37*14675a02SAndroid Build Coastguard Worker // If the plan cannot be parsed, return INVALID_ARGUMENT status. 38*14675a02SAndroid Build Coastguard Worker // If the plan does not contain tensorSpec, return INVALID_ARGUMENT status. 39*14675a02SAndroid Build Coastguard Worker // If the plan does not contain LocalComputeIORouter, return INVALID_ARGUMENT 40*14675a02SAndroid Build Coastguard Worker // status. 41*14675a02SAndroid Build Coastguard Worker // If the plan contains ClientExecutions, return INVALID_ARGUMENT status. 42*14675a02SAndroid Build Coastguard Worker // If the plan expects input tensors other than dataset token, input dir and 43*14675a02SAndroid Build Coastguard Worker // output dir, return INVALID_ARGUMENT status. 44*14675a02SAndroid Build Coastguard Worker // If Tensorflow completes, return OK status. 45*14675a02SAndroid Build Coastguard Worker // If Tensorflow was interrupted, return CANCELLED status. 46*14675a02SAndroid Build Coastguard Worker absl::Status RunLocalComputation( 47*14675a02SAndroid Build Coastguard Worker SimpleTaskEnvironment* env_deps, EventPublisher* event_publisher, 48*14675a02SAndroid Build Coastguard Worker LogManager* log_manager, const Flags* flags, 49*14675a02SAndroid Build Coastguard Worker const std::string& session_name, const std::string& plan_uri, 50*14675a02SAndroid Build Coastguard Worker const std::string& input_dir_uri, const std::string& output_dir_uri, 51*14675a02SAndroid Build Coastguard Worker const absl::flat_hash_map<std::string, std::string>& input_resources); 52*14675a02SAndroid Build Coastguard Worker 53*14675a02SAndroid Build Coastguard Worker // This is exposed for use in tests that require a mocked OpStatsLogger. 54*14675a02SAndroid Build Coastguard Worker // Otherwise, this is used internally by the other RunLocalComputation 55*14675a02SAndroid Build Coastguard Worker // method once the OpStatsLogger object has been created. 56*14675a02SAndroid Build Coastguard Worker absl::Status RunLocalComputation( 57*14675a02SAndroid Build Coastguard Worker PhaseLogger& phase_logger, SimpleTaskEnvironment* env_deps, 58*14675a02SAndroid Build Coastguard Worker LogManager* log_manager, 59*14675a02SAndroid Build Coastguard Worker ::fcp::client::opstats::OpStatsLogger* opstats_logger, const Flags* flags, 60*14675a02SAndroid Build Coastguard Worker const std::string& plan_uri, const std::string& input_dir_uri, 61*14675a02SAndroid Build Coastguard Worker const std::string& output_dir_uri, 62*14675a02SAndroid Build Coastguard Worker const absl::flat_hash_map<std::string, std::string>& input_resources, 63*14675a02SAndroid Build Coastguard Worker const SelectorContext& selector_context); 64*14675a02SAndroid Build Coastguard Worker 65*14675a02SAndroid Build Coastguard Worker } // namespace client 66*14675a02SAndroid Build Coastguard Worker } // namespace fcp 67*14675a02SAndroid Build Coastguard Worker 68*14675a02SAndroid Build Coastguard Worker #endif // FCP_CLIENT_LC_RUNNER_H_ 69