Repository navigation
[Experimental] PGM CLI implementation #1297
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
Merged
+1,484
−12
Merged
Changes from all commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
bcedee0
CLI experiment with singed commit
TonyXiang8787 1b0d2f6
Merge branch 'main' into feature/pgm-cli
mgovers ce329a6
down merge
TonyXiang8787 9f0e593
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 63b2c0e
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 13e1f18
Remove GitHub release job from workflow
TonyXiang8787 3b2548f
help cli
TonyXiang8787 d9b2015
try sign
TonyXiang8787 10ae34f
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 aaa70c0
try to split
TonyXiang8787 417b17b
reuse python shim
TonyXiang8787 fc99c28
add mutex
TonyXiang8787 532316a
call back
TonyXiang8787 21fd9c3
message call back
TonyXiang8787 bccf944
get cli test
TonyXiang8787 0e090a4
cli test
TonyXiang8787 dd4c74a
test more
TonyXiang8787 b919bac
use c
TonyXiang8787 42eb6ce
test shim
TonyXiang8787 0899a7d
Update test target file path for PGMCLI
TonyXiang8787 d282788
Fix CLI linker language for GCC sanitizer builds
Copilot b8be263
sonar
TonyXiang8787 534bc34
clang tidy
TonyXiang8787 45c9338
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 72a8be0
cmake
TonyXiang8787 f6215fe
cpp cli
TonyXiang8787 3c26909
cli
TonyXiang8787 5767dce
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 b763826
use ranges transform
TonyXiang8787 f35a02e
test more
TonyXiang8787 e5c16fe
fix clang tidy
TonyXiang8787 104c70e
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 bd7f158
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 2fea14d
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 47f4a86
trigger ci
TonyXiang8787 2c17bd2
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 9a689eb
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 966b155
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 fc934dd
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 05d0cac
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 3e9b45c
start docs
TonyXiang8787 eb3291a
docs
TonyXiang8787 1812083
fix name
TonyXiang8787 5250946
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 6f55d49
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 1bf768d
use std format
TonyXiang8787 ec0695b
msgpack check comment
TonyXiang8787 2444fc2
add user doc
TonyXiang8787 12f6e7c
add build guide
TonyXiang8787 41aae17
remove shorthand for many options
TonyXiang8787 9934062
explain mutex:'
TonyXiang8787 0e3a08d
add initialization
TonyXiang8787 e7cc31f
more explanation
TonyXiang8787 24114ad
fix typo
TonyXiang8787 7e4a73b
typo
TonyXiang8787 6e8ab9a
typo cli option
TonyXiang8787 5517f9a
some typos
TonyXiang8787 0e854f0
revision on docs
TonyXiang8787 4c0a1f2
adjust some docs
TonyXiang8787 4fb95f3
fix build guide
TonyXiang8787 025ac4e
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 754b5e6
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 8af19c9
use transformer pair
TonyXiang8787 195ba36
Merge branch 'feature/pgm-cli' of https://github.com/PowerGridModel/p…
TonyXiang8787 7deae24
fix enum
TonyXiang8787 2ef1247
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 1f9ef1a
Merge branch 'main' into feature/pgm-cli
TonyXiang8787 5698d2d
use new injection
TonyXiang8787 dbbc93f
dosstring
TonyXiang8787 723f09e
doc in toml
TonyXiang8787 8487ce4
add empty tables
TonyXiang8787 29c496d
verbose to show
TonyXiang8787 a6788b3
use new env
TonyXiang8787 0232ffa
try again with conda
TonyXiang8787 de66550
Update CMakeLists.txt
TonyXiang8787 3b968e9
Update CMakeLists.txt
TonyXiang8787 a0bd2ac
Update docs/advanced_documentation/build-guide.md
TonyXiang8787 edf67f1
Update power_grid_model_c/power_grid_model_cli_backend/src/cli_option…
TonyXiang8787 f8b5fd4
Update power_grid_model_c/power_grid_model_cli_backend/src/cli_main.cpp
TonyXiang8787 37811e8
Update power_grid_model_c/power_grid_model_cli_backend/src/cli_option…
TonyXiang8787 a5455a3
Update power_grid_model_c/power_grid_model_cli_backend/src/cli_option…
TonyXiang8787 588cbfb
fix typo
TonyXiang8787 e470be9
Merge branch 'feature/pgm-cli' of git@github.com:PowerGridModel/power…
TonyXiang8787 f6e7378
fix cmake
TonyXiang8787 7733152
fix error
TonyXiang8787 7b7b514
revert back to stream
TonyXiang8787 4d288d4
remove vvv
TonyXiang8787 53b6256
add sstream
TonyXiang8787 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
TonyXiang8787 marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <!-- | ||
| SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
|
|
||
| SPDX-License-Identifier: MPL-2.0 | ||
| --> | ||
|
|
||
| # Power Grid Model CLI Reference | ||
|
|
||
| This is the CLI reference for the `power-grid-model`. | ||
|
|
||
| **The Power Grid Model CLI is still experimental. We offer no guarantee on stability of CLI arguments!** | ||
|
|
||
| See below the CLI Reference, you can also run `power-grid-model --help` to get them: | ||
|
|
||
| ```{literalinclude} cli-help.txt | ||
| :language: text | ||
| :class: cli-help | ||
| ``` | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| # | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| """Provide Python package entry points outside Conda builds. | ||
|
|
||
| Regular builds expose the CMake root entry point and Python CLI shim through | ||
| package metadata. Conda builds use the native CLI executable directly, so provide empty tables for | ||
| these fields to avoid installing a Python shim that could conflict with it. | ||
| """ | ||
|
|
||
| import os | ||
| from collections.abc import Mapping | ||
| from typing import Any | ||
|
|
||
|
|
||
| def dynamic_metadata(_settings: Mapping[str, Any], _project: Mapping[str, Any]) -> dict[str, Any]: | ||
| if "CONDA_BUILD" in os.environ: | ||
| return {"entry-points": {}, "scripts": {}} | ||
|
|
||
| return { | ||
| "entry-points": {"cmake.root": {"power_grid_model": "power_grid_model._core.power_grid_model_c"}}, | ||
| "scripts": {"power-grid-model": "power_grid_model._core.power_grid_model_c.run_pgm_cli:main"}, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| # | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| add_executable(power_grid_model_cli main.cpp) | ||
|
|
||
| target_link_libraries(power_grid_model_cli PRIVATE power_grid_model_cli_backend) | ||
|
|
||
| set_target_properties( | ||
| power_grid_model_cli | ||
| PROPERTIES | ||
| INSTALL_RPATH_USE_LINK_PATH FALSE | ||
| OUTPUT_NAME "power-grid-model" | ||
| ) | ||
| if(APPLE) | ||
| set_target_properties(power_grid_model_cli PROPERTIES INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}") | ||
| elseif(UNIX) # Linux, BSD (not Windows/macOS) | ||
| set_target_properties(power_grid_model_cli PROPERTIES INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") | ||
| endif() | ||
|
|
||
| install( | ||
| TARGETS power_grid_model_cli | ||
| EXPORT power_grid_modelTargets | ||
| COMPONENT power_grid_model | ||
| ) |
|
TonyXiang8787 marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| // | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| #include <power_grid_model_cli_backend/cli_main.h> | ||
|
|
||
| int main(int argc, char** argv) { return PGM_cli_main(argc, argv, nullptr, nullptr, nullptr); } |
73 changes: 73 additions & 0 deletions
73
power_grid_model_c/power_grid_model_cli_backend/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| # | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| add_library( | ||
| power_grid_model_cli_backend | ||
| SHARED | ||
| "src/cli_main.cpp" | ||
| "src/cli_options.cpp" | ||
| "src/pgm_calculation.cpp" | ||
| ) | ||
|
|
||
| target_include_directories( | ||
| power_grid_model_cli_backend | ||
| PUBLIC | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
| $<INSTALL_INTERFACE:include> | ||
| PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/src | ||
| ) | ||
|
|
||
| file( | ||
| GLOB_RECURSE pgm_cli_backend_public_headers | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h" | ||
| ) | ||
|
|
||
| target_link_libraries(power_grid_model_cli_backend PRIVATE power_grid_model_c) | ||
| target_link_libraries(power_grid_model_cli_backend PRIVATE power_grid_model_cpp) | ||
| target_link_libraries(power_grid_model_cli_backend PRIVATE CLI11::CLI11) | ||
|
|
||
| target_compile_definitions( | ||
| power_grid_model_cli_backend | ||
| PRIVATE | ||
| PGM_CLI_BACKEND_EXPORTS | ||
| PGM_ENABLE_EXPERIMENTAL | ||
| ) | ||
|
|
||
| target_sources( | ||
| power_grid_model_cli_backend | ||
| PUBLIC | ||
| FILE_SET pgm_cli_backend_public_headers | ||
| TYPE HEADERS | ||
| BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include/" | ||
| FILES "${pgm_cli_backend_public_headers}" | ||
| ) | ||
|
|
||
| set_target_properties( | ||
| power_grid_model_cli_backend | ||
| PROPERTIES VERSION ${PGM_VERSION} SOVERSION ${PGM_VERSION_MAJOR} | ||
| ) | ||
|
|
||
| set_target_properties(power_grid_model_cli_backend PROPERTIES INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
| if(APPLE) | ||
| set_target_properties(power_grid_model_cli_backend PROPERTIES INSTALL_RPATH "@loader_path") | ||
| elseif(UNIX) # Linux, BSD (not Windows/macOS) | ||
| set_target_properties(power_grid_model_cli_backend PROPERTIES INSTALL_RPATH "$ORIGIN") | ||
| endif() | ||
|
|
||
| if(NOT PGM_MSVC_REPRODUCIBLE_BUILD) | ||
| set_target_properties( | ||
| power_grid_model_cli_backend | ||
| PROPERTIES | ||
| INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE | ||
| INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE | ||
| ) | ||
| endif() | ||
|
|
||
| install( | ||
| TARGETS power_grid_model_cli_backend | ||
| EXPORT power_grid_modelTargets | ||
| COMPONENT power_grid_model | ||
| FILE_SET pgm_cli_backend_public_headers | ||
| ) |
62 changes: 62 additions & 0 deletions
62
...grid_model_c/power_grid_model_cli_backend/include/power_grid_model_cli_backend/cli_main.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> | ||
| // | ||
| // SPDX-License-Identifier: MPL-2.0 | ||
|
|
||
| #pragma once | ||
| #ifndef POWER_GRID_MODEL_CLI_BACKEND_CLI_MAIN_H | ||
| #define POWER_GRID_MODEL_CLI_BACKEND_CLI_MAIN_H | ||
|
|
||
| #ifdef _WIN32 | ||
| #define PGM_CLI_HELPER_DLL_IMPORT __declspec(dllimport) | ||
| #define PGM_CLI_HELPER_DLL_EXPORT __declspec(dllexport) | ||
| #define PGM_CLI_HELPER_DLL_LOCAL | ||
| #else | ||
| #if __GNUC__ >= 4 | ||
| #define PGM_CLI_HELPER_DLL_IMPORT __attribute__((visibility("default"))) | ||
| #define PGM_CLI_HELPER_DLL_EXPORT __attribute__((visibility("default"))) | ||
| #define PGM_CLI_HELPER_DLL_LOCAL __attribute__((visibility("hidden"))) | ||
| #else | ||
| #define PGM_CLI_HELPER_DLL_IMPORT | ||
| #define PGM_CLI_HELPER_DLL_EXPORT | ||
| #define PGM_CLI_HELPER_DLL_LOCAL | ||
| #endif | ||
| #endif | ||
|
|
||
| #ifdef PGM_CLI_BACKEND_EXPORTS | ||
| #define PGM_CLI_API PGM_CLI_HELPER_DLL_EXPORT | ||
| #else | ||
| #define PGM_CLI_API PGM_CLI_HELPER_DLL_IMPORT | ||
| #endif | ||
| #define PGM_CLI_LOCAL PGM_CLI_HELPER_DLL_LOCAL | ||
|
|
||
| #ifdef __cplusplus | ||
| #define PGM_CLI_NOEXCEPT noexcept | ||
| #else | ||
| #define PGM_CLI_NOEXCEPT | ||
| #endif | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| // NOLINTNEXTLINE(modernize-use-using) | ||
| typedef void (*PGM_CLIMessageCallback)(char const* msg, void* user_data); | ||
|
|
||
| /** | ||
| * @brief CLI entry point for the Power Grid Model command line interface. | ||
| * | ||
| * @param argc Number of command line arguments. | ||
| * @param argv Command line arguments. | ||
| * @param cout_callback Callback used for standard output. When null, std::cout is used. | ||
| * @param cerr_callback Callback used for standard error. When null, std::cerr is used. | ||
| * @param user_data Opaque user data forwarded to the callbacks. | ||
| * @return Process exit code. | ||
| */ | ||
| PGM_CLI_API int PGM_cli_main(int argc, char** argv, PGM_CLIMessageCallback cout_callback, | ||
| PGM_CLIMessageCallback cerr_callback, void* user_data) PGM_CLI_NOEXCEPT; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif // POWER_GRID_MODEL_CLI_BACKEND_CLI_MAIN_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.