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
2 changes: 1 addition & 1 deletion .github/workflows/python-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: "Test Python bindings"
strategy:
matrix:
on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-26' ]
on: [ 'ubuntu-24.04', 'macos-15-intel', 'macos-15' ]
python: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]

runs-on: ${{ matrix.on }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ dist/**

# debug information files
*.dwo
**.DS_Store
**.DS_Store

*build*
36 changes: 26 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,18 @@ FetchContent_Declare(
GIT_TAG v1.8.1
)

FetchContent_Declare(
calf
GIT_REPOSITORY https://github.com/High-Performance-IO/calf.git
GIT_TAG main
)

# JSONCONS build flags
set(JSONCONS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(JSONCONS_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(JSONCONS_BUILD_FUZZERS OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(jsoncons tomlplusplus)
FetchContent_MakeAvailable(jsoncons tomlplusplus calf)

if (BUILD_PYTHON_BINDINGS)
FetchContent_Declare(
Expand Down Expand Up @@ -129,24 +136,33 @@ set(CAPIO_CL_HEADERS capiocl.hpp)
# Library target
add_library(libcapio_cl STATIC ${CAPIO_SRC} ${CAPIO_CL_HEADERS})


target_include_directories(libcapio_cl PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${jsoncons_SOURCE_DIR}/include
${CAPIOCL_JSON_SCHEMAS_DIRECTORY}
${TOMLPLUSPLUS_SOURCE_DIR}/include
${CALF_SOURCE_DIR}
)

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

find_library(LIBANL anl)
if(LIBANL)
if (LIBANL)
target_link_libraries(libcapio_cl PRIVATE ${LIBANL})
endif ()

#####################################
# set CALF logger component name
#####################################
calf_enable_log(libcapio_cl $<IF:$<CONFIG:Debug>,ON,OFF>)
calf_set_component(libcapio_cl "capiocl")
calf_set_default_log_dir(libcapio_cl "./capiocl_logs")
target_include_directories(libcapio_cl PRIVATE ${CALF_SOURCE_DIR})

#####################################
# Install rules
#####################################
Expand Down Expand Up @@ -202,7 +218,7 @@ if (CAPIO_CL_BUILD_TESTS)
CURL::libcurl
)

if(LIBANL)
if (LIBANL)
target_link_libraries(CAPIO_CL_tests PRIVATE ${LIBANL})
endif ()

Expand Down Expand Up @@ -296,11 +312,11 @@ if (ENABLE_COVERAGE_PIPELINE)

COMMAND ${LCOV_BIN}
--remove ${COVERAGE_INFO}
"*jsoncons*"
"/usr/include/*"
"*googletest*"
"*tests/*"
${COVERAGE_REMOVE_PATTERNS}
"*jsoncons*"
"/usr/include/*"
"*googletest*"
"*tests/*"
${COVERAGE_REMOVE_PATTERNS}
--ignore-errors unused
--ignore-errors inconsistent
--output-file ${COVERAGE_INFO}
Expand Down
42 changes: 0 additions & 42 deletions capiocl/printer.h

This file was deleted.

74 changes: 38 additions & 36 deletions src/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include <memory>
#include <sstream>

#include "calf/StdOutLogger.h"
#include "capiocl.hpp"
#include "capiocl/configuration.h"
#include "capiocl/engine.h"
#include "capiocl/monitor.h"
#include "capiocl/printer.h"

/// @brief Class to implement a shared mutex lock guard
template <typename SharedMutex> class shared_lock_guard {
Expand All @@ -26,47 +26,48 @@ template <typename SharedMutex> class shared_lock_guard {
};

void capiocl::engine::Engine::print() const {

UPDATE_CALF_WORKFLOW_NAME(workflow_name);
// First message
printer::print(printer::CLI_LEVEL_JSON, "");
printer::print(printer::CLI_LEVEL_JSON, "Composition of expected CAPIO FS: ");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, " ");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Composition of expected CAPIO FS: ");

// Table header lines
printer::print(printer::CLI_LEVEL_JSON, "*" + std::string(134, '=') + "*");

printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, ' ') + "|");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "*%s*", std::string(134, '=').c_str());
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str());

{
std::ostringstream oss;
oss << "| Parsed configuration file for workflow: \033[1;36m" << workflow_name
<< std::setw(94 - workflow_name.length()) << "\033[0m |";
printer::print(printer::CLI_LEVEL_JSON, oss.str());
}
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO,
"| Parsed configuration file for workflow: \033[1;36m %s%s \033[0m |",
workflow_name.c_str(), std::string(86 - workflow_name.length(), ' ').c_str());

printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, ' ') + "|");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str());

std::string msg = "| File color legend: \033[48;5;034m \033[0m File stored in memory";
msg += std::string(82, ' ') + "|";
printer::print(printer::CLI_LEVEL_JSON, msg);
CALF_PRINT_COLOR(
CALF_CLI_LEVEL_INFO,
"| File color legend: \033[48;5;034m \033[0m File stored in memory%s|",
std::string(82, ' ').c_str());

printer::print(
printer::CLI_LEVEL_JSON, // LCOV_EXCL_LINE
"| \033[48;5;172m \033[0m File stored on file system" +
std::string(77, ' ') + "|");
CALF_PRINT_COLOR(
CALF_CLI_LEVEL_INFO,
"| \033[48;5;172m \033[0m File stored on file system%s|",
std::string(77, ' ').c_str());

printer::print(printer::CLI_LEVEL_JSON, "|" + std::string(134, '=') + "|");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "|%s|", std::string(134, ' ').c_str());

std::string line = "|======|===================|===================|====================";
line += "|====================|============|===========|=========|==========|";
printer::print(printer::CLI_LEVEL_JSON, line);
CALF_PRINT_COLOR(
CALF_CLI_LEVEL_INFO, "|%s|%s|%s|%s|%s|%s|%s|%s|%s|", std::string(6, '=').c_str(),
std::string(19, '=').c_str(), std::string(19, '=').c_str(), std::string(20, '=').c_str(),
std::string(20, '=').c_str(), std::string(12, '=').c_str(), std::string(11, '=').c_str(),
std::string(9, '=').c_str(), std::string(10, '=').c_str());

line = "| Kind | Filename | Producer step | Consumer step | ";
line += "Commit Rule | Fire Rule | Permanent | Exclude | n_files |";
printer::print(printer::CLI_LEVEL_JSON, line);
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO,
"| Kind | Filename | Producer step | Consumer step | "
"Commit Rule | Fire Rule | Permanent | Exclude | n_files |");

line = "|======|===================|===================|====================|========";
line += "============|============|===========|=========|==========|";
printer::print(printer::CLI_LEVEL_JSON, line);
CALF_PRINT_COLOR(
CALF_CLI_LEVEL_INFO, "|%s|%s|%s|%s|%s|%s|%s|%s|%s|", std::string(6, '=').c_str(),
std::string(19, '=').c_str(), std::string(19, '=').c_str(), std::string(20, '=').c_str(),
std::string(20, '=').c_str(), std::string(12, '=').c_str(), std::string(11, '=').c_str(),
std::string(9, '=').c_str(), std::string(10, '=').c_str());

// Iterate over _locations
for (auto &itm : _capio_cl_entries) {
Expand Down Expand Up @@ -136,13 +137,13 @@ void capiocl::engine::Engine::print() const {
line << std::setfill(' ') << std::setw(10) << "|" << std::setw(11) << "|";
}

printer::print(printer::CLI_LEVEL_JSON, line.str());
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "%s", line.str().c_str());
}

printer::print(printer::CLI_LEVEL_JSON, "*" + std::string(134, '~') + "*");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "*%s*", std::string(134, '~').c_str());
}

printer::print(printer::CLI_LEVEL_JSON, "");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, " ");
}

capiocl::engine::Engine::Engine(const bool use_default_settings) {
Expand Down Expand Up @@ -899,6 +900,7 @@ bool capiocl::engine::Engine::operator==(const Engine &other) const {
return true;
}
void capiocl::engine::Engine::loadConfiguration(const std::string &path) {
UPDATE_CALF_WORKFLOW_NAME(workflow_name);
configuration.load(path);

std::string multicast_monitor_enabled, fs_monitor_enabled;
Expand All @@ -912,7 +914,7 @@ void capiocl::engine::Engine::loadConfiguration(const std::string &path) {
if (multicast_monitor_enabled == "true") {
monitor.registerMonitorBackend(new monitor::MulticastMonitor(configuration));
} else {
printer::print(printer::CLI_LEVEL_WARNING, "Skipping registration of MulticastMonitor");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Skipping registration of MulticastMonitor");
}

try {
Expand All @@ -924,7 +926,7 @@ void capiocl::engine::Engine::loadConfiguration(const std::string &path) {
if (fs_monitor_enabled == "true") {
monitor.registerMonitorBackend(new monitor::FileSystemMonitor());
} else {
printer::print(printer::CLI_LEVEL_WARNING, "Skipping registration of FileSystemMonitor");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Skipping registration of FileSystemMonitor");
}
}
void capiocl::engine::Engine::useDefaultConfiguration() {
Expand Down
11 changes: 6 additions & 5 deletions src/Monitor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "capiocl/monitor.h"
#include "capiocl.hpp"
#include "capiocl/printer.h"


capiocl::monitor::MonitorException::MonitorException(const std::string &msg) : message(msg) {
printer::print(printer::CLI_LEVEL_ERROR, msg);
std::cerr << msg << std::endl;
}

bool capiocl::monitor::Monitor::isCommitted(const std::filesystem::path &path) const {
Expand All @@ -19,6 +19,7 @@ void capiocl::monitor::Monitor::setCommitted(std::filesystem::path path) const {
void capiocl::monitor::Monitor::registerMonitorBackend(const MonitorInterface *interface) {
interfaces.emplace_back(interface);
}

void capiocl::monitor::Monitor::setHomeNode(const std::filesystem::path &path) const {
std::for_each(interfaces.begin(), interfaces.end(),
[&path](const auto &interface) { interface->setHomeNode(path); });
Expand All @@ -27,7 +28,7 @@ void capiocl::monitor::Monitor::setHomeNode(const std::filesystem::path &path) c
std::set<std::string>
capiocl::monitor::Monitor::getHomeNode(const std::filesystem::path &path) const {
std::set<std::string> home_nodes;
for (const auto &interface : interfaces) {
for (const auto &interface: interfaces) {
const auto &node = interface->getHomeNode(path);
if (node == NO_HOME_NODE) {
continue;
Expand All @@ -38,7 +39,7 @@ capiocl::monitor::Monitor::getHomeNode(const std::filesystem::path &path) const
}

capiocl::monitor::Monitor::~Monitor() {
for (const auto &interface : interfaces) {
for (const auto &interface: interfaces) {
delete interface;
}
}
}
21 changes: 13 additions & 8 deletions src/Parser.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <filesystem>
#include <fstream>

#include "calf/StdOutLogger.h"
#include "capiocl.hpp"
#include "capiocl/engine.h"
#include "capiocl/parser.h"
#include "capiocl/printer.h"

capiocl::parser::ParserException::ParserException(const std::string &msg) : message(msg) {
printer::print(printer::CLI_LEVEL_ERROR, msg);
UPDATE_CALF_WORKFLOW_NAME("");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", msg.c_str());
}

jsoncons::jsonschema::json_schema<jsoncons::json>
Expand All @@ -17,6 +18,7 @@ capiocl::parser::Parser::loadSchema(const char *data) {

std::filesystem::path capiocl::parser::Parser::resolve(std::filesystem::path path,
const std::filesystem::path &prefix) {
UPDATE_CALF_WORKFLOW_NAME("");
if (prefix.empty()) {
return path;
}
Expand All @@ -25,9 +27,9 @@ std::filesystem::path capiocl::parser::Parser::resolve(std::filesystem::path pat
return path;
}

auto resolved = prefix / path;
const auto msg = "Path : " + path.string() + " IS RELATIVE! Resolved to: " + resolved.string();
printer::print(printer::CLI_LEVEL_WARNING, msg);
auto resolved = prefix / path;
CALF_PRINT_COLOR(CALF_CLI_LEVEL_WARNING, "Path %s IS RELATIVE! Resolved to: %s", path.c_str(),
resolved.c_str());

return resolved;
}
Expand All @@ -38,7 +40,8 @@ void capiocl::parser::Parser::validate_json(const jsoncons::json &doc, const cha
// throws jsoncons::jsonschema::validation_error on failure
schema.validate(doc);
} catch (const jsoncons::jsonschema::validation_error &e) {
printer::print(printer::CLI_LEVEL_ERROR, e.what());
UPDATE_CALF_WORKFLOW_NAME("");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_ERROR, "%s", e.what());
throw ParserException("JSON validation failed!");
}
}
Expand Down Expand Up @@ -66,8 +69,10 @@ capiocl::engine::Engine *capiocl::parser::Parser::parse(const std::filesystem::p
}

file.close();
printer::print(printer::CLI_LEVEL_INFO,
"Parsing CAPIO-CL config file for version: " + capio_cl_release);

UPDATE_CALF_WORKFLOW_NAME("");
CALF_PRINT_COLOR(CALF_CLI_LEVEL_INFO, "Parsing CAPIO-CL config file for version: %s",
capio_cl_release.c_str());

if (capio_cl_release == CAPIO_CL_VERSION::V1) {
return available_parsers::parse_v1(source, resolve_prefix, store_only_in_memory);
Expand Down
Loading
Loading