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

Rework of the CLI argument parser and add the option to define inputs through a JSON file #93

Merged
merged 34 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b99a7f0
Add first parser attempt
Sep 24, 2022
ab653cb
Use argparser
Sep 25, 2022
27c7749
Convert all execs to use new argparser
Sep 25, 2022
2f0446e
Add json option and example files for all parameters
Sep 25, 2022
5e4cbeb
Include json in dependencies
Sep 25, 2022
9eacdb7
Add json to readme
Sep 25, 2022
053cba4
Bump version
Sep 25, 2022
3619132
Bump version
Sep 25, 2022
48ff460
Fix missing json check and add install to workflows
Sep 25, 2022
2df8035
Run ubuntu on 22.04
Sep 25, 2022
8d4a132
Add unit tests and documentation for parser
Sep 30, 2022
f604cbe
Fix unit test
Sep 30, 2022
49d0441
Use template function to convert value in types
Sep 30, 2022
5dd35b6
Fix windows uint problem and get catch2 through conan
phbasler Sep 30, 2022
9383965
Unify spelling
Oct 4, 2022
8affdcd
Unify spelling of arguments
Oct 4, 2022
8531dc6
Merge branch 'master' into JSON
phbasler Oct 13, 2022
be6fbce
Update cpp-linter.yml
phbasler Oct 14, 2022
16c9d8d
Update cpp-linter.yml
phbasler Oct 14, 2022
3b290bb
Merge branch 'master' into JSON
Oct 14, 2022
3b4012f
apply cmake-format
Oct 14, 2022
43d853d
Automated commit of cmake-format changes.
phbasler Oct 14, 2022
94ed5fc
logger docu
Oct 15, 2022
47c5b3b
Merge branch 'JSON' of https://github.com/phbasler/BSMPT into JSON
Oct 15, 2022
fba4d53
Merge branch 'master' into JSON
phbasler Oct 17, 2022
ef039fb
Apply suggestions from code review
phbasler Nov 5, 2022
e21d647
Remove duplicate cmakedefs
Nov 5, 2022
0c2d39e
Fix missing install on mac
Nov 5, 2022
a9e6954
Only print help output once
Nov 5, 2022
75cb672
Update CMakeLists.txt
phbasler Nov 5, 2022
de31f39
Fix openmp missing on
Nov 5, 2022
d3b896d
Merge branch 'JSON' of https://github.com/phbasler/BSMPT into JSON
Nov 5, 2022
d30d228
opt openmp
Nov 5, 2022
c984ea8
link to openmp target
Nov 5, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
persist-credentials: false
- name: installPackages
run: brew install eigen && brew install gsl && brew install nlopt && brew install boost && brew install libomp
run: brew install eigen && brew install gsl && brew install nlopt && brew install boost && brew install libomp && brew install nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: "!contains(github.event.head_commit.message, 'skip-ci')"

steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name : installPackages
run : sudo apt-get install --no-install-recommends --yes libgsl-dev libeigen3-dev libnlopt-dev libnlopt-cxx-dev libboost-all-dev
run : sudo apt-get install --no-install-recommends --yes libgsl-dev libeigen3-dev libnlopt-dev libnlopt-cxx-dev libboost-all-dev nlohmann-json3-dev
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/cpp-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
style: file
style: "file"
tidy-checks: '-*'
version: '14'

- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
persist-credentials: false
- name : installPackages
run : brew install eigen gsl nlopt boost libomp
run : brew install eigen gsl nlopt boost libomp nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand All @@ -42,7 +42,7 @@ jobs:
with:
persist-credentials: false
- name : installPackages
run : brew install eigen gsl boost libomp
run : brew install eigen gsl boost libomp nlohmann-json
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
Expand Down
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cmake_minimum_required(VERSION 3.13)
project(
BSMPT
VERSION 2.4.0
VERSION 2.5.0
LANGUAGES C CXX
DESCRIPTION
"BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models"
Expand Down Expand Up @@ -37,6 +37,10 @@ if(EnableCoverage)
set(BSMPT_USE_VECTORIZATION OFF)
endif()

if(BSMPT_IS_TOPLEVEL)
include(CTest)
endif()

# -------------------------------- setup cmake --------------------------------
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) # use <packagename>_ROOT as search path
Expand All @@ -62,6 +66,7 @@ find_package(PkgConfig)
find_package(Eigen3 3.3.0 REQUIRED)
find_package(Boost 1.66)
find_package(GSL 2.1 REQUIRED)
find_package(nlohmann_json 3.7.3)

find_package(Threads REQUIRED)

Expand All @@ -83,6 +88,11 @@ if(Boost_FOUND)
endif()
endif()

if(nlohmann_json_FOUND)
set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs}
"${nlohmann_json}/*")
endif()

set(EXPORT_CMAES FALSE)
include(FetchContent)
if(UseLibCMAES AND NOT WIN32)
Expand Down Expand Up @@ -211,9 +221,6 @@ endif(BSMPT_IS_TOPLEVEL)

