Repository navigation
Expand file tree
/
Copy pathcli.py
More file actions
1949 lines (1759 loc) · 73.2 KB
/
Copy pathcli.py
File metadata and controls
1949 lines (1759 loc) · 73.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright 2016-2024 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause
import functools
import inspect
import itertools
import json
import os
import random
import shlex
import sys
import time
import traceback
import reframe.core.config as config
import reframe.core.exceptions as errors
import reframe.core.logging as logging
import reframe.core.runtime as runtime
import reframe.frontend.argparse as argparse
import reframe.frontend.autodetect as autodetect
import reframe.frontend.ci as ci
import reframe.frontend.dependencies as dependencies
import reframe.frontend.filters as filters
import reframe.frontend.reporting as reporting
import reframe.utility as util
import reframe.utility.jsonext as jsonext
import reframe.utility.osext as osext
import reframe.utility.typecheck as typ
from reframe.core.warnings import suppress_deprecations
from reframe.frontend.testgenerators import (distribute_tests,
getallnodes, repeat_tests,
parameterize_tests)
from reframe.frontend.executors.policies import (SerialExecutionPolicy,
AsynchronousExecutionPolicy)
from reframe.frontend.executors import Runner, generate_testcases
from reframe.frontend.loader import RegressionCheckLoader
from reframe.frontend.printer import PrettyPrinter
def format_env(envvars):
ret = '[ReFrame Environment]\n'
notset = '<not set>'
envvars = [*envvars, 'RFM_INSTALL_PREFIX']
ret += '\n'.join(sorted(f' {e}={os.getenv(e, notset)}' for e in envvars))
return ret
@logging.time_function
def list_checks(testcases, printer, detailed=False, concretized=False):
printer.info('[List of matched checks]')
unique_checks = set()
def dep_lines(u, *, prefix, depth=0, lines=None, printed=None,
fixt_vars=None):
if lines is None:
lines = []
if printed is None:
printed = set(unique_checks)
fixt_to_vars = {}
for fixt_name, fixt in u.check._rfm_fixture_space.items():
key = f'{fixt.cls.__name__}#{fixt.scope}'
fixt_to_vars.setdefault(key, [])
fixt_to_vars[key].append(fixt_name)
adj = u.deps
for v in adj:
if v.check.is_fixture():
fixture_scope = v.check._rfm_fixt_data.scope
key = f'{type(v.check).__name__}#{fixture_scope}'
fixture_vars = fixt_to_vars[key]
else:
fixture_vars = None
unique_checks.add(v.check.unique_name)
if concretized or (not concretized and
v.check.unique_name not in printed):
dep_lines(v, prefix=prefix + 2*' ', depth=depth+1,
lines=lines, printed=printed,
fixt_vars=fixture_vars)
if depth:
if fixt_vars:
fmt_fixt_vars = " '"
fmt_fixt_vars += " '".join(fixt_vars)
else:
fmt_fixt_vars = ''
name_info = (f'{u.check.display_name}{fmt_fixt_vars} '
f'/{u.check.hashcode}')
tc_info = ''
details = ''
if concretized:
tc_info = f' @{u.partition.fullname}+{u.environ.name}'
location = inspect.getfile(type(u.check))
if detailed:
details_fields = [
f'variant: {u.check.variant_num}',
f'file: {location!r}'
]
descr_value = getattr(u.check, 'descr', None)
if descr_value is None:
descr_str = '<undefined>'
elif descr_value == '':
descr_str = '<none>'
else:
descr_str = descr_value
details_fields.append(f'description: {descr_str}')
details = '\n' + '\n'.join(f'{prefix} {field}' for field in details_fields)
lines.append(f'{prefix}^{name_info}{tc_info}{details}')
return lines
# We need the leaf test cases to be printed at the leftmost
leaf_testcases = list(t for t in testcases if t.in_degree == 0)
for t in leaf_testcases:
name_info = f'{t.check.display_name} /{t.check.hashcode}'
tc_info = ''
details = ''
if concretized:
tc_info = f' @{t.partition.fullname}+{t.environ.name}'
location = inspect.getfile(type(t.check))
if detailed:
details_fields = [
f'variant: {t.check.variant_num}',
f'file: {location!r}'
]
descr_value = getattr(t.check, 'descr', None)
if descr_value is None:
descr_str = '<undefined>'
elif descr_value == '':
descr_str = '<none>'
else:
descr_str = descr_value
details_fields.append(f'description: {descr_str}')
details = '\n' + '\n'.join(f' {field}' for field in details_fields)
if concretized or (not concretized and
t.check.unique_name not in unique_checks):
printer.info(f'- {name_info}{tc_info}{details}')
if not t.check.is_fixture():
unique_checks.add(t.check.unique_name)
for l in reversed(dep_lines(t, prefix=' ')):
printer.info(l)
if concretized:
printer.info(f'Concretized {len(testcases)} test case(s)\n')
else:
printer.info(f'Found {len(unique_checks)} check(s)\n')
@logging.time_function
def describe_checks(testcases, printer):
records = []
unique_names = set()
for tc in testcases:
if tc.check.is_fixture():
continue
if tc.check.display_name not in unique_names:
unique_names.add(tc.check.display_name)
rec = json.loads(jsonext.dumps(tc.check))
# Now manipulate the record to be more user-friendly
#
# 1. Add other fields that are relevant for users
# 2. Remove all private fields
cls = type(tc.check)
if hasattr(cls, 'loggable_attrs'):
for name, alt_name in cls.loggable_attrs():
key = alt_name if alt_name else name
try:
with suppress_deprecations():
rec.setdefault(key, getattr(tc.check, name))
except AttributeError:
rec.setdefault(key, '<undefined>')
rec['pipeline_hooks'] = {}
rec['perf_variables'] = list(rec['perf_variables'].keys())
for stage, hooks in tc.check.pipeline_hooks().items():
for hk in hooks:
if hk.__name__ not in tc.check.disabled_hooks:
rec['pipeline_hooks'].setdefault(stage, [])
rec['pipeline_hooks'][stage].append(hk.__name__)
for attr in list(rec.keys()):
if attr == '__rfm_class__':
rec['@class'] = rec[attr]
del rec[attr]
elif attr == '__rfm_file__':
rec['@file'] = rec[attr]
del rec[attr]
elif attr.startswith('_'):
del rec[attr]
# List all required variables
required = []
var_space = type(tc.check).var_space
for var in var_space:
if not var_space[var].is_defined():
required.append(var)
rec['@required'] = required
records.append(dict(sorted(rec.items())))
printer.info(jsonext.dumps(records, indent=2))
def list_tags(testcases, printer):
printer.info('[List of unique tags]')
tags = set()
tags = tags.union(*(t.check.tags for t in testcases))
printer.info(', '.join(f'{t!r}' for t in sorted(tags)))
printer.info(f'Found {len(tags)} tag(s)\n')
def logfiles_message():
log_files = logging.log_files()
msg = 'Log file(s) saved in '
if not log_files:
msg += '<no log file was generated>'
else:
msg += f'{", ".join(repr(f) for f in log_files)}'
return msg
def calc_verbosity(site_config, quiesce):
curr_verbosity = site_config.get('general/0/verbose')
return curr_verbosity - quiesce
class exit_gracefully_on_error:
def __init__(self, message, logger=None, exceptions=None, exitcode=1):
self.__message = message
self.__logger = logger or PrettyPrinter()
self.__exceptions = exceptions or (Exception,)
self.__exitcode = exitcode
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is SystemExit:
# Allow users to exit inside the context manager
logging.getprofiler().exit_region()
logging.getprofiler().print_report(self.__logger.debug)
return
if isinstance(exc_val, self.__exceptions):
self.__logger.error(f'{self.__message}: {exc_val}')
self.__logger.verbose(
''.join(traceback.format_exception(exc_type, exc_val, exc_tb))
)
logging.getprofiler().exit_region()
logging.getprofiler().print_report(self.__logger.debug)
sys.exit(self.__exitcode)
def validate_storage_options(namespace, cmd_options):
storage_enabled = runtime.runtime().get_option('storage/0/enable')
for arg in cmd_options:
attr = arg[2:].replace('-', '_')
if getattr(namespace, attr, None):
if not storage_enabled:
logging.getlogger().error(
f'option `{arg}` requires results storage; '
'either set `RFM_ENABLE_RESULTS_STORAGE=1` or set '
'`"storage": [{"enable": True}]` in the configuration file'
)
return False
# Results storage is enable; try to import polars to make sure the
# installation is sane
try:
import polars # noqa: F401
except ImportError:
logging.getlogger().error(
'results storage requires polars to be installed; '
'reinstall reframe-hpc with analytics turned on'
)
return False
return True
@logging.time_function_noexit
def main():
# Setup command line options
argparser = argparse.ArgumentParser()
action_options = argparser.add_mutually_exclusive_group(required=True)
output_options = argparser.add_argument_group(
'Options controlling ReFrame output'
)
locate_options = argparser.add_argument_group(
'Options for discovering checks'
)
select_options = argparser.add_argument_group(
'Options for selecting checks'
)
run_options = argparser.add_argument_group(
'Options controlling the execution of checks'
)
env_options = argparser.add_argument_group(
'Options controlling the ReFrame environment'
)
testgen_options = argparser.add_argument_group(
'Options for generating tests dynamically'
)
reporting_options = argparser.add_argument_group(
'Options related to results reporting'
)
misc_options = argparser.add_argument_group('Miscellaneous options')
# Output directory options
output_options.add_argument(
'--compress-report', action='store_true',
help='Compress the run report file',
envvar='RFM_COMPRESS_REPORT', configvar='general/compress_report'
)
output_options.add_argument(
'--dont-restage', action='store_false', dest='clean_stagedir',
help='Reuse the test stage directory',
envvar='RFM_CLEAN_STAGEDIR', configvar='general/clean_stagedir'
)
output_options.add_argument(
'--keep-stage-files', action='store_true',
help='Keep stage directories even for successful checks',
envvar='RFM_KEEP_STAGE_FILES', configvar='general/keep_stage_files'
)
output_options.add_argument(
'-o', '--output', action='store', metavar='DIR',
help='Set output directory prefix to DIR',
envvar='RFM_OUTPUT_DIR', configvar='systems/outputdir'
)
output_options.add_argument(
'--perflogdir', action='store', metavar='DIR',
help=('Set performance log data directory prefix '
'(relevant only to the filelog log handler)'),
envvar='RFM_PERFLOG_DIR',
configvar='logging/handlers_perflog/filelog_basedir'
)
output_options.add_argument(
'--prefix', action='store', metavar='DIR',
help='Set general directory prefix to DIR',
envvar='RFM_PREFIX', configvar='systems/prefix'
)
output_options.add_argument(
'--report-file', action='store', metavar='FILE',
help="Store JSON run report in FILE",
envvar='RFM_REPORT_FILE',
configvar='general/report_file'
)
output_options.add_argument(
'--report-junit', action='store', metavar='FILE',
help="Store a JUnit report in FILE",
envvar='RFM_REPORT_JUNIT',
configvar='general/report_junit'
)
output_options.add_argument(
'-s', '--stage', action='store', metavar='DIR',
help='Set stage directory prefix to DIR',
envvar='RFM_STAGE_DIR', configvar='systems/stagedir'
)
output_options.add_argument(
'--save-log-files', action='store_true',
help='Save ReFrame log files to the output directory',
envvar='RFM_SAVE_LOG_FILES', configvar='general/save_log_files'
)
output_options.add_argument(
'--timestamp', action='store', nargs='?', metavar='TIMEFMT',
const=argparse.CONST_DEFAULT,
help=('Append a timestamp to the output and stage directory prefixes '
'(default: "%%Y%%m%%dT%%H%%M%%S%%z")'),
envvar='RFM_TIMESTAMP_DIRS', configvar='general/timestamp_dirs'
)
# Check discovery options
locate_options.add_argument(
'-c', '--checkpath', action='append', metavar='PATH',
help="Add PATH to the check search path list",
envvar='RFM_CHECK_SEARCH_PATH :', configvar='general/check_search_path'
)
locate_options.add_argument(
'-R', '--recursive', action='store_true',
help='Search for checks in the search path recursively',
envvar='RFM_CHECK_SEARCH_RECURSIVE',
configvar='general/check_search_recursive'
)
# Select options
select_options.add_argument(
'--cpu-only', action='store_true',
help='Select only CPU checks'
)
select_options.add_argument(
'--failed', action='store_true',
help="Select failed test cases (only when '--restore-session' is used)"
)
select_options.add_argument(
'--gpu-only', action='store_true',
help='Select only GPU checks'
)
select_options.add_argument(
'--maintainer', action='append', dest='maintainers', default=[],
metavar='PATTERN',
help='Select checks with at least one maintainer matching PATTERN'
)
select_options.add_argument(
'-n', '--name', action='append', dest='names', default=[],
metavar='PATTERN', help='Select checks whose name matches PATTERN'
)
# FIXME: The following is the only selection option that has an associated
# (undocumented) configuration variable. This is to support pruning of the
# partition environments as the runtime is created, similarly to how the
# system partitions are treated. Currently, this facilitates the
# implementation of fixtures, but we should reconsider it: see discussion
# in https://github.com/reframe-hpc/reframe/issues/2245
select_options.add_argument(
'-p', '--prgenv', action='append', default=[r'.*'], metavar='PATTERN',
configvar='general/valid_env_names',
help=('Select checks with at least one '
'programming environment matching PATTERN')
)
select_options.add_argument(
'-T', '--exclude-tag', action='append', dest='exclude_tags',
metavar='PATTERN', default=[],
help='Exclude checks whose tag matches PATTERN'
)
select_options.add_argument(
'-t', '--tag', action='append', dest='tags', metavar='PATTERN',
default=[],
help='Select checks with at least one tag matching PATTERN'
)
select_options.add_argument(
'-x', '--exclude', action='append', dest='exclude_names',
metavar='PATTERN', default=[],
help='Exclude checks whose name matches PATTERN'
)
select_options.add_argument(
'-E', '--filter-expr', action='append', metavar='EXPR',
help='Select checks that satisfy the expression EXPR'
)
action_options.add_argument(
'--ci-generate', action='store', metavar='FILE',
help=('Generate into FILE a Gitlab CI pipeline '
'for the selected tests and exit'),
)
action_options.add_argument(
'--delete-stored-sessions', action='store', metavar='QUERY',
help='Delete stored sessions'
)
action_options.add_argument(
'--describe', action='store_true',
help='Give full details on the selected tests'
)
action_options.add_argument(
'--describe-stored-sessions', action='store', metavar='QUERY',
help='Get detailed session information in JSON'
)
action_options.add_argument(
'--describe-stored-testcases', action='store',
metavar='QUERY',
help='Get detailed test case information in JSON'
)
action_options.add_argument(
'--detect-host-topology', metavar='FILE', action='store',
nargs='?', const='-',
help=('Detect the local host topology and exit, '
'optionally saving it in FILE')
)
action_options.add_argument(
'--dry-run', action='store_true',
help='Dry run the tests without submitting them for execution'
)
action_options.add_argument(
'-L', '--list-detailed', nargs='?', const='T', choices=['C', 'T'],
help=('List the selected tests (T) or the concretized test cases (C) '
'providing more details')
)
action_options.add_argument(
'--list-stored-sessions', nargs='?', action='store',
const='now-1w:now', metavar='QUERY', help='List stored sessions'
)
action_options.add_argument(
'--list-stored-testcases', action='store', metavar='QUERY',
help='List performance info for stored testcases'
)
action_options.add_argument(
'-l', '--list', nargs='?', const='T', choices=['C', 'T'],
help='List the selected tests (T) or the concretized test cases (C)'
)
action_options.add_argument(
'--list-tags', action='store_true',
help='List the unique tags found in the selected tests and exit'
)
action_options.add_argument(
'--performance-compare', metavar='CMPSPEC', action='store',
help='Compare past performance results'
)
action_options.add_argument(
'-r', '--run', action='store_true',
help='Run the selected checks'
)
action_options.add_argument(
'--show-config', action='store', nargs='?', const='all',
metavar='PARAM',
help='Print the value of configuration parameter PARAM and exit'
)
action_options.add_argument(
'-V', '--version', action='version', version=osext.reframe_version()
)
# Run options
run_options.add_argument(
'--disable-hook', action='append', metavar='NAME', dest='hooks',
default=[], help='Disable a pipeline hook for this run'
)
run_options.add_argument(
'--duration', action='store', metavar='TIMEOUT',
help='Run the test session repeatedly for the specified duration'
)
run_options.add_argument(
'--exec-order', metavar='ORDER', action='store',
choices=['name', 'random', 'rname', 'ruid', 'uid'],
help='Impose an execution order for independent tests'
)
run_options.add_argument(
'--exec-policy', metavar='POLICY', action='store',
choices=['async', 'serial'], default='async',
help='Set the execution policy of ReFrame (default: "async")'
)
run_options.add_argument(
'--flex-alloc-nodes', action='store',
dest='flex_alloc_nodes', metavar='{all|STATE|NUM}', default=None,
help='Set strategy for the flexible node allocation (default: "idle").'
)
run_options.add_argument(
'--flex-alloc-strict', action='store_true',
envvar='RFM_FLEX_ALLOC_STRICT',
configvar='general/flex_alloc_strict',
help='Fail the flexible tests if not enough nodes can be found'
)
run_options.add_argument(
'-J', '--job-option', action='append', metavar='OPT',
dest='job_options', default=[],
help='Pass option OPT to job scheduler'
)
run_options.add_argument(
'--max-retries', metavar='NUM', action='store', default=0,
help='Set the maximum number of times a failed regression test '
'may be retried (default: 0)', type=int
)
run_options.add_argument(
'--maxfail', metavar='NUM', action='store', default=sys.maxsize,
help='Exit after first NUM failures', type=int
)
run_options.add_argument(
'--mode', action='store', help='Execution mode to use'
)
run_options.add_argument(
'--reruns', action='store', metavar='N', default=0,
help='Rerun the whole test session N times', type=int
)
run_options.add_argument(
'--restore-session', action='store', nargs='?', const='',
metavar='REPORT',
help='Restore a testing session from REPORT file'
)
run_options.add_argument(
'--retries-threshold', action='store', default='1000%',
metavar='VALUE[%]',
help='Retry tests only if failures do not exceed threshold'
)
run_options.add_argument(
'-S', '--setvar', action='append', metavar='[TEST.]VAR=VAL',
dest='vars', default=[],
help=('Set test variable VAR to VAL in all tests '
'or optionally in TEST only')
)
run_options.add_argument(
'--skip-performance-check', action='store_true',
help='Skip performance checking'
)
run_options.add_argument(
'--skip-prgenv-check', action='store_true',
help='Skip programming environment check'
)
run_options.add_argument(
'--skip-sanity-check', action='store_true',
help='Skip sanity checking'
)
run_options.add_argument(
'--skip-system-check', action='store_true',
help='Skip system check'
)
# Environment options
env_options.add_argument(
'-M', '--map-module', action='append', metavar='MAPPING',
dest='module_mappings',
help='Add a module mapping',
envvar='RFM_MODULE_MAPPINGS ,', configvar='general/module_mappings'
)
env_options.add_argument(
'-m', '--module', action='append',
metavar='MOD', dest='user_modules',
help='Load module MOD before running any regression check',
envvar='RFM_USER_MODULES ,', configvar='general/user_modules'
)
env_options.add_argument(
'--module-mappings', action='store', metavar='FILE',
dest='module_map_file',
help='Load module mappings from FILE',
envvar='RFM_MODULE_MAP_FILE', configvar='general/module_map_file'
)
env_options.add_argument(
'--module-path', action='append', metavar='PATH',
dest='module_paths', default=[],
help='(Un)use module path PATH before running any regression check',
)
env_options.add_argument(
'--non-default-craype', action='store_true',
help='Test a non-default Cray Programming Environment',
envvar='RFM_NON_DEFAULT_CRAYPE', configvar='general/non_default_craype'
)
env_options.add_argument(
'--purge-env', action='store_true', dest='purge_env',
help='Unload all modules before running any regression check',
envvar='RFM_PURGE_ENVIRONMENT', configvar='general/purge_environment'
)
env_options.add_argument(
'-u', '--unload-module', action='append', metavar='MOD',
dest='unload_modules',
help='Unload module MOD before running any regression check',
envvar='RFM_UNLOAD_MODULES ,', configvar='general/unload_modules'
)
# Test generation options
testgen_options.add_argument(
'--distribute', action='store', metavar='{all|avail|STATE}',
nargs='?', const='idle',
help=('Distribute the selected single-node jobs on every node that'
'is in STATE (default: "idle"')
)
testgen_options.add_argument(
'-P', '--parameterize', action='append', metavar='VAR:VAL0,VAL1,...',
default=[], help='Parameterize a test on a set of variables'
)
testgen_options.add_argument(
'--param-values-delim', action='store', default=',',
help='Parameter value delimiter'
)
testgen_options.add_argument(
'--repeat', action='store', metavar='N',
help='Repeat selected tests N times'
)
# Reporting options
reporting_options.add_argument(
'--performance-report', action='store', nargs='?',
const=argparse.CONST_DEFAULT,
configvar='general/perf_report_spec',
envvar='RFM_PERF_REPORT_SPEC',
help=('Print a report for performance tests '
'(default: "now-1d:now/last:+job_nodelist/+result")')
)
reporting_options.add_argument(
'--session-extras', action='append', metavar='KV_DATA',
help='Annotate session with custom key/value data'
)
# Miscellaneous options
misc_options.add_argument(
'-C', '--config-file', action='append', metavar='FILE',
dest='config_files',
help='Set configuration file',
envvar='RFM_CONFIG_FILES :'
)
misc_options.add_argument(
'--failure-stats', action='store_true', help='Print failure statistics'
)
misc_options.add_argument(
'--nocolor', action='store_false', dest='colorize',
help='Disable coloring of output',
envvar='RFM_COLORIZE', configvar='general/colorize'
)
misc_options.add_argument(
'--system', action='store', help='Load configuration for SYSTEM',
envvar='RFM_SYSTEM'
)
misc_options.add_argument(
'--table-format', choices=['csv', 'pretty', 'plain'],
help='Table formatting',
envvar='RFM_TABLE_FORMAT', configvar='general/table_format'
)
misc_options.add_argument(
'--table-format-delim', action='store',
help='The delimiter to use when using `--table-format=csv`',
envvar='RFM_TABLE_FORMAT_DELIM', configvar='general/table_format_delim'
)
misc_options.add_argument(
'--term-lhs', action='store',
help='LHS term in performance comparisons'
)
misc_options.add_argument(
'--term-rhs', action='store',
help='RHS term in performance comparisons'
)
misc_options.add_argument(
'-v', '--verbose', action='count',
help='Increase verbosity level of output',
envvar='RFM_VERBOSE', configvar='general/verbose'
)
misc_options.add_argument(
'-q', '--quiet', action='count', default=0,
help='Decrease verbosity level of output',
)
misc_options.add_argument(
'--warn-as-error', action='store_true',
help='Treat warnings as errors',
envvar='RFM_WARN_AS_ERROR'
)
# Options not associated with command-line arguments
argparser.add_argument(
dest='sched_access_in_submit',
envvar='RFM_SCHED_ACCESS_IN_SUBMIT',
configvar='systems*/sched_options/sched_access_in_submit',
action='store_true',
help='Pass access options in the submission command (only for Slurm)'
)
argparser.add_argument(
dest='autodetect_fqdn',
envvar='RFM_AUTODETECT_FQDN',
action='store',
default=False,
type=typ.Bool,
help='Use the full qualified domain name as host name'
)
argparser.add_argument(
dest='autodetect_method',
envvar='RFM_AUTODETECT_METHOD',
action='store',
help='Method to detect the system'
)
argparser.add_argument(
dest='autodetect_methods',
envvar='RFM_AUTODETECT_METHODS',
action='store',
help='List of methods for detecting the current system'
)
argparser.add_argument(
dest='autodetect_xthostname',
envvar='RFM_AUTODETECT_XTHOSTNAME',
action='store',
default=False,
type=typ.Bool,
help="Use Cray's xthostname file to retrieve the host name"
)
argparser.add_argument(
dest='config_path',
envvar='RFM_CONFIG_PATH :',
action='append',
help='Directories where ReFrame will look for base configuration'
)
argparser.add_argument(
dest='generate_file_reports',
envvar='RFM_GENERATE_FILE_REPORTS',
configvar='general/generate_file_reports',
action='store_true',
help='Save session report in files'
)
argparser.add_argument(
dest='git_timeout',
envvar='RFM_GIT_TIMEOUT',
configvar='general/git_timeout',
action='store',
help=('Timeout in seconds when checking if the url is a '
'valid repository.'),
type=float
)
argparser.add_argument(
dest='httpjson_url',
envvar='RFM_HTTPJSON_URL',
configvar='logging/handlers_perflog/httpjson_url',
help='URL of HTTP server accepting JSON logs'
)
argparser.add_argument(
dest='ignore_reqnodenotavail',
envvar='RFM_IGNORE_REQNODENOTAVAIL',
configvar='systems*/sched_options/ignore_reqnodenotavail',
action='store_true',
help='Ignore ReqNodeNotAvail Slurm error'
)
argparser.add_argument(
dest='dump_pipeline_progress',
envvar='RFM_DUMP_PIPELINE_PROGRESS',
configvar='general/dump_pipeline_progress',
action='store_true',
help='Dump progress information for the async execution'
)
argparser.add_argument(
dest='perf_info_level',
envvar='RFM_PERF_INFO_LEVEL',
configvar='general/perf_info_level',
action='store',
type=typ.Str[r'critical|error|warning|info|verbose|'
r'debug|debug2|undefined'],
help='Log level at which immediate performance info will be printed'
)
argparser.add_argument(
dest='pipeline_timeout',
envvar='RFM_PIPELINE_TIMEOUT',
configvar='general/pipeline_timeout',
action='store',
help='Timeout for advancing the pipeline',
type=float
)
argparser.add_argument(
dest='poll_randomize_ms',
envvar='RFM_POLL_RANDOMIZE_MS',
configvar='general/poll_randomize_ms',
action='store',
type=typ.List[int],
help='Randomize the sleep interval between polls'
)
argparser.add_argument(
dest='poll_rate_decay',
envvar='RFM_POLL_RATE_DECAY',
configvar='general/poll_rate_decay',
action='store',
type=float,
help='Poll rate decay'
)
argparser.add_argument(
dest='poll_rate_max',
envvar='RFM_POLL_RATE_MAX',
configvar='general/poll_rate_max',
action='store',
type=float,
help='Maximum poll rate'
)
argparser.add_argument(
dest='poll_rate_min',
envvar='RFM_POLL_RATE_MIN',
configvar='general/poll_rate_min',
action='store',
type=float,
help='Minimum poll rate'
)
argparser.add_argument(
dest='reference_prefix',
envvar='RFM_REFERENCE_PREFIX',
configvar='general/reference_prefix',
action='store',
help='Directory prefix for external references'
)
argparser.add_argument(
dest='remote_detect',
envvar='RFM_REMOTE_DETECT',
configvar='general/remote_detect',
action='store_true',
help='Detect remote system topology'
)
argparser.add_argument(
dest='remote_workdir',
envvar='RFM_REMOTE_WORKDIR',
configvar='general/remote_workdir',
action='store',
help='Working directory for launching ReFrame remotely'
)
argparser.add_argument(
dest='resolve_module_conflicts',
envvar='RFM_RESOLVE_MODULE_CONFLICTS',
configvar='general/resolve_module_conflicts',
action='store_true',
help='Resolve module conflicts automatically'
)
argparser.add_argument(
dest='enable_results_storage',
envvar='RFM_ENABLE_RESULTS_STORAGE',
configvar='storage/enable',
action='store_true',
help='Enable results storage'
)
argparser.add_argument(
dest='slurm_job_cancel_reasons',
envvar='RFM_SLURM_JOB_CANCEL_REASONS',
configvar='systems*/sched_options/slurm_job_cancel_reasons',
action='store',
help='Reasons to cancel a Slurm job',
type=typ.List[str]
)
argparser.add_argument(
dest='slurm_pending_job_reason_poll_freq',
envvar='RFM_SLURM_PENDING_JOB_REASON_POLL_FREQ',
configvar='systems*/sched_options/slurm_pending_job_reason_poll_freq',
action='store',
help='Frequency of polling for the reason a Slurm job is pending',
type=int
)
argparser.add_argument(
dest='sqlite_conn_timeout',
envvar='RFM_SQLITE_CONN_TIMEOUT',
configvar='storage/sqlite_conn_timeout',
type=float,
help='Timeout for DB connections (SQLite backend)'
)
argparser.add_argument(
dest='sqlite_db_file',
envvar='RFM_SQLITE_DB_FILE',
configvar='storage/sqlite_db_file',
help='DB file where the results database resides (SQLite backend)'
)
argparser.add_argument(
dest='sqlite_db_file_mode',
envvar='RFM_SQLITE_DB_FILE_MODE',
configvar='storage/sqlite_db_file_mode',
help='DB file permissions (SQLite backend)',
type=functools.partial(int, base=8)
)
output_options.add_argument(
dest='stagedir_hashes',
envvar='RFM_STAGEDIR_HASHES',
configvar='general/stagedir_hashes',
action='store_true',
help='Use hashes in stage and output directory names',
)
argparser.add_argument(
dest='syslog_address',
envvar='RFM_SYSLOG_ADDRESS',
configvar='logging/handlers_perflog/syslog_address',
help='Syslog server address'
)
argparser.add_argument(
dest='trap_job_errors',
envvar='RFM_TRAP_JOB_ERRORS',
configvar='general/trap_job_errors',
action='store_true',
help='Trap job errors in job scripts and fail tests automatically'
)
argparser.add_argument(
dest='use_login_shell',
envvar='RFM_USE_LOGIN_SHELL',
configvar='general/use_login_shell',
action='store_true',
help='Use a login shell for job scripts'
)
def restrict_logging():
'''Restrict logging to errors only.
This is done when specific options are passed, which generate JSON
output and we don't want to pollute the output with other logging
output.
:returns: :obj:`True` if the logging was restricted, :obj:`False`
otherwise.
'''
if (options.show_config or
options.detect_host_topology or
options.describe or
options.describe_stored_sessions or
options.describe_stored_testcases):
logging.getlogger().setLevel(logging.ERROR)
return True
else:
return False
# Parse command line
options = argparser.parse_args()
if len(sys.argv) == 1:
argparser.print_help()
sys.exit(1)
# First configure logging with our generic configuration so as to be able
# to print pretty messages; logging will be reconfigured by user's
# configuration later
site_config = config.load_config('<builtin>')
site_config.select_subconfig('generic')
options.update_config(site_config)
logging.configure_logging(site_config)