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

Quit after command-line parses env var #2694

Merged
merged 21 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
319c464
added some patterns to gitignore
tclose Aug 10, 2023
2e024ee
added MRTRIX_PARSE_ONLY environment variable to change behaviour so t…
tclose Aug 10, 2023
329cd09
Added parse to int of PARSE_ONLY env var
tclose Aug 11, 2023
f3ef857
added MR namespace to internal method calls in logging macros
tclose Aug 13, 2023
8f78456
added warning message to indicate that command is
tclose Aug 13, 2023
568e0de
removed argv[0] from parse_only warning message
tclose Aug 13, 2023
79044b0
added MRTRIX_PARSE_ONLY to list of environment variables
tclose Aug 18, 2023
c033eb2
renamed MRTRIX_PARSE_ONLY to MRTRIX_CLI_PARSE_ONLY
tclose Aug 22, 2023
449c596
implemented MRTRIX_CLI_PARSE_ONLY for python commands
tclose Aug 22, 2023
d5f3dd8
reordered CLI_PARSE_ONLY env var in docs reference
tclose Aug 22, 2023
c70cec7
removed generated files from pydra branch
tclose Aug 25, 2023
fd2dfa4
WARN -> INFO for MRTRIX_CLI_PARSE_ONLY
tclose Aug 25, 2023
c7d8f52
relax value for MRTRIX_CLI_PARSE_ONLY to include yes/no in app.py
tclose Aug 25, 2023
486041e
convert parse_only to bool from int
tclose Aug 25, 2023
6ec824d
Merge branch 'dev' into quit-after-usage
tclose Aug 25, 2023
1daa867
made reference to report_to_user_func from logging macros reference f…
tclose Aug 25, 2023
25fd0da
fixed up syntax error and change info() to console()
tclose Aug 25, 2023
349d27f
updated env var description to note that PARSE_ONLY doesn't work for …
tclose Aug 25, 2023
b05e55f
clang formatted command.h
tclose Aug 25, 2023
2afcc3a
Switch CLI_PARSE_ONLY message to CONSOLE
tclose Aug 25, 2023
93d17e2
added in quote to cli_parse_only message
tclose Aug 25, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ testing/src/project_version.h
.__tmp.log
.check_syntax.tmp
.check_syntax2.tmp
*.venv
__pycache__
.DS_Store
13 changes: 13 additions & 0 deletions core/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "app.h"
#include "exec_version.h"
#include "mrtrix.h"
#ifdef MRTRIX_PROJECT
namespace MR {
namespace App {
Expand Down Expand Up @@ -98,6 +99,18 @@ int main (int cmdline_argc, char** cmdline_argv)
::MR::GUI::App app (cmdline_argc, cmdline_argv);
#endif
::MR::App::parse ();

//ENVVAR name: MRTRIX_PARSE_ONLY
//ENVVAR Set the command to parse the provided inputs and then quit
//ENVVAR if it is 1. This can be used in the CI of wrapping code,
//ENVVAR such as the automatically generated Pydra interfaces
char* parse_only = std::getenv("MRTRIX_PARSE_ONLY");
if (parse_only && ::MR::to<int>(parse_only)) {
tclose marked this conversation as resolved.
Show resolved Hide resolved
WARN(
"Quitting after parsing command-line arguments successfully because environment variable 'MRTRIX_PARSE_ONLY' is set to '1'"
);
return 0;
}
run ();
}
catch (::MR::Exception& E) {
Expand Down
10 changes: 5 additions & 5 deletions core/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ namespace MR
* debugging information; anything else: none. */
extern void (*report_to_user_func) (const std::string& msg, int type);

#define CONSOLE(msg) if (MR::App::log_level >= 1) report_to_user_func (msg, -1)
#define FAIL(msg) if (MR::App::log_level >= 0) report_to_user_func (msg, 0)
#define WARN(msg) if (MR::App::log_level >= 1) report_to_user_func (msg, 1)
#define INFO(msg) if (MR::App::log_level >= 2) report_to_user_func (msg, 2)
#define DEBUG(msg) if (MR::App::log_level >= 3) report_to_user_func (msg, 3)
#define CONSOLE(msg) if (MR::App::log_level >= 1) MR::report_to_user_func (msg, -1)
#define FAIL(msg) if (MR::App::log_level >= 0) MR::report_to_user_func (msg, 0)
#define WARN(msg) if (MR::App::log_level >= 1) MR::report_to_user_func (msg, 1)
#define INFO(msg) if (MR::App::log_level >= 2) MR::report_to_user_func (msg, 2)
#define DEBUG(msg) if (MR::App::log_level >= 3) MR::report_to_user_func (msg, 3)



Expand Down
6 changes: 6 additions & 0 deletions docs/reference/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ List of MRtrix3 environment variables
:option:`NumberOfThreads` setting in the configuration file, but
will be overridden by the ENVVAR ``-nthreads`` command-line option.

.. envvar:: MRTRIX_PARSE_ONLY

Set the command to parse the provided inputs and then quit
if it is 1. This can be used in the CI of wrapping code,
such as the automatically generated Pydra interfaces

.. envvar:: MRTRIX_PRESERVE_PHILIPS_ISO

Do not remove the synthetic isotropically-weighted diffusion
Expand Down