# -------------------- Testing
# ---------------------------------------------------
if(BSMPT_IS_TOPLEVEL)
include(CTest)
endif()

if(BSMPT_IS_TOPLEVEL AND BUILD_TESTING)
add_subdirectory(tests)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas M
SPDX-License-Identifier: GPL-3.0-or-later
-->

Program: BSMPT version 2.4.0
Program: BSMPT version 2.5.0

Released by: Philipp Basler and Lisa Biermann and Margarete Mühlleitner and Jonas Müller

Expand Down Expand Up @@ -137,6 +137,9 @@ Also contact us if you have a custom model for BSMPT v1.x and you have trouble c

## Executables
BSMPT provides multiple executables. Here we give a quick overview of them. For every executable you can call them with the `--help` option to get an overview of possible input parameters.

Additionally, every executable has the option to set the `--json=/path/to/your/file.json` which contains a json string with the parameters you can set through the CLI. This can be useful if you want to store the parameters you used for a given call. Please beware that all relative paths in the json file are considered relative to the current working directory and not to the location of the json file. Examples can be found in `example/JSON`. If you want to be sure to have the correct output file we recommend using absolute paths.

For the following examples the C2HDM with the example/C2HDM_Input.dat file is used.

### BSMPT
Expand Down
17 changes: 17 additions & 0 deletions example/JSON/BSMPT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
13 changes: 13 additions & 0 deletions example/JSON/CalcCT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
19 changes: 19 additions & 0 deletions example/JSON/CalculateEWBG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
17 changes: 17 additions & 0 deletions example/JSON/NLOVEV.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
19 changes: 19 additions & 0 deletions example/JSON/PlotEWBG_nL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",
"vw": "0.1",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
21 changes: 21 additions & 0 deletions example/JSON/PlotEWBG_vw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"config": "../example/EWBG_config.txt",
"vw_min": "0.1",
"vw_max": "0.2",
"vw_stepsize": "0.05",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
14 changes: 14 additions & 0 deletions example/JSON/Test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"model": "c2hdm",
"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
13 changes: 13 additions & 0 deletions example/JSON/TripleHiggsCouplingsNLO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"firstLine": "2",
"lastLine": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
20 changes: 20 additions & 0 deletions example/JSON/VEVEVO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"line": "2",
"input": "../example/C2HDM_Input.dat",
"output": "test.tsv",
"model": "c2hdm",
"temperatureStart": "0",
"temperatureEnd": "100",
"temperatureStep": "5",

"useNLopt": "true",
"useCMAES": "true",
"useGSL": "true",
"useMultiThreading": "true",
"logginglevel::default": "true",
"logginglevel::minimizerdetailed": "false",
"logginglevel::ewbgdetailed": "false",
"logginglevel::debug": "false",
"logginglevel::progdetailed": "false",
"logginglevel::disabled_comment": "remove _comment from key to disable logger"
}
1 change: 1 addition & 0 deletions include/BSMPT/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#cmakedefine libcmaes_FOUND
#cmakedefine NLopt_FOUND
#cmakedefine Boost_FOUND
#cmakedefine nlohmann_json_FOUND
25 changes: 19 additions & 6 deletions include/BSMPT/utility/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ namespace BSMPT
{

class Logger;
class parser;

void ShowLoggerHelp();
void SetLogger(const parser &argparser);
void SetLogger(const std::vector<std::string> &args);

enum class LoggingLevel
Expand All @@ -32,18 +34,29 @@ enum class LoggingLevel
Debug
};

/**
* @brief The BSMPTLogger class
*/
class BSMPTLogger
{
public:
friend Logger;
BSMPTLogger(std::ostream &os) : mOstream{os.rdbuf()} {}
BSMPTLogger(const BSMPTLogger &) = delete;
BSMPTLogger(BSMPTLogger &&) = delete;
BSMPTLogger(const BSMPTLogger &) = delete;
BSMPTLogger(BSMPTLogger &&) = delete;
BSMPTLogger &operator=(const BSMPTLogger &) = delete;
BSMPTLogger &operator=(BSMPTLogger &&) = delete;
BSMPTLogger &operator=(BSMPTLogger &&) = delete;

private:
/**
* @brief SetOStream sets the output of the logger to a certain ostream
* @param Ostream
*/
void SetOStream(std::ostream &Ostream);
/**
* @brief SetOStream writes the output of the logger to a file
* @param file
*/
void SetOStream(const std::string &file);
template <typename T>
void
Expand Down Expand Up @@ -81,10 +94,10 @@ class BSMPTLogger
class Logger
{
public:
Logger(const Logger &) = delete;
Logger(Logger &&) = delete;
Logger(const Logger &) = delete;
Logger(Logger &&) = delete;
Logger &operator=(const Logger &) = delete;
Logger &operator=(Logger &&) = delete;
Logger &operator=(Logger &&) = delete;

static void SetLevel(const std::map<LoggingLevel, bool> &Setup)
{
Expand Down
Loading