Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,11 @@ FetchContent_Declare(
GIT_TAG v1.4.3
)

FetchContent_Declare(
httplib
GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
GIT_TAG v0.29.0
)


set(JSONCONS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(JSONCONS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(JSONCONS_BUILD_FUZZERS OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_ZSTD_IF_AVAILABLE OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(jsoncons tomlplusplus httplib)
FetchContent_MakeAvailable(jsoncons tomlplusplus)

if (BUILD_PYTHON_BINDINGS)
FetchContent_Declare(
Expand Down Expand Up @@ -143,13 +135,11 @@ target_include_directories(libcapio_cl PUBLIC
${jsoncons_SOURCE_DIR}/include
${CAPIOCL_JSON_SCHEMAS_DIRECTORY}
${TOMLPLUSPLUS_SOURCE_DIR}/include
${httplib_SOURCE_DIR}
)

target_link_libraries(libcapio_cl PUBLIC)
target_link_libraries(libcapio_cl PRIVATE
tomlplusplus::tomlplusplus
httplib::httplib
)

find_library(LIBANL anl)
Expand Down
37 changes: 0 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,43 +187,6 @@ engine.print()
Serializer.dump(engine, "my_workflow", "my_workflow.json")
```

## CapioCL Web API Documentation

This section describes the REST-style Web API exposed by the CapioCL Web Server.
The server provides HTTP endpoints for configuring and querying the CapioCL engine at runtime.
Within the `bruno_webapi_tests` you can find several tests and examples on how to perform
requests to the API webserver using [bruno](https://www.usebruno.com).

All endpoints communicate using JSON over HTTP. To enable the webserver, users needs to explicitly start it with:

```cpp
capiocl::engine::Engine engine();

// start engine with default parameters
engine.startApiServer();

// or by specifying the address and port:
engine.startApiServer("127.0.0.1", 5520);
```


or equivalently in python with:

```python
engine = py_capio_cl.Engine()

#start engine with default parameters
engine.startApiServer()

# or by specifying the address and port:
engine.startApiServer("127.0.0.1", 5520)
```

By default, the webserver listens only on local connection at the following address: ```127.0.0.1:5520```. No
authentication
services are currently available, and as such, users should put particular care when allowing connections from external
endpoints.

## Notes

- All GET endpoints expect a JSON body containing the targeted file path.
Expand Down
42 changes: 36 additions & 6 deletions bindings/python_bindings.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <iostream>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/stl/filesystem.h>
#include <string>

#include "capiocl.hpp"
#include "capiocl/engine.h"
#include "capiocl/monitor.h"
#include "capiocl/parser.h"
#include "capiocl/printer.h"
#include "capiocl/serializer.h"

namespace py = pybind11;
Expand All @@ -20,6 +21,11 @@ PYBIND11_MODULE(_py_capio_cl, m) {
py::register_exception<capiocl::serializer::SerializerException>(m, "SerializerException");
py::register_exception<capiocl::monitor::MonitorException>(m, "MonitorException");

m.attr("CAPIO_CL_DEFAULT_WF_NAME") = py::str(capiocl::CAPIO_CL_DEFAULT_WF_NAME);
m.attr("DEFAULT_MCAST_GROUP") =
py::make_tuple(capiocl::configuration::defaults::DEFAULT_API_MULTICAST_IP.v,
std::stoi(capiocl::configuration::defaults::DEFAULT_API_MULTICAST_PORT.v));

py::module_ fire_rules = m.def_submodule("fire_rules", "CAPIO-CL fire rules");
fire_rules.attr("UPDATE") = py::str(capiocl::fireRules::UPDATE);
fire_rules.attr("NO_UPDATE") = py::str(capiocl::fireRules::NO_UPDATE);
Expand All @@ -40,9 +46,14 @@ PYBIND11_MODULE(_py_capio_cl, m) {
.def("print", &capiocl::engine::Engine::print)
.def("contains", &capiocl::engine::Engine::contains, py::arg("path"))
.def("size", &capiocl::engine::Engine::size)
.def("add", &capiocl::engine::Engine::add, py::arg("path"), py::arg("producers"),
py::arg("consumers"), py::arg("commit_rule"), py::arg("fire_rule"),
py::arg("permanent"), py::arg("exclude"), py::arg("dependencies"))
.def("add",
py::overload_cast<std::filesystem::path &, std::vector<std::string> &,
std::vector<std::string> &, const std::string &, const std::string &,
bool, bool, std::vector<std::filesystem::path> &>(
&capiocl::engine::Engine::add),
py::arg("path"), py::arg("producers"), py::arg("consumers"), py::arg("commit_rule"),
py::arg("fire_rule"), py::arg("permanent"), py::arg("exclude"),
py::arg("dependencies"))
.def("addProducer", &capiocl::engine::Engine::addProducer, py::arg("path"),
py::arg("producer"))
.def("addConsumer", &capiocl::engine::Engine::addConsumer, py::arg("path"),
Expand Down Expand Up @@ -98,8 +109,7 @@ PYBIND11_MODULE(_py_capio_cl, m) {
.def("isCommitted", &capiocl::engine::Engine::isCommitted, py::arg("path"))
.def("setHomeNode", &capiocl::engine::Engine::setHomeNode, py::arg("path"))
.def("getPaths", &capiocl::engine::Engine::getPaths)
.def("startApiServer", &capiocl::engine::Engine::startApiServer,
py::arg("address") = "127.0.0.1", py::arg("port") = 5520)
.def("startApiServer", &capiocl::engine::Engine::startApiServer)
.def("__str__", &capiocl::engine::Engine::print)
.def("__repr__",
[](const capiocl::engine::Engine &e) {
Expand All @@ -120,4 +130,24 @@ PYBIND11_MODULE(_py_capio_cl, m) {

m.def("serialize", &capiocl::serializer::Serializer::dump, py::arg("engine"),
py::arg("filename"), py::arg("version") = capiocl::CAPIO_CL_VERSION::V1);

py::class_<capiocl::engine::CapioCLEntry>(m, "CapioCLEntry")
.def(py::init<>())
.def_readwrite("producers", &capiocl::engine::CapioCLEntry::producers)
.def_readwrite("consumers", &capiocl::engine::CapioCLEntry::consumers)
.def_readwrite("file_dependencies", &capiocl::engine::CapioCLEntry::file_dependencies)
.def_readwrite("commit_rule", &capiocl::engine::CapioCLEntry::commit_rule)
.def_readwrite("fire_rule", &capiocl::engine::CapioCLEntry::fire_rule)
.def_readwrite("directory_children_count",
&capiocl::engine::CapioCLEntry::directory_children_count)
.def_readwrite("commit_on_close_count",
&capiocl::engine::CapioCLEntry::commit_on_close_count)
.def_readwrite("enable_directory_count_update",
&capiocl::engine::CapioCLEntry::enable_directory_count_update)
.def_readwrite("store_in_memory", &capiocl::engine::CapioCLEntry::store_in_memory)
.def_readwrite("permanent", &capiocl::engine::CapioCLEntry::permanent)
.def_readwrite("excluded", &capiocl::engine::CapioCLEntry::excluded)
.def_readwrite("is_file", &capiocl::engine::CapioCLEntry::is_file)
.def_static("from_json", &capiocl::engine::CapioCLEntry::fromJson, py::arg("in"))
.def("to_json", &capiocl::engine::CapioCLEntry::toJson);
}
23 changes: 0 additions & 23 deletions bruno_webapi_tests/add_consumer.bru

This file was deleted.

23 changes: 0 additions & 23 deletions bruno_webapi_tests/add_file_dependency.bru

This file was deleted.

23 changes: 0 additions & 23 deletions bruno_webapi_tests/add_producer.bru

This file was deleted.

22 changes: 0 additions & 22 deletions bruno_webapi_tests/add_workflow_name.bru

This file was deleted.

9 changes: 0 additions & 9 deletions bruno_webapi_tests/bruno.json

This file was deleted.

Empty file removed bruno_webapi_tests/collection.bru
Empty file.
22 changes: 0 additions & 22 deletions bruno_webapi_tests/get_commit_close_count.bru

This file was deleted.

22 changes: 0 additions & 22 deletions bruno_webapi_tests/get_commit_on_n_files_count.bru

This file was deleted.

22 changes: 0 additions & 22 deletions bruno_webapi_tests/get_commit_rule.bru

This file was deleted.

22 changes: 0 additions & 22 deletions bruno_webapi_tests/get_consumer.bru

This file was deleted.

22 changes: 0 additions & 22 deletions bruno_webapi_tests/get_directory.bru

This file was deleted.

Loading
Loading