Resolve "Deploy Cargo alongside application"

Closes #123 (closed)

Merge request reports

Loading

cli/CMakeLists.txt

0 → 100644
+58 −0
Changes for cli/CMakeLists.txt: 58 added lines, 0 removed lines.
Original line number Diff line number Diff line
################################################################################
# Copyright 2021-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 scord.                                                  #
#                                                                              #
# scord 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.                                          #
#                                                                              #
# scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.              #
#                                                                              #
# SPDX-License-Identifier: GPL-3.0-or-later                                    #
################################################################################

# scord_ping: ping a remote scord server
add_executable(scord_ping)

target_sources(scord_ping
  PRIVATE
  scord_ping.cpp
)

target_link_libraries(scord_ping
  PUBLIC fmt::fmt CLI11::CLI11 libscord)

install(TARGETS scord_ping
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# scord_query: query a remote scord server
add_executable(scord_query)

target_sources(scord_query
  PRIVATE
  scord_query.cpp
)

target_link_libraries(scord_query
  PUBLIC fmt::fmt CLI11::CLI11 libscord)

install(TARGETS scord_query
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

set_target_properties(
  scord_query PROPERTIES __INSTALLED_PATH
                         ${CMAKE_INSTALL_FULL_BINDIR}/scord_query
)

cli/scord_ping.cpp

0 → 100644
+83 −0
Changes for cli/scord_ping.cpp: 83 added lines, 0 removed lines.
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2021-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 scord.
 *
 * scord 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.
 *
 * scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#include <fmt/format.h>
#include <filesystem>
#include <CLI/CLI.hpp>
#include <scord/scord.hpp>

struct ping_config {
    std::string progname;
    std::string server_address;
};

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

    ping_config cfg;

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

    CLI::App app{"Scord ping client", cfg.progname};

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

    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[]) {

    using namespace std::chrono_literals;

    ping_config cfg = parse_command_line(argc, argv);

    try {
        const auto [protocol, address] = parse_address(cfg.server_address);
        ping(scord::server{protocol, address});
        fmt::print("Ping succeeded!\n");
    } catch(const std::exception& ex) {
        fmt::print(stderr, "Ping failed: {}\n", ex.what());
        return EXIT_FAILURE;
    }
}

cli/scord_query.cpp

0 → 100644
+95 −0
Changes for cli/scord_query.cpp: 95 added lines, 0 removed lines.
Original line number Diff line number Diff line
/******************************************************************************
 * Copyright 2021-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 scord.
 *
 * scord 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.
 *
 * scord 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 scord.  If not, see <https://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#include <fmt/format.h>
#include <filesystem>
#include <CLI/CLI.hpp>
#include <scord/scord.hpp>

struct query_config {
    std::string progname;
    std::string server_address;
    std::uint32_t job_id{};
};

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

    query_config cfg;

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

    CLI::App app{"Scord metainfo client", cfg.progname};

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

    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[]) {

    using namespace std::chrono_literals;

    query_config cfg = parse_command_line(argc, argv);

    try {
        const auto [protocol, address] = parse_address(cfg.server_address);

        scord::server srv{protocol, address};

        scord::job_info info =
                scord::query(scord::server{protocol, address}, cfg.job_id);

        fmt::print(stdout,
                   "Job metadata:\n"
                   "  adhoc_controller: {}\n"
                   "  io_procs: {}\n",
                   info.adhoc_controller_address(), info.io_procs());

    } catch(const std::exception& ex) {
        fmt::print(stderr, "Error: {}\n", ex.what());
        return EXIT_FAILURE;
    }
}
+8 −0
Changes for cmake/scord-utils.cmake: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -142,3 +142,11 @@ function(mark_variables_as_advanced)
    mark_as_advanced(${_var})
  endforeach()
endfunction()

# Define a custom target property so that we can store and retrieve the
# installed path of a target.
define_property(
  TARGET PROPERTY __INSTALLED_PATH
  BRIEF_DOCS "Full path to a target's installed location"
  FULL_DOCS "Full path to a target's installed location"
)
+26 −4
Changes for docker/0.4.0-wip/Dockerfile: 26 added lines, 4 removed lines.
Original line number Diff line number Diff line
FROM debian:bullseye-slim
FROM debian:bookworm-slim

LABEL Description="Debian-based environment suitable to build scord"

@@ -32,10 +32,11 @@ RUN apt-get update && \
        libyaml-dev libcurl4-openssl-dev procps \
        # genopts dependencies
        python3-venv \
        # redis-plus-plus dependencies \
        libhiredis-dev \
        # Slurm plugin dependencies \
        libslurm-dev \
        # Cargo dependencies \
        libboost-dev \
        libboost-mpi-dev \
        # tests dependencies \
        python3-pip && \
    ### install cmake 3.23.1 ###################################################
@@ -55,11 +56,14 @@ RUN apt-get update && \
    git clone https://github.com/mercury-hpc/mercury --recurse-submodules && \
    git clone https://github.com/mochi-hpc/mochi-margo --recurse-submodules && \
#    cd mochi-margo && git reset --hard v0.9.9 && cd .. && \
    git clone https://github.com/redis/hiredis.git --recurse-submodules && \
    cd hiredis && git checkout v1.2.0 && cd .. && \
    git clone https://github.com/sewenew/redis-plus-plus --recurse-submodules && \
    git clone https://github.com/francielizanon/agios --recurse-submodules && \
    cd agios && git checkout development && cd .. && \
    git clone https://github.com/USCiLab/cereal --recurse-submodules && \
    git clone https://github.com/mochi-hpc/mochi-thallium --recurse-submodules && \
    git clone https://storage.bsc.es/gitlab/hpc/cargo.git && \
    cd mochi-thallium && \
    export LD_LIBRARY_PATH=${DEPS_INSTALL_PATH}/lib:${DEPS_INSTALL_PATH}/lib64 && \
    export PKG_CONFIG_PATH=${DEPS_INSTALL_PATH}/lib/pkgconfig:${DEPS_INSTALL_PATH}/lib64/pkgconfig && \
@@ -121,6 +125,15 @@ RUN apt-get update && \
    make -j install && \
    cd .. && rm -rf build && cd && \
    \
    ### hiredis
    cd deps/hiredis && \
    mkdir build && cd build && \
    cmake -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PATH} \
          -DCMAKE_BUILD_TYPE:STRING=Release \
          .. && \
    make install -j && \
    cd .. && rm -rf build && cd && \
    \
    ### redis-plus-plus
    cd deps/redis-plus-plus && \
    mkdir build && cd build && \
@@ -161,8 +174,17 @@ RUN apt-get update && \
    make -j install && \
    cd .. && rm -rf build && cd && \
    \
    ### Cargo \
    cd deps/cargo && \
    mkdir build && cd build && \
    cmake -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_PATH} \
          .. && \
    make -j install && \
    cd .. && rm -rf build && cd && \
    \
    ### python packages for testing scripts\
    pip install lark loguru && \
    pip install lark loguru --break-system-packages && \
    \
    ### Cleanup
    # Clean apt cache to reduce image layer size
Loading
Loading