@@ -57,9 +57,10 @@ ToolOptions ToolOptionsFromPythonDict(const py::dict& dictionary) {
5757
5858PYBIND11_MODULE (_pywrap_profiler_plugin, m) {
5959 m.def (
60- " trace" , [](const char * service_addr, const char * logdir,
61- const char * worker_list, bool include_dataset_ops,
62- int duration_ms, int num_tracing_attempts, py::dict options) {
60+ " trace" ,
61+ [](const char * service_addr, const char * logdir, const char * worker_list,
62+ bool include_dataset_ops, int duration_ms, int num_tracing_attempts,
63+ py::dict options) {
6364 absl::Status status;
6465 ToolOptions tool_options = ToolOptionsFromPythonDict (options);
6566 {
@@ -70,22 +71,29 @@ PYBIND11_MODULE(_pywrap_profiler_plugin, m) {
7071 }
7172 // Py_INCREF and Py_DECREF must be called holding the GIL.
7273 xla::ThrowIfError (status);
73- });
74-
75- m.def (" monitor" , [](const char * service_addr, int duration_ms,
76- int monitoring_level, bool display_timestamp) {
77- std::string content;
78- absl::Status status;
79- {
80- py::gil_scoped_release release;
81- status =
82- xprof::pywrap::Monitor (service_addr, duration_ms, monitoring_level,
83- display_timestamp, &content);
84- }
85- // Py_INCREF and Py_DECREF must be called holding the GIL.
86- xla::ThrowIfError (status);
87- return content;
88- });
74+ },
75+ py::arg (" service_addr" ), py::arg (" logdir" ), py::arg (" worker_list" ),
76+ py::arg (" include_dataset_ops" ), py::arg (" duration_ms" ),
77+ py::arg (" num_tracing_attempts" ), py::arg (" options" ));
78+
79+ m.def (
80+ " monitor" ,
81+ [](const char * service_addr, int duration_ms, int monitoring_level,
82+ bool display_timestamp) {
83+ std::string content;
84+ absl::Status status;
85+ {
86+ py::gil_scoped_release release;
87+ status = xprof::pywrap::Monitor (service_addr, duration_ms,
88+ monitoring_level, display_timestamp,
89+ &content);
90+ }
91+ // Py_INCREF and Py_DECREF must be called holding the GIL.
92+ xla::ThrowIfError (status);
93+ return content;
94+ },
95+ py::arg (" service_addr" ), py::arg (" duration_ms" ),
96+ py::arg (" monitoring_level" ), py::arg (" display_timestamp" ));
8997
9098 m.def (
9199 " xspace_to_tools_data" ,
@@ -98,8 +106,7 @@ PYBIND11_MODULE(_pywrap_profiler_plugin, m) {
98106 xspace_paths.push_back (xspace_path);
99107 }
100108 std::string tool_name = std::string (py_tool_name);
101- ToolOptions tool_options =
102- ToolOptionsFromPythonDict (options);
109+ ToolOptions tool_options = ToolOptionsFromPythonDict (options);
103110 absl::StatusOr<std::pair<std::string, bool >> result;
104111 {
105112 py::gil_scoped_release release;
@@ -113,7 +120,8 @@ PYBIND11_MODULE(_pywrap_profiler_plugin, m) {
113120 return py::make_tuple (py::bytes (result->first ),
114121 py::bool_ (result->second ));
115122 },
116- py::arg (), py::arg (), py::arg () = py::dict ());
123+ py::arg (" xspace_path_list" ), py::arg (" tool_name" ),
124+ py::arg (" options" ) = py::dict ());
117125
118126 m.def (
119127 " xspace_to_tools_data_from_byte_string" ,
@@ -132,8 +140,7 @@ PYBIND11_MODULE(_pywrap_profiler_plugin, m) {
132140 }
133141
134142 std::string tool_name = std::string (py_tool_name);
135- ToolOptions tool_options =
136- ToolOptionsFromPythonDict (options);
143+ ToolOptions tool_options = ToolOptionsFromPythonDict (options);
137144
138145 absl::StatusOr<std::pair<std::string, bool >> result;
139146 {
@@ -148,17 +155,24 @@ PYBIND11_MODULE(_pywrap_profiler_plugin, m) {
148155 return py::make_tuple (py::bytes (result->first ),
149156 py::bool_ (result->second ));
150157 },
151- py::arg (), py::arg (), py::arg (), py::arg () = py::dict ());
158+ py::arg (" xspace_string_list" ), py::arg (" filenames_list" ),
159+ py::arg (" tool_name" ), py::arg (" options" ) = py::dict ());
152160
153- m.def (" start_grpc_server" , [](int port) {
154- py::gil_scoped_release release;
155- xprof::pywrap::StartGrpcServer (port);
156- });
161+ m.def (
162+ " start_grpc_server" ,
163+ [](int port) {
164+ py::gil_scoped_release release;
165+ xprof::pywrap::StartGrpcServer (port);
166+ },
167+ py::arg (" port" ));
157168
158- m.def (" initialize_stubs" , [](const std::string& worker_service_addresses) {
159- py::gil_scoped_release release;
160- xprof::profiler::InitializeStubs (worker_service_addresses);
161- });
169+ m.def (
170+ " initialize_stubs" ,
171+ [](const std::string& worker_service_addresses) {
172+ py::gil_scoped_release release;
173+ xprof::profiler::InitializeStubs (worker_service_addresses);
174+ },
175+ py::arg (" worker_service_addresses" ));
162176};
163177
164178} // namespace
0 commit comments