| 1891 | } // NOLINT |
| 1892 | |
| 1893 | void register_lgraph_plugin(pybind11::module& m) { |
| 1894 | //====================================== |
| 1895 | // Register Python task runner |
| 1896 | //====================================== |
| 1897 | pybind11::class_<lgraph::python_plugin::TaskInput>(m, "TaskInput") |
| 1898 | .def_static( |
| 1899 | "ReadTaskInput", |
| 1900 | [](const std::string& pipename) { |
| 1901 | boost::interprocess::message_queue mq(boost::interprocess::open_only, |
| 1902 | pipename.c_str()); |
| 1903 | lgraph::python_plugin::TaskInput input; |
| 1904 | while (!input.ReadFromMessageQueue(mq, 100)) { |
| 1905 | SignalsGuard signalsGuard; |
| 1906 | } |
| 1907 | return input; |
| 1908 | }, |
| 1909 | "Read TaskInput from message queue", |
| 1910 | pybind11::call_guard<SignalsGuard>()) |
| 1911 | .def_readonly("user", &lgraph::python_plugin::TaskInput::user, "user to be used") |
| 1912 | .def_readonly("graph", &lgraph::python_plugin::TaskInput::graph, "Graph to be used") |
| 1913 | .def_readonly("plugin_dir", &lgraph::python_plugin::TaskInput::plugin_dir, |
| 1914 | "Directory where .py files are stored") |
| 1915 | .def_readonly("function", &lgraph::python_plugin::TaskInput::function, "The function name") |
| 1916 | .def( |
| 1917 | "get_input", |
| 1918 | [](const lgraph::python_plugin::TaskInput& in) { return pybind11::bytes(in.input); }, |
| 1919 | "The input byte array", |
| 1920 | pybind11::call_guard<SignalsGuard>()) |
| 1921 | .def_readonly("read_only", &lgraph::python_plugin::TaskInput::read_only); |
| 1922 | |
| 1923 | pybind11::class_<lgraph::python_plugin::TaskOutput>(m, "TaskOutput") |
| 1924 | .def_static( |
| 1925 | "WriteTaskOutput", |
| 1926 | [](const std::string& pipename, lgraph::python_plugin::TaskOutput::ErrorCode error_code, |
| 1927 | const std::string& output) { |
| 1928 | boost::interprocess::message_queue mq(boost::interprocess::open_only, |
| 1929 | pipename.c_str()); |
| 1930 | lgraph::python_plugin::TaskOutput out; |
| 1931 | out.error_code = error_code; |
| 1932 | out.output = output; |
| 1933 | out.WriteToMessageQueue(mq); |
| 1934 | }, |
| 1935 | "Write TaskOutput to stdout", |
| 1936 | pybind11::call_guard<SignalsGuard>()); |
| 1937 | } |
| 1938 | |
| 1939 | class EdgeListWriter { |
| 1940 | fma_common::OutputFmaStream ofs_; |
no test coverage detected