From 83fb186694b8fcd557c7f5f7cedc2ea2be02d4f2 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 19 May 2020 14:18:31 +0200 Subject: [PATCH 1/3] Print ReFrame environment variables in debug output --- reframe/frontend/cli.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index c813e03e6c..f6ed26375e 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -32,6 +32,31 @@ from reframe.frontend.printer import PrettyPrinter +REFRAME_ENV = [ + 'RFM_CHECK_SEARCH_PATH', + 'RFM_CHECK_SEARCH_RECURSIVE', + 'RFM_COLORIZE', + 'RFM_CONFIG_FILE', + 'RFM_GRAYLOG_SERVER', + 'RFM_IGNORE_CHECK_CONFLICTS', + 'RFM_KEEP_STAGE_FILES', + 'RFM_MODULE_MAP_FILE', + 'RFM_MODULE_MAPPINGS', + 'RFM_NON_DEFAULT_CRAYPE', + 'RFM_OUTPUT_DIR', + 'RFM_PERFLOG_DIR', + 'RFM_PREFIX', + 'RFM_PURGE_ENVIRONMENT', + 'RFM_SAVE_LOG_FILES', + 'RFM_STAGE_DIR', + 'RFM_SYSTEM', + 'RFM_TIMESTAMP_DIRS', + 'RFM_UNLOAD_MODULES', + 'RFM_USER_MODULES', + 'RFM_VERBOSE' +] + + def format_check(check, detailed): lines = [' - %s (found in %s)' % (check.name, inspect.getfile(type(check)))] @@ -53,6 +78,14 @@ def format_check(check, detailed): return '\n'.join(lines) +def format_env(): + ret = 'ReFrame environment variables:\n' + notset = "''" + ret += '\n'.join( + [f' {e}={os.environ.get(e, notset)}' for e in REFRAME_ENV]) + return ret + + def list_checks(checks, printer, detailed=False): printer.info('[List of matched checks]') for c in checks: @@ -416,6 +449,8 @@ def main(): sys.exit(0) + printer.debug(format_env()) + # Setup the check loader loader = RegressionCheckLoader( load_path=site_config.get('general/0/check_search_path'), From e82c21e24f486cedf8122e642bca4bf03bdd3327 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Wed, 20 May 2020 15:54:52 +0200 Subject: [PATCH 2/3] Address PR comments --- reframe/frontend/argparse.py | 6 ++++++ reframe/frontend/cli.py | 35 ++++------------------------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/reframe/frontend/argparse.py b/reframe/frontend/argparse.py index 5cf672fa47..d8b3ca4f87 100644 --- a/reframe/frontend/argparse.py +++ b/reframe/frontend/argparse.py @@ -57,6 +57,12 @@ def cmd_options(self): '''Options filled in by command-line''' return self.__namespace + @property + def env_vars(self): + '''Environment variables related to ReFrame''' + return sorted( + [v[0].split()[0] for v in self.__option_map.values() if v[0]]) + def __getattr__(self, name): if name.startswith('_'): raise AttributeError( diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index f6ed26375e..2bd0abfdbf 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -32,31 +32,6 @@ from reframe.frontend.printer import PrettyPrinter -REFRAME_ENV = [ - 'RFM_CHECK_SEARCH_PATH', - 'RFM_CHECK_SEARCH_RECURSIVE', - 'RFM_COLORIZE', - 'RFM_CONFIG_FILE', - 'RFM_GRAYLOG_SERVER', - 'RFM_IGNORE_CHECK_CONFLICTS', - 'RFM_KEEP_STAGE_FILES', - 'RFM_MODULE_MAP_FILE', - 'RFM_MODULE_MAPPINGS', - 'RFM_NON_DEFAULT_CRAYPE', - 'RFM_OUTPUT_DIR', - 'RFM_PERFLOG_DIR', - 'RFM_PREFIX', - 'RFM_PURGE_ENVIRONMENT', - 'RFM_SAVE_LOG_FILES', - 'RFM_STAGE_DIR', - 'RFM_SYSTEM', - 'RFM_TIMESTAMP_DIRS', - 'RFM_UNLOAD_MODULES', - 'RFM_USER_MODULES', - 'RFM_VERBOSE' -] - - def format_check(check, detailed): lines = [' - %s (found in %s)' % (check.name, inspect.getfile(type(check)))] @@ -78,11 +53,10 @@ def format_check(check, detailed): return '\n'.join(lines) -def format_env(): +def format_env(envvars): ret = 'ReFrame environment variables:\n' - notset = "''" - ret += '\n'.join( - [f' {e}={os.environ.get(e, notset)}' for e in REFRAME_ENV]) + notset = "" + ret += '\n'.join([f' {e}={os.environ.get(e, notset)}' for e in envvars]) return ret @@ -449,7 +423,7 @@ def main(): sys.exit(0) - printer.debug(format_env()) + printer.debug(format_env(options.env_vars)) # Setup the check loader loader = RegressionCheckLoader( @@ -457,7 +431,6 @@ def main(): recurse=site_config.get('general/0/check_search_recursive'), ignore_conflicts=site_config.get('general/0/ignore_check_conflicts') ) - printer.debug(argparse.format_options(options)) def print_infoline(param, value): param = param + ':' From 83c478fb78ac8222df5847c99a3d041f87d341c2 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Fri, 22 May 2020 10:01:23 +0200 Subject: [PATCH 3/3] Address PR comments (version 2) --- reframe/frontend/argparse.py | 13 +------------ reframe/frontend/cli.py | 7 ++++--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/reframe/frontend/argparse.py b/reframe/frontend/argparse.py index d8b3ca4f87..67f0bce3ab 100644 --- a/reframe/frontend/argparse.py +++ b/reframe/frontend/argparse.py @@ -60,8 +60,7 @@ def cmd_options(self): @property def env_vars(self): '''Environment variables related to ReFrame''' - return sorted( - [v[0].split()[0] for v in self.__option_map.values() if v[0]]) + return [v[0].split()[0] for v in self.__option_map.values() if v[0]] def __getattr__(self, name): if name.startswith('_'): @@ -279,13 +278,3 @@ def parse_args(self, args=None, namespace=None): ) return _Namespace(options, self._option_map) - - -def format_options(namespace): - '''Format parsed arguments in ``namespace``.''' - ret = 'Command-line configuration:\n' - ret += '\n'.join( - [' %s=%s' % (attr, val) - for attr, val in sorted(namespace.cmd_options.__dict__.items())] - ) - return ret diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index b5f7e4ceca..6773542eab 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -54,9 +54,10 @@ def format_check(check, detailed): def format_env(envvars): - ret = 'ReFrame environment variables:\n' - notset = "" - ret += '\n'.join([f' {e}={os.environ.get(e, notset)}' for e in envvars]) + ret = '[ReFrame Environment]\n' + notset = '' + envvars = [*envvars, 'RFM_INSTALL_PREFIX'] + ret += '\n'.join(sorted(f' {e}={os.getenv(e, notset)}' for e in envvars)) return ret