Resolve "Interface with FTIO"

Closes #40 (closed)

Merge request reports

Loading
+20 −1
Changes for cli/CMakeLists.txt: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -101,7 +101,26 @@ target_link_libraries(shaping
    cargo
)

install(TARGETS cargo_ping cargo_shutdown ccp shaping

################################################################################
## ftio: A CLI tool to send the ftio info to a Cargo server 
add_executable(cargo_ftio)

target_sources(cargo_ftio
  PRIVATE
    ftio.cpp
)

target_link_libraries(cargo_ftio
  PUBLIC
    fmt::fmt
    CLI11::CLI11
    net::rpc_client
    cargo
)


install(TARGETS cargo_ping cargo_shutdown ccp shaping cargo_ftio
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

+2 −0
Changes for cli/copy.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ parse_command_line(int argc, char* argv[]) {
                   "Flags for input datasets. Accepted values\n"
                   "  - posix: read data using POSIX (default)\n"
                   "  - parallel: read data using MPI-IO\n"
                    "  - dataclay: read data using DATACLAY\n"
                   "  - gekkofs: read data using gekkofs user library\n")
            ->option_text("FLAGS")
            ->transform(CLI::CheckedTransformer(dataset_flags_map,
@@ -87,6 +88,7 @@ parse_command_line(int argc, char* argv[]) {
                   "Flags for output datasets. Accepted values\n"
                   "  - posix: write data using POSIX (default)\n"
                   "  - parallel: write data using MPI-IO\n"
                   "  - dataclay: write data using DATACLAY\n"
                   "  - gekkofs: write data using gekkofs user library\n")
            ->option_text("FLAGS")
            ->transform(CLI::CheckedTransformer(dataset_flags_map,

cli/ftio.cpp

0 → 100644
+133 −0
Changes for cli/ftio.cpp: 133 added lines, 0 removed lines.
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain
 *
 * This software was partially supported by the EuroHPC-funded project ADMIRE
 *   (Project ID: 956748, https://www.admire-eurohpc.eu).
 *
 * This file is part of Cargo.
 *
 * Cargo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Cargo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Cargo.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#include <fmt/format.h>
#include <cargo.hpp>
#include <filesystem>
#include <CLI/CLI.hpp>
#include <net/client.hpp>
#include <net/endpoint.hpp>

struct ftio_config {
    std::string progname;
    std::string server_address;
    float confidence;
    float probability;
    float period;
    bool run{false};
    bool pause{false};
    bool resume{false};
};

ftio_config
parse_command_line(int argc, char* argv[]) {

    ftio_config cfg;

    cfg.progname = std::filesystem::path{argv[0]}.filename().string();

    CLI::App app{"Cargo ftio client", cfg.progname};

    app.add_option("-s,--server", cfg.server_address, "Server address")
            ->option_text("ADDRESS")
            ->required();

    app.add_option("-c,--conf", cfg.confidence, "confidence")
            ->option_text("float")
            ->default_val("-1.0");

    app.add_option("-p,--probability", cfg.probability, "probability")
            ->option_text("float")
            ->default_val("-1.0");

    app.add_option("-t,--period", cfg.period, "period")
            ->option_text("float")
            ->default_val("-1.0");

    app.add_flag(
            "--run", cfg.run,
            "Trigger stage operation to run now. Has no effect when period is set > 0");

    app.add_flag(
        "--pause", cfg.pause,
        "Trigger stage operation to slow down. Other parameters not used");
    
    app.add_flag("--resume", cfg.resume, "Trigger stage operation to resume, only pause or resume will take into account. Others parameters not used.");
    
    try {
        app.parse(argc, argv);
        return cfg;
    } catch(const CLI::ParseError& ex) {
        std::exit(app.exit(ex));
    }
}

auto
parse_address(const std::string& address) {
    const auto pos = address.find("://");
    if(pos == std::string::npos) {
        throw std::runtime_error(fmt::format("Invalid address: {}", address));
    }

    const auto protocol = address.substr(0, pos);
    return std::make_pair(protocol, address);
}


int
main(int argc, char* argv[]) {

    ftio_config cfg = parse_command_line(argc, argv);

    try {
        const auto [protocol, address] = parse_address(cfg.server_address);
        network::client rpc_client{protocol};

        if(const auto result = rpc_client.lookup(address); result.has_value()) {
            const auto& endpoint = result.value();
            const auto retval =
                    endpoint.call("ftio_int", cfg.confidence, cfg.probability,
                                  cfg.period, cfg.run, cfg.pause, cfg.resume);

            if(retval.has_value()) {

                auto error_code = int{retval.value()};

                fmt::print("ftio_int RPC was successful!\n");
                fmt::print("  (server replied with: {})\n", error_code);
                return EXIT_SUCCESS;
            }

            fmt::print(stderr, "ftio_int RPC failed\n");
            return EXIT_FAILURE;

        } else {
            fmt::print(stderr, "Failed to lookup address: {}\n", address);
            return EXIT_FAILURE;
        }
    } catch(const std::exception& ex) {
        fmt::print(stderr, "Error: {}\n", ex.what());
        return EXIT_FAILURE;
    }
}
+74 −0
Changes for cmake/FindDataClay.cmake: 74 added lines, 0 removed lines.
Original line number Diff line number Diff line
################################################################################
# Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain            #
#                                                                              #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
#                                                                              #
# This file is part of cargo.                                                  #
#                                                                              #
# cargo is free software: you can redistribute it and/or modify                #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# cargo is distributed in the hope that it will be useful,                     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with cargo.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################


find_path(DataClay_INCLUDE_DIR
  NAMES dataclayplugin.h
  PREFIX dataclay-plugin
)

find_path(DataClay_MODEL_DIR
  NAMES client.py
  PREFIX dataclay-plugin
)
message(STATUS "[${PROJECT_NAME}] DataClay library MODEL DIR ${DataClay_MODEL_DIR}")




find_library(DataClay_LIBRARY
  NAMES dataclay-plugin/libdataclayplugin.so
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
	DataClay
	DEFAULT_MSG
	DataClay_INCLUDE_DIR
	DataClay_LIBRARY
	DataClay_MODEL_DIR
)

if(DataClay_FOUND)
  find_package(Python3 REQUIRED Development)
  message(STATUS "[${PROJECT_NAME}] DataClay library needs Python include ${Python3_INCLUDE_DIRS}")

  set(DataClay_LIBRARIES ${DataClay_LIBRARY})
  set(DataClay_INCLUDE_DIRS ${DataClay_INCLUDE_DIR} )


  if(NOT TARGET DataClay::DataClay)
	  add_library(DataClay::DataClay UNKNOWN IMPORTED)
	  set_target_properties(DataClay::DataClay PROPERTIES
		IMPORTED_LOCATION "${DataClay_LIBRARY}"
		INTERFACE_INCLUDE_DIRECTORIES "${DataClay_INCLUDE_DIR};${Python3_INCLUDE_DIRS}"
	  )
	endif()
endif()


mark_as_advanced(
	DataClay_INCLUDE_DIR
	DataClay_LIBRARY
)
+7 −11
Changes for cmake/FindExpand.cmake: 7 added lines, 11 removed lines.
Original line number Diff line number Diff line
################################################################################
# Copyright 2018-2023, Barcelona Supercomputing Center (BSC), Spain            #
# Copyright 2015-2023, Johannes Gutenberg Universitaet Mainz, Germany          #
# Copyright 2022-2023, Barcelona Supercomputing Center (BSC), Spain            #
#                                                                              #
# This software was partially supported by the                                 #
# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu).    #
# This software was partially supported by the EuroHPC-funded project ADMIRE   #
#   (Project ID: 956748, https://www.admire-eurohpc.eu).                       #
#                                                                              #
# This software was partially supported by the                                 #
# ADA-FS project under the SPPEXA project funded by the DFG.                   #
# This file is part of cargo.                                                  #
#                                                                              #
# This file is part of GekkoFS.                                                #
#                                                                              #
# GekkoFS is free software: you can redistribute it and/or modify              #
# cargo is free software: you can redistribute it and/or modify                #
# it under the terms of the GNU General Public License as published by         #
# the Free Software Foundation, either version 3 of the License, or            #
# (at your option) any later version.                                          #
#                                                                              #
# GekkoFS is distributed in the hope that it will be useful,                   #
# cargo is distributed in the hope that it will be useful,                     #
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
# GNU General Public License for more details.                                 #
#                                                                              #
# You should have received a copy of the GNU General Public License            #
# along with GekkoFS.  If not, see <https://www.gnu.org/licenses/>.            #
# along with cargo.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################
Loading
Loading