Skip to content

Commit

Permalink
Merge pull request PowerGridModel#736 from PowerGridModel/feature/add…
Browse files Browse the repository at this point in the history
…-nightly

Feature/add nightly
  • Loading branch information
mgovers authored Sep 26, 2024
2 parents 2f0f310 + 8144221 commit 38de620
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 45 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ on:
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
inputs:
target:
type: string
description: "The CMake target to run (e.g.: all)"
required: true
# run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
Expand All @@ -23,7 +30,8 @@ on:
options:
- all
- power_grid_model_c
- power_grid_model_cpp
- power_grid_model_api_tests
- all power_grid_model_benchmark_cpp
required: true

concurrency:
Expand Down Expand Up @@ -62,12 +70,12 @@ jobs:
brew install boost eigen nlohmann-json msgpack-cxx doctest
- name: Set build target in case of push
if: github.event_name != 'workflow_dispatch'
if: github.event_name != 'workflow_dispatch' && github.event.event_name != 'workflow_call'
run: |
echo "TARGET=power_grid_model_c" >> $GITHUB_ENV
echo "TARGET=power_grid_model_api_tests" >> $GITHUB_ENV
- name: Set build target in case of workflow dispatch
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'workflow_dispatch' || github.event.event_name == 'workflow_call'
run: |
echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
pull_request:
# run pipeline on merge queue
merge_group:
# run pipeline from another workflow
workflow_call:
# run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: Nightly build

# Controls when the workflow will run
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * *" # Based on UTC time

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
main:
uses: "./.github/workflows/main.yml"

clang-tidy:
uses: "./.github/workflows/clang-tidy.yml"
with:
target: power_grid_model_c
# target: "all power_grid_model_benchmark_cpp" # TODO(mgovers): re-enable when more clang-tidy stuff is fixed
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class Deserializer {
Deserializer& operator=(Deserializer const&) = delete;
// movable
Deserializer(Deserializer&&) = default;
Deserializer& operator=(Deserializer&&) = default;
Deserializer& operator=(Deserializer&&) noexcept = default;

// destructor
~Deserializer() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <string_view>

// custom packers
namespace msgpack {
namespace msgpack { // NOLINT(modernize-concat-nested-namespaces)
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
namespace adaptor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Buffer {
void set_nan(Idx buffer_offset) { set_nan(*this, buffer_offset, 1); }
void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); }

static void set_value(MetaAttribute const* attribute, Buffer const& buffer, RawDataConstPtr src_ptr,
Idx buffer_offset, Idx size, Idx src_stride) {
static void set_value(MetaAttribute const* attribute, Buffer& buffer, // NOSONAR: no reference-to-const
RawDataConstPtr src_ptr, Idx buffer_offset, Idx size, Idx src_stride) {
buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size,
src_stride);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,34 @@ class DatasetWritable {
static DatasetInfo const& get_info(DatasetWritable const& dataset) { return dataset.info_; }
DatasetInfo const& get_info() const { return get_info(*this); }

static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, RawDataPtr data) {
static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx* indptr, RawDataPtr data) {
dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data);
}
void set_buffer(std::string const& component, Idx* indptr, RawDataPtr data) {
set_buffer(*this, component, indptr, data);
}

static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, Buffer const& data) {
static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx* indptr, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr,
data.get());
}
void set_buffer(std::string const& component, Idx* indptr, Buffer const& data) {
set_buffer(*this, component, indptr, data);
}

static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component,
std::string const& attribute, RawDataPtr data) {
static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, RawDataPtr data) {
dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(),
attribute.c_str(), data);
}
void set_attribute_buffer(std::string const& component, std::string const& attribute, RawDataPtr data) {
set_attribute_buffer(*this, component, attribute, data);
}

static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component,
std::string const& attribute, Buffer const& data) {
static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(),
attribute.c_str(), data.get());
}
Expand All @@ -127,43 +129,43 @@ class DatasetMutable {

RawMutableDataset* get() const { return dataset_.get(); }

static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario,
Idx total_elements, Idx const* indptr, RawDataPtr data) {
static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx elements_per_scenario, Idx total_elements,
Idx const* indptr, RawDataPtr data) {
dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(),
elements_per_scenario, total_elements, indptr, data);
}
void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr,
RawDataPtr data) { // NOSONAR: no const
RawDataPtr data) {
add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data);
}

static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario,
Idx total_elements, Idx const* indptr, Buffer const& data) {
static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx elements_per_scenario, Idx total_elements,
Idx const* indptr, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(),
elements_per_scenario, total_elements, indptr, data.get());
}
void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr,
Buffer const& data) { // NOSONAR: no const
Buffer const& data) {
add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data);
}

static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component,
std::string const& attribute, RawDataPtr data) {
static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, RawDataPtr data) {
dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(),
attribute.c_str(), data);
}
void add_attribute_buffer(std::string const& component, std::string const& attribute,
RawDataPtr data) { // NOSONAR: no const
void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataPtr data) {
add_attribute_buffer(*this, component, attribute, data);
}

static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component,
std::string const& attribute, Buffer const& data) {
static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(),
attribute.c_str(), data.get());
}
void add_attribute_buffer(std::string const& component, std::string const& attribute,
Buffer const& data) { // NOSONAR: no const: no const
void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) {
add_attribute_buffer(*this, component, attribute, data);
}

Expand All @@ -190,43 +192,43 @@ class DatasetConst {

RawConstDataset* get() const { return dataset_.get(); }

static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario,
Idx total_elements, Idx const* indptr, RawDataConstPtr data) {
static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx elements_per_scenario, Idx total_elements,
Idx const* indptr, RawDataConstPtr data) {
dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(),
elements_per_scenario, total_elements, indptr, data);
}
void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr,
RawDataConstPtr data) { // NOSONAR: no const
RawDataConstPtr data) {
add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data);
}

static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario,
Idx total_elements, Idx const* indptr, Buffer const& data) {
static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const
std::string const& component, Idx elements_per_scenario, Idx total_elements,
Idx const* indptr, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(),
elements_per_scenario, total_elements, indptr, data.get());
}
void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr,
Buffer const& data) { // NOSONAR: no const
Buffer const& data) {
add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data);
}

static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component,
std::string const& attribute, RawDataConstPtr data) {
static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, RawDataConstPtr data) {
dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(),
attribute.c_str(), data);
}
void add_attribute_buffer(std::string const& component, std::string const& attribute,
RawDataConstPtr data) { // NOSONAR: no const
void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataConstPtr data) {
add_attribute_buffer(*this, component, attribute, data);
}

static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component,
std::string const& attribute, Buffer const& data) {
static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const
std::string const& component, std::string const& attribute, Buffer const& data) {
dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(),
attribute.c_str(), data.get());
}
void add_attribute_buffer(std::string const& component, std::string const& attribute,
Buffer const& data) { // NOSONAR: no const
void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) {
add_attribute_buffer(*this, component, attribute, data);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/benchmark_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(PROJECT_SOURCES
benchmark.cpp
)

add_executable(power_grid_model_benchmark_cpp ${PROJECT_SOURCES})
add_executable(power_grid_model_benchmark_cpp EXCLUDE_FROM_ALL ${PROJECT_SOURCES})
target_link_libraries(power_grid_model_benchmark_cpp
PRIVATE power_grid_model
)
Expand Down
2 changes: 1 addition & 1 deletion tests/native_api_tests/test_api_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ TEST_CASE("API Model") {
}

SUBCASE("Copy model") {
Model model_copy{model};
auto const model_copy = Model{model};
model_copy.calculate(options, single_output_dataset);
node_output.get_value(PGM_def_sym_output_node_id, node_result_id.data(), -1);
node_output.get_value(PGM_def_sym_output_node_energized, node_result_energized.data(), 0, -1);
Expand Down
2 changes: 1 addition & 1 deletion tests/native_api_tests/test_api_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ TEST_CASE("API Serialization and Deserialization") {
ID node_id_2{0};
double node_u_rated_2;
// set buffer
Buffer source_buffer_columnar{PGM_def_input_source, 1};
Buffer const source_buffer_columnar{PGM_def_input_source, 1};
dataset.set_buffer("node", nullptr, nullptr);
dataset.set_attribute_buffer("node", "id", &node_id_2);
dataset.set_attribute_buffer("node", "u_rated", &node_u_rated_2);
Expand Down

0 comments on commit 38de620

Please sign in to comment.