Skip to content
Open
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
5 changes: 2 additions & 3 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
apt-get update
apt-get install -y git \
cmake make ninja-build sudo \
python3 python3-pip python3-venv \
libcurl4-gnutls-dev
python3 python3-pip python3-venv

- name: "Run CMake"
shell: bash
Expand Down Expand Up @@ -77,7 +76,7 @@ jobs:
sudo apt-get install -y git \
cmake make ninja-build sudo \
python3 python3-pip python3-venv \
gcc g++ libcurl4-gnutls-dev
gcc g++

- name: "Compile tests"
run: |
Expand Down
156 changes: 37 additions & 119 deletions .github/workflows/python-bindings.yml
Original file line number Diff line number Diff line change
@@ -1,139 +1,57 @@
name: "Python Bindings Unit Tests"
name: "Python Bindings Build & Test"

on:
push:
branches:
- main
branches: [ main ]
pull_request:
branches:
- main
branches: [ main ]

concurrency:
group: build-python-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
python-tests:
name: "Test Python bindings"
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ]
python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
os:
- 'ubuntu-24.04'
- 'ubuntu-24.04-arm'
- 'macos-26-intel'
- 'macos-26'

runs-on: ${{ matrix.on }}
env:
INSTALL_PREFIX: "/usr/local"

steps:
- name: "Checkout repository"
uses: actions/checkout@v6

- name: "Set up Python ${{ matrix.python }}"
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}

# Install platform build dependencies
- name: "Install system packages (Ubuntu)"
if: startsWith(matrix.on, 'ubuntu-')
run: sudo apt-get update && sudo apt-get install -y ninja-build g++ cmake libcurl4-gnutls-dev

- name: "Setup Homebrew (macOS)"
if: startsWith(matrix.on, 'macos-')
uses: Homebrew/actions/setup-homebrew@main

- name: "Install system packages (macOS)"
if: startsWith(matrix.on, 'macos-')
run: brew install ninja gcc cmake curl

- name: "Create virtual environment"
run: |
pip install -r build-requirements.txt
pip install -r test-requirements.txt
CIBW_BEFORE_ALL_LINUX: >
pip install cmake ninja
CIBW_BEFORE_ALL_MACOS: >
brew install ninja gcc cmake curl

# Install Python build dependencies
- name: "Build and Install Python package"
run: |
mkdir -p /tmp/capio_cl_jsons
mkdir -p /tmp/capio_cl_tomls
cp -r tests/jsons/* /tmp/capio_cl_jsons
cp -r tests/tomls/* /tmp/capio_cl_tomls
pip install .
CIBW_BEFORE_BUILD: >
pip install -r build-requirements.txt &&
mkdir -p /tmp/capio_cl_jsons /tmp/capio_cl_tomls &&
cp -r tests/jsons/* /tmp/capio_cl_jsons/ &&
cp -r tests/tomls/* /tmp/capio_cl_tomls/

# Run unit tests
- name: "Run Python tests (Ubuntu)"
if: startsWith(matrix.on, 'ubuntu-')
run: |
pytest -v tests/python/test_*
CIBW_BEFORE_TEST: pip install -r test-requirements.txt

- name: "Run Python tests (MacOS)"
if: startsWith(matrix.on, 'macos-')
run: |
pytest -k "not test_home_node" -v tests/python/test_*
CIBW_TEST_COMMAND_LINUX: "pytest -v {project}/tests/python/test_*"
CIBW_TEST_COMMAND_MACOS: "pytest -k 'not test_home_node' -v {project}/tests/python/test_*"


- name: "Generate coverage report"
if: ${{ startsWith(matrix.on, 'ubuntu-') }}
run: |
pip install --upgrade gcovr
gcovr \
--exclude-throw-branches \
--gcov-ignore-parse-errors=negative_hits.warn \
--exclude tests/ \
--xml coverage.xml \
.

- name: "Upload coverage report"
if: ${{ startsWith(matrix.on, 'ubuntu-') }}
uses: actions/upload-artifact@v7
with:
name: ${{ format('{0}-{1}-tests', matrix.on, matrix.python) }}
path: ./coverage.xml
retention-days: 1
if-no-files-found: error

riscv-tests:
name: "Build & Test on RISC-V (QEMU)"
strategy:
matrix:
python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
runs-on: ubuntu-latest

env:
INSTALL_PREFIX: "/usr/local"
PYTHON_VERSION: "${{ matrix.python }}"
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*"

steps:
- name: "Checkout repository"
- name: Checkout repository
uses: actions/checkout@v6

- name: "Build and test inside RISC-V emulated environment (Debian based)"
uses: uraimo/run-on-arch-action@v3
with:
arch: riscv64
distro: ubuntu_latest
githubToken: ${{ github.token }}

install: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
python3 python3-pip python3-venv python3-wheel python3-setuptools \
g++ cmake ninja-build git

run: |
set -eux
echo "Building for RISC-V on Ubuntu 22.04"

python3 -m pip install -r build-requirements.txt --break-system-packages

mkdir -p /tmp/capio_cl_jsons
mkdir -p /tmp/capio_cl_tomls
cp -r tests/jsons/* /tmp/capio_cl_jsons
cp -r tests/tomls/* /tmp/capio_cl_tomls

python3 -m build \
-Ccmake.define.ENABLE_COVERAGE=OFF \
-Ccmake.build-type=Release \
-Ccmake.define.CAPIO_CL_BUILD_TESTS=OFF

pip install dist/*.whl --break-system-packages
python3 -m pip install -r test-requirements.txt --break-system-packages
- name: Build wheels
uses: pypa/cibuildwheel@v3.4.0
env:
MACOSX_DEPLOYMENT_TARGET: "10.15"

pytest -v tests/python/test_* | tee pytest-riscv.log
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
15 changes: 1 addition & 14 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 Expand Up @@ -191,8 +181,6 @@ endif ()
#####################################
if (CAPIO_CL_BUILD_TESTS)

find_package(CURL REQUIRED)

message(STATUS "Building CAPIO-CL tests")

FetchContent_Declare(
Expand All @@ -209,7 +197,6 @@ if (CAPIO_CL_BUILD_TESTS)
target_link_libraries(CAPIO_CL_tests PRIVATE
libcapio_cl
GTest::gtest_main
CURL::libcurl
)

if(LIBANL)
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.

Loading
Loading