Skip to content
Snippets Groups Projects
Commit 4f8e694b authored by Maxence Naud's avatar Maxence Naud
Browse files

[Add] python binding for new graph matching system

parent 48212a3b
No related branches found
No related tags found
1 merge request!68Fix for updating aidge bundle
Pipeline #36842 failed
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
********************************************************************************/ ********************************************************************************/
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
#include <pybind11/functional.h>
#include "aidge/graphRegex/GraphRegex.hpp" #include "aidge/graphRegex/GraphRegex.hpp"
namespace py = pybind11; namespace py = pybind11;
...@@ -20,7 +21,7 @@ void init_GraphRegex(py::module& m){ ...@@ -20,7 +21,7 @@ void init_GraphRegex(py::module& m){
py::class_<GraphRegex, std::shared_ptr<GraphRegex>>(m, "GraphRegex", "GraphRegex class describes a regex to test a graph.") py::class_<GraphRegex, std::shared_ptr<GraphRegex>>(m, "GraphRegex", "GraphRegex class describes a regex to test a graph.")
.def(py::init<>()) .def(py::init<>())
.def("add_query", &GraphRegex::addQuery, R"mydelimiter( .def("add_query", &GraphRegex::addQuery, py::arg("query"), py::arg("f") = nullptr, R"mydelimiter(
:rtype: str :rtype: str
)mydelimiter") )mydelimiter")
...@@ -47,10 +48,10 @@ void init_GraphRegex(py::module& m){ ...@@ -47,10 +48,10 @@ void init_GraphRegex(py::module& m){
Add a node test Add a node test
:param key: the key of the node test to use in the query. :param key: the key of the node test to use in the query.
:param conditionalExpressions: the test to do . :param conditionalExpressions: the test to do .
)mydelimiter") )mydelimiter")
.def("set_node_key", .def("set_node_key",
(void (GraphRegex::*)(const std::string, std::function<bool(NodePtr)>)) & (void (GraphRegex::*)(const std::string, std::function<bool(NodePtr)>)) &
GraphRegex::setNodeKey, GraphRegex::setNodeKey,
...@@ -59,7 +60,7 @@ void init_GraphRegex(py::module& m){ ...@@ -59,7 +60,7 @@ void init_GraphRegex(py::module& m){
Add a node test Add a node test
:param key: the key of the lambda test to use in the conditional expressions. :param key: the key of the lambda test to use in the conditional expressions.
:param f: bool lambda (nodePtr) . :param f: bool lambda (nodePtr) .
)mydelimiter") )mydelimiter")
......
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "aidge/graphRegex/matchFsm/MatchResult.hpp"
namespace py = pybind11;
namespace Aidge {
void init_MatchSolution(py::module& m){
py::class_<MatchSolution, std::shared_ptr<MatchSolution>>(m, "MatchSolution", "MatchSolution class contains the result of one match and the associated key, the query and the start node.")
.def("at", &MatchSolution::at, py::arg("key"),
R"mydelimiter(
:rtype: str
)mydelimiter")
.def("get_all", &MatchSolution::getAll,
R"mydelimiter(
)mydelimiter")
.def("get_query", &MatchSolution::getQuery,
R"mydelimiter(
)mydelimiter")
.def("get_start_node", &MatchSolution::getStartNode,
R"mydelimiter(
)mydelimiter")
;
}
} // namespace Aidge
...@@ -56,6 +56,7 @@ void init_OpArgs(py::module&); ...@@ -56,6 +56,7 @@ void init_OpArgs(py::module&);
void init_Connector(py::module&); void init_Connector(py::module&);
void init_GraphRegex(py::module&); void init_GraphRegex(py::module&);
void init_MatchSolution(py::module&);
void init_Recipies(py::module&); void init_Recipies(py::module&);
...@@ -106,7 +107,9 @@ void init_Aidge(py::module& m){ ...@@ -106,7 +107,9 @@ void init_Aidge(py::module& m){
init_Identity(m); init_Identity(m);
init_Producer(m); init_Producer(m);
init_GraphRegex(m); init_GraphRegex(m);
init_MatchSolution(m);
init_Recipies(m); init_Recipies(m);
init_Scheduler(m); init_Scheduler(m);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment