Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#810 Add the possibility to zip the inputs and outputs for N simulation #820

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1826950
#810 Add the possibility to zip the inputs and outputs for N simulation
barondim Dec 13, 2024
efc0b5b
#810 Handle libzip error
barondim Jan 9, 2025
34332f4
#810 Addition of tests with a zip archive in input for N, SA and NSA …
barondim Jan 9, 2025
d511283
#810 Generate zip archive in the main() function
barondim Jan 15, 2025
c54c1dd
#810 Add results.json and outputs directory to the zip archive
barondim Jan 16, 2025
c966b9d
#810 Deletion of useless includes
barondim Jan 17, 2025
3a34c20
#810 Update envDFL.h help message
barondim Jan 17, 2025
0c01277
#810 Little fix
barondim Jan 17, 2025
5020b43
#810 Handle the case when the simulation doesn't dump final state IID…
barondim Jan 17, 2025
a6ef06e
#810 Doxygen
barondim Jan 17, 2025
f83a962
#810 Add an error if the steady state simulation did not generate a f…
barondim Jan 17, 2025
1cac7e3
#810 Add a specific error if Log::addLogFileContentInMapData() method…
barondim Jan 17, 2025
32a042f
#810 Do not add data in mapData if the zip mode is not activated
barondim Jan 17, 2025
57033a1
#810 Postponing results.json generation is useless
barondim Jan 17, 2025
16b413e
#810 PR remark : check that the zip archive exists in envDFL.sh
barondim Jan 17, 2025
633a6e2
#810 Renaming + doxygen
barondim Jan 17, 2025
5390c96
#810 Deletion of ZipErrorMessage.cpp
barondim Jan 17, 2025
3b05720
#810 Renaming
barondim Jan 17, 2025
df7990a
#810 Populate the output files map even if the simulation crashes
barondim Jan 17, 2025
00a6950
#810 Check which outputs should be generated in Context::populateOutp…
barondim Jan 20, 2025
547e11a
#810 Add a unit test for --input-archive option
barondim Jan 20, 2025
9b97e70
#810 Add PRIVATE to all target_link_libraries declarations
barondim Jan 20, 2025
de3c5da
#810 Ensure the files are removed if they already exist before unzipp…
barondim Jan 20, 2025
880fa95
#810 Documentation
barondim Jan 20, 2025
e87f470
#810 Override libzip error message
barondim Jan 21, 2025
4b56c67
#810 Check whether all required files are present in the specified ar…
barondim Jan 21, 2025
36f5773
#810 Little bug fix
barondim Jan 21, 2025
199b017
#810 Little bug fixes
barondim Jan 21, 2025
0aef6cb
#810 Renaming + add a unit test on checking missing files in archive
barondim Jan 21, 2025
1ea2e32
#810 force flush in dynawo.log
barondim Jan 21, 2025
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
177 changes: 143 additions & 34 deletions scripts/envDFL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -494,120 +494,221 @@ build_tests_coverage() {
}

launch() {
if [ -n "$ZIP_ARCHIVE" ]; then
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
error_exit "DFL configuration file $3 doesn't exist"
fi
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3
fi
}

launch_gdb() {
if [ -n "$ZIP_ARCHIVE" ]; then
gdb --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $1 doesn't exist"
error_exit "IIDM network file $1 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $2 doesn't exist"
error_exit "DFL configuration file $2 doesn't exist"
fi
gdb --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3
fi
}

launch_valgrind() {
if [ -n "$ZIP_ARCHIVE" ]; then
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $1 doesn't exist"
error_exit "IIDM network file $1 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $2 doesn't exist"
error_exit "DFL configuration file $2 doesn't exist"
fi
valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher \
--log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3
fi
}


launch_sa() {
if [ ! -f "$2" ]; then
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
if [ -n "$ZIP_ARCHIVE" ]; then
"$MPIRUN_PATH" -np $NBPROCS $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
fi
"$MPIRUN_PATH" -np $NBPROCS $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4
fi
else
if [ -n "$ZIP_ARCHIVE" ]; then
barondim marked this conversation as resolved.
Show resolved Hide resolved
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4
fi
unset LD_PRELOAD
fi
unset LD_PRELOAD
}

launch_nsa() {
if [ ! -f "$2" ]; then
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
if [ -n "$ZIP_ARCHIVE" ]; then
"$MPIRUN_PATH" -np $NBPROCS $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE \
--nsa # Steady state calculations.
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
fi
"$MPIRUN_PATH" -np $NBPROCS $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--nsa # Steady state calculations.
fi
else
if [ -n "$ZIP_ARCHIVE" ]; then
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE \
--nsa # Steady state calculations.
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
$DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--nsa # Steady state calculations.
fi
unset LD_PRELOAD
fi
unset LD_PRELOAD
}

launch_sa_gdb() {
if [ ! -f "$2" ]; then
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
if [ -n "$ZIP_ARCHIVE" ]; then
"$MPIRUN_PATH" -np $NBPROCS xterm -e gdb -q --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
export_preload
if [ "${DYNAWO_USE_MPI}" == "YES" ]; then
fi
"$MPIRUN_PATH" -np $NBPROCS xterm -e gdb -q --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4
fi
else
if [ -n "$ZIP_ARCHIVE" ]; then
gdb -q --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4 \
--input-archive $ZIP_ARCHIVE
else
if [ ! -f "$2" ]; then
error_exit "IIDM network file $2 doesn't exist"
fi
if [ ! -f "$3" ]; then
error_exit "DFL configuration file $3 doesn't exist"
fi
if [ ! -f "$4" ]; then
error_exit "Security Analysis contingencies file $4 doesn't exist"
fi
gdb -q --args $DYNAFLOW_LAUNCHER_INSTALL_DIR/bin/DynaFlowLauncher --log-level $DYNAFLOW_LAUNCHER_LOG_LEVEL \
--network $2 \
--config $3 \
--contingencies $4
fi
unset LD_PRELOAD
fi
unset LD_PRELOAD
}

version() {
Expand Down Expand Up @@ -740,11 +841,19 @@ case "$1" in
;;
esac

# Nb Threads
# parse options
ARGS=""
while (($#)); do
key="$1"
case "$key" in
--input-archive)
ZIP_ARCHIVE=$2
shift 2 # pass argument and value
;;
--input-archive=*)
ZIP_ARCHIVE="${1#*=}"
shift # past value
;;
--nbThreads|-np)
NBPROCS=$2
shift 2 # pass argument and value
Expand Down
2 changes: 2 additions & 0 deletions sources/Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ configure_file(${CMAKE_SOURCE_DIR}/cmake/version.h.in ${CMAKE_CURRENT_SOURCE_DIR
set(SOURCES
src/Options.cpp
src/Log.cpp
src/ZipErrorMessage.cpp
src/DFLLog_keys.cpp
src/DFLError_keys.cpp
)
Expand Down Expand Up @@ -53,6 +54,7 @@ target_link_libraries(dfl_Common

PRIVATE
Boost::filesystem
libZIP::libZIP
)
add_library(DynaFlowLauncher::common ALIAS dfl_Common)
install(FILES ${CMAKE_SOURCE_DIR}/etc/Dictionaries/DFLLog_en_GB.dic ${CMAKE_SOURCE_DIR}/etc/Dictionaries/DFLError_en_GB.dic DESTINATION share)
Expand Down
2 changes: 1 addition & 1 deletion sources/Common/include/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#pragma once

#include <boost/optional.hpp>
#include <boost/program_options.hpp>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -43,6 +42,7 @@ class Options {
std::string networkFilePath; ///< Network filepath to process
std::string contingenciesFilePath; ///< Contingencies filepath for security analysis
std::string configPath; ///< Launcher configuration filepath
std::string zipArchivePath; ///< zip archive path to unzip to get input files
std::string dynawoLogLevel; ///< chosen log level
};

Expand Down
15 changes: 15 additions & 0 deletions sources/Common/include/ZipErrorMessage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Copyright (c) 2025, RTE (http://www.rte-france.com)
// See AUTHORS.txt
// All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at http://mozilla.org/MPL/2.0/.
// SPDX-License-Identifier: MPL-2.0
//

#pragma once

#include <libzip/ZipException.h>

std::string formatZipErrorMessage(const zip::ZipException& e);
Loading
Loading