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 10 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
3 changes: 3 additions & 0 deletions cmake/TestMain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#

set(_command ${EXE} --network=res/TestIIDM_${TEST_NAME}.iidm --config=res/config_${TEST_NAME}.json)
if(${USE_ZIP} STREQUAL "YES")
list(APPEND _command --input-archive=res/${TEST_NAME}.zip)
endif()
message(STATUS "Execute process: ${_command}")
execute_process(COMMAND ${_command} RESULT_VARIABLE _result)
if(_result)
Expand Down
3 changes: 3 additions & 0 deletions cmake/TestMainNSA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#

set(_dfl_cmd ${EXE} --network=res/TestIIDM_${TEST_NAME}.iidm --config=res/config_${TEST_NAME}.json --contingencies=res/contingencies_${TEST_NAME}.json --nsa)
if(${USE_ZIP} STREQUAL "YES")
list(APPEND _dfl_cmd --input-archive=res/${TEST_NAME}.zip)
endif()
if(NOT DEFINED USE_MPI OR USE_MPI STREQUAL "")
message(FATAL_ERROR "USE_MPI is not defined")
endif()
Expand Down
3 changes: 3 additions & 0 deletions cmake/TestMainSA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#

set(_dfl_cmd ${EXE} --network=res/TestIIDM_${TEST_NAME}.iidm --config=res/config_${TEST_NAME}.json --contingencies=res/contingencies_${TEST_NAME}.json)
if(${USE_ZIP} STREQUAL "YES")
list(APPEND _dfl_cmd --input-archive=res/${TEST_NAME}.zip)
endif()
if(NOT DEFINED USE_MPI OR USE_MPI STREQUAL "")
message(FATAL_ERROR "USE_MPI is not defined")
endif()
Expand Down
3 changes: 2 additions & 1 deletion etc/Dictionaries/DFLError_en_GB.dic
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ MissingICInWarmStartingPointMode = no initial condition (p, q, v or theta) was

//------------------ Outputs -----------------------
MissingGeneratorHvdcParameterInSettings = parameter %1% not found in settings file for generator or hvdc %2%
NoSVCInFlatStartingPointMode = simulation of secondary voltage controls is not possible with 'FLAT' starting point mode
NoSVCInFlatStartingPointMode = simulation of secondary voltage controls is not possible with 'FLAT' starting point mode
FileCreationFailed = failed to create %1%
//------------------ Main ---------------------------
EnvVariableMissing = cannot find environnement variable %1% please check runtime environment
NetworkFileNotFound = network file %1% does not exist
Expand Down
187 changes: 150 additions & 37 deletions scripts/envDFL.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,26 @@ where [option] can be:
update-references update MAIN tests references

=========== Launch
launch [network] [config] launch DynaFlow Launcher:
launch [network] [config] --input-archive [archive]
launch DynaFlow Launcher:
- network: filepath (only IIDM is supported)
- config: filepath (JSON configuration file)
- archive: path to a zip archive containing the network and configuration

launch-sa [network] [config] [contingencies] --nbThreads [nbprocs]
launch-sa [network] [config] [contingencies] --input-archive [archive] --nbThreads [nbprocs]
launch DynaFlow Launcher to run a Security Analysis:
- network: filepath (only IIDM is supported)
- config: filepath (JSON configuration file)
- contingencies: filepath (JSON file)
- archive: path to a zip archive containing the network, configuration and contingencies
- nbprocs: number of MPI processes to use for SA (default 1)

launch-nsa [network] [config] [contingencies] --nbThreads [nbprocs]
launch-nsa [network] [config] [contingencies] --input-archive [archive] --nbThreads [nbprocs]
launch DynaFlow Launcher to run a steadystate calculcation followed by a security Analysis:
- network: filepath (only IIDM is supported)
- config: filepath (JSON configuration file)
- contingencies: filepath (JSON file)
- archive: path to a zip archive containing the network, configuration and contingencies
- nbprocs: number of MPI processes to use for SA (default 1)


Expand Down Expand Up @@ -494,120 +498,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 +845,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
14 changes: 14 additions & 0 deletions sources/Common/include/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ class Log {
* @param outputDir directory where the log should be written
*/
static void init(const common::Options& options, const std::string& outputDir);

/**
* @brief Put the content of a log file in a map
*
* This function reads the content of a log file specified by its absolute path and stores it as a string in the
* provided map, using the relative path as the key.
*
* @param logFileRelativePath the relative path to the log file, used as the key in the map
* @param logFileAbsolutePath the absolute path to the log file, used to locate and read its content
* @param mapData the map where the log file content is stored, with the relative path as the key
*/
static void addLogFileContentInMapData(const std::string& logFileRelativePath,
const std::string& logFileAbsolutePath,
std::unordered_map<std::string, std::string>& mapData);
};

} // namespace common
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
Loading
Loading