1 /* Copyright 2017 The TensorFlow Authors All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_CORE_PROFILER_RPC_CLIENT_SAVE_PROFILE_H_
17 #define TENSORFLOW_CORE_PROFILER_RPC_CLIENT_SAVE_PROFILE_H_
18 
19 #include <ostream>
20 #include <string>
21 
22 #include "tensorflow/core/platform/status.h"
23 #include "tensorflow/core/platform/types.h"
24 #include "tensorflow/core/profiler/profiler_service.pb.h"
25 
26 namespace tensorflow {
27 namespace profiler {
28 
29 std::string GetCurrentTimeStampAsString();
30 
31 // Returns the profile plugin directory given a logdir to TensorBoard.
32 std::string GetTensorBoardProfilePluginDir(const std::string& logdir);
33 
34 // Creates an empty event file if not already exists, which indicates that we
35 // have a plugins/profile/ directory in the current logdir.
36 Status MaybeCreateEmptyEventFile(const std::string& logdir);
37 
38 // Saves all profiling tool data in a profile to <repository_root>/<run>/.
39 // This writes user-facing log messages to `os`.
40 // Note: this function creates a directory even when all fields in
41 // ProfileResponse are unset/empty.
42 Status SaveProfile(const std::string& repository_root, const std::string& run,
43                    const std::string& host, const ProfileResponse& response,
44                    std::ostream* os);
45 
46 // Gzip the data and save to <repository_root>/<run>/.
47 Status SaveGzippedToolData(const std::string& repository_root,
48                            const std::string& run, const std::string& host,
49                            const std::string& tool_name,
50                            const std::string& data);
51 
52 }  // namespace profiler
53 }  // namespace tensorflow
54 
55 #endif  // TENSORFLOW_CORE_PROFILER_RPC_CLIENT_SAVE_PROFILE_H_
56