packages.hpcstat: add support for default queue

This commit is contained in:
2024-08-24 17:05:41 +08:00
parent 0470c1041c
commit 63d5f339ea
9 changed files with 47 additions and 4 deletions

View File

@@ -2,9 +2,11 @@ include("${CMAKE_CURRENT_LIST_DIR}/biuTargets.cmake")
find_package(magic_enum REQUIRED)
find_package(fmt REQUIRED)
find_package(Boost REQUIRED COMPONENTS headers iostreams filesystem system)
find_package(Eigen3 REQUIRED)
find_package(range-v3 REQUIRED)
find_path(NAMEOF_INCLUDE_DIR nameof.hpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(HighFive REQUIRED)
find_path(ZPP_BITS_INCLUDE_DIR zpp_bits.h REQUIRED)
find_package(TgBot REQUIRED)
find_path(LIBBACKTRACE_INCLUDE_DIR backtrace.h REQUIRED)
find_library(LIBBACKTRACE_LIBRARY NAMES backtrace REQUIRED)

View File

@@ -54,6 +54,13 @@ namespace fmt
-> typename FormatContext::iterator;
};
template <biu::SpecializationOf<std::sub_match> SubMatch> struct formatter<SubMatch, typename SubMatch::value_type>
: formatter<std::basic_string<typename SubMatch::value_type>, typename SubMatch::value_type>
{
template <typename FormatContext> auto format(const SubMatch& match, FormatContext& ctx) const
-> typename FormatContext::iterator;
};
template <typename Char, biu::Enumerable T> struct formatter<T, Char>
{
bool full = false;

View File

@@ -80,6 +80,14 @@ namespace fmt
return fmt::format_to(ctx.out(), ")");
}
template <biu::SpecializationOf<std::sub_match> SubMatch> template <typename FormatContext>
auto formatter<SubMatch, typename SubMatch::value_type>::format(const SubMatch& match, FormatContext& ctx) const
-> typename FormatContext::iterator
{
return formatter<std::basic_string<typename SubMatch::value_type>, typename SubMatch::value_type>::format
(match.str(), ctx);
}
template <typename Char, biu::Enumerable T> constexpr auto formatter<T, Char>::parse
(fmt::basic_format_parse_context<Char>& ctx) -> typename fmt::basic_format_parse_context<Char>::iterator
{

View File

@@ -6,4 +6,10 @@ int main()
std::optional<int> a = 3;
std::cout << "{}\n"_f(a);
auto b = "hello"s;
auto c = "h(ell)o"_re;
std::smatch d;
assert(std::regex_match(b, d, c));
assert("{}"_f(d[1]) == "ell");
}

View File

@@ -38,3 +38,9 @@ install(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_DATADIR}/hpcstat)
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
message("Imported targets: ${ImportedTargets}")
message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
include(CTest)
add_executable(test-main test/main.cpp)
target_link_libraries(test-main PRIVATE biu::biu)
set_property(TARGET test-main PROPERTY CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON)
add_test(NAME test-main COMMAND test-main)

View File

@@ -17,4 +17,5 @@
--set HPCSTAT_DATADIR /var/lib/hpcstat --set HPCSTAT_SSH_BINDIR ${openssh}/bin \
--set HPCSTAT_DUC_BINDIR ${duc}/bin
'';
doCheck = true;
}

View File

@@ -31,10 +31,10 @@ namespace hpcstat::lfs
else
{
// Job <462270> is submitted to queue <normal_1day>.
std::regex re(R"r(Job <(\d+)> is submitted to queue <(\w+)>.)r");
// Job <462270> is submitted to default queue <normal>.
std::regex re(R"r(Job <(\d+)> is submitted to(?: default)? queue <(\w+)>.)r");
std::smatch match;
if (std::regex_search(result.Stdout, match, re))
return std::make_pair(std::stoi(match[1]), match[2]);
if (std::regex_search(result.Stdout, match, re)) return std::make_pair(std::stoi(match[1]), match[2]);
else { std::cerr << "Failed to parse job id from output: {}\n"_f(result.Stdout); return std::nullopt; }
}
}

View File

@@ -0,0 +1,12 @@
# include <biu.hpp>
int main()
{
using namespace biu::literals;
std::string s1 = "Job <462270> is submitted to queue <normal_1day>.";
std::string s2 = "Job <462270> is submitted to default queue <normal>.";
std::regex re(R"r(Job <(\d+)> is submitted to(?: default)? queue <(\w+)>.)r");
std::smatch match;
assert(std::regex_match(s1, match, re) && ("{}_{}"_f(match[1], match[2]) == "462270_normal_1day"));
assert(std::regex_match(s2, match, re) && ("{}_{}"_f(match[1], match[2]) == "462270_normal"));
}

View File

@@ -7,4 +7,5 @@
src = ./.;
buildInputs = [ yaml-cpp eigen fmt concurrencpp highfive tbb matplotplusplus biu zpp-bits ];
nativeBuildInputs = [ cmake pkg-config ];
doCheck = true;
}