def _commandline_args(): """Parse and return command-line arguments """ description = """ Driver for running CTSM system tests Typical usage: ./run_sys_tests -s aux_clm -c COMPARE_NAME -g GENERATE_NAME This automatically detects the machine and launches the appropriate components of the aux_clm test suite on that machine. This script also implements other aspects of the typical CTSM system testing workflow, such as running create_test via qsub on cheyenne, and setting up a directory to hold all of the tests in the test suite. A symbolic link will be created in the current directory pointing to the testroot directory containing all of the test directories in the test suite. Note that the -c/--compare and -g/--generate arguments are required, unless you specify --skip-compare and/or --skip-generate. Any other test suite can be given as well: clm_short, aux_glc, etc. This can also be used to run tests listed in a text file (via the -f/--testfile argument), or tests listed individually on the command line (via the -t/--testname argument). """ parser = argparse.ArgumentParser( description=description, formatter_class=argparse.RawTextHelpFormatter) machine_name = get_machine_name() default_machine = create_machine(machine_name, defaults=MACHINE_DEFAULTS, allow_missing_entries=True) tests_to_run = parser.add_mutually_exclusive_group(required=True) tests_to_run.add_argument('-s', '--suite-name', help='Name of test suite to run') tests_to_run.add_argument('-f', '--testfile', help='Path to file listing tests to run') tests_to_run.add_argument( '-t', '--testname', '--testnames', nargs='+', help='One or more test names to run (space-delimited)') compare = parser.add_mutually_exclusive_group(required=True) compare.add_argument('-c', '--compare', metavar='COMPARE_NAME', help='Baseline name (often tag) to compare against\n' '(required unless --skip-compare is given)') compare.add_argument('--skip-compare', action='store_true', help='Do not compare against baselines') generate = parser.add_mutually_exclusive_group(required=True) generate.add_argument('-g', '--generate', metavar='GENERATE_NAME', help='Baseline name (often tag) to generate\n' '(required unless --skip-generate is given)') generate.add_argument('--skip-generate', action='store_true', help='Do not generate baselines') parser.add_argument( '--suite-compiler', '--suite-compilers', nargs='+', help='Compiler(s) from the given test suite for which tests are run\n' 'Only valid in conjunction with -s/--suite-name;\n' 'if not specified, use all compilers defined for this suite and machine\n' ) parser.add_argument( '--account', help='Account number to use for job submission.\n' 'This is needed on some machines; if not provided explicitly,\n' 'the script will attempt to guess it using the same rules as in CIME.\n' 'Default for this machine: {}'.format(default_machine.account)) parser.add_argument( '--testid-base', help='Base string used for the test id.\n' 'Default is to auto-generate this with a date and time stamp.') parser.add_argument('--testroot-base', help='Path in which testroot should be put.\n' 'For supported machines, this can be left out;\n' 'for non-supported machines, it must be provided.\n' 'Default for this machine: {}'.format( default_machine.scratch_dir)) parser.add_argument( '--baseline-root', help='Path in which baselines should be compared and generated.\n' 'Default is to use the default for this machine.') parser.add_argument( '--walltime', help='Walltime for each test.\n' 'If running a test suite, you can generally leave this unset,\n' 'because it is set in the file defining the test suite.\n' 'For other uses, providing this helps decrease the time spent\n' 'waiting in the queue.') parser.add_argument('--queue', help='Queue to which tests are submitted.\n' 'If not provided, uses machine default.') parser.add_argument( '--extra-create-test-args', default='', help='String giving extra arguments to pass to create_test\n' '(To allow the argument parsing to accept this, enclose the string\n' 'in quotes, with a leading space, as in " --my-arg foo".)') parser.add_argument( '--job-launcher-queue', help='Queue to which the create_test command is submitted.\n' 'Only applies on machines for which we submit the create_test command\n' 'rather than running it on the login node.\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_queue())) parser.add_argument( '--job-launcher-walltime', help='Walltime for the create_test command.\n' 'Only applies on machines for which we submit the create_test command\n' 'rather than running it on the login node.\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_walltime())) parser.add_argument( '--job-launcher-extra-args', help='Extra arguments for the command that launches the\n' 'create_test command.\n' '(To allow the argument parsing to accept this, enclose the string\n' 'in quotes, with a leading space, as in " --my-arg foo".)\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_extra_args())) parser.add_argument( '--skip-testroot-creation', action='store_true', help='Do not create the directory that will hold the tests.\n' 'This should be used if the desired testroot directory already exists.' ) parser.add_argument( '--dry-run', action='store_true', help='Print what would happen, but do not run any commands.\n' '(Generally should be run with --verbose.)\n') parser.add_argument('--machine-name', default=machine_name, help='Name of machine for which create_test is run.\n' 'This typically is not needed, but can be provided\n' 'for the sake of testing this script.\n' 'Defaults to current machine: {}'.format(machine_name)) add_logging_args(parser) args = parser.parse_args() _check_arg_validity(args) return args
def _commandline_args(): """Parse and return command-line arguments """ description = """ Driver for running CTSM system tests Typical usage: ./run_sys_tests -s aux_clm -c COMPARE_NAME -g GENERATE_NAME This automatically detects the machine and launches the appropriate components of the aux_clm test suite on that machine. This script also implements other aspects of the typical CTSM system testing workflow, such as running create_test via qsub on cheyenne, and setting up a directory to hold all of the tests in the test suite. A symbolic link will be created in the current directory pointing to the testroot directory containing all of the test directories in the test suite. Note that the -c/--compare and -g/--generate arguments are required, unless you specify --skip-compare and/or --skip-generate. Any other test suite can be given as well: clm_short, aux_glc, etc. This can also be used to run tests listed in a text file (via the -f/--testfile argument), or tests listed individually on the command line (via the -t/--testname argument). """ parser = argparse.ArgumentParser( description=description, formatter_class=argparse.RawTextHelpFormatter) machine_name = get_machine_name() default_machine = create_machine(machine_name, defaults=MACHINE_DEFAULTS, allow_missing_entries=True) tests_to_run = parser.add_mutually_exclusive_group(required=True) tests_to_run.add_argument('-s', '--suite-name', help='Name of test suite to run') tests_to_run.add_argument('-f', '--testfile', help='Path to file listing tests to run') tests_to_run.add_argument( '-t', '--testname', '--testnames', nargs='+', help='One or more test names to run (space-delimited)') compare = parser.add_mutually_exclusive_group(required=True) compare.add_argument('-c', '--compare', metavar='COMPARE_NAME', help='Baseline name (often tag) to compare against\n' '(required unless --skip-compare is given)') compare.add_argument('--skip-compare', action='store_true', help='Do not compare against baselines') generate = parser.add_mutually_exclusive_group(required=True) generate.add_argument('-g', '--generate', metavar='GENERATE_NAME', help='Baseline name (often tag) to generate\n' '(required unless --skip-generate is given)') generate.add_argument('--skip-generate', action='store_true', help='Do not generate baselines') parser.add_argument( '--suite-compiler', '--suite-compilers', nargs='+', help='Compiler(s) from the given test suite for which tests are run\n' 'Only valid in conjunction with -s/--suite-name;\n' 'if not specified, use all compilers defined for this suite and machine\n' ) parser.add_argument( '--account', help='Account number to use for job submission.\n' 'This is needed on some machines; if not provided explicitly,\n' 'the script will attempt to guess it using the same rules as in CIME.\n' 'Default for this machine: {}'.format(default_machine.account)) parser.add_argument( '--testid-base', help='Base string used for the test id.\n' 'Default is to auto-generate this with a date and time stamp.') parser.add_argument('--testroot-base', help='Path in which testroot should be put.\n' 'For supported machines, this can be left out;\n' 'for non-supported machines, it must be provided.\n' 'Default for this machine: {}'.format( default_machine.scratch_dir)) parser.add_argument( '--rerun-existing-failures', action='store_true', help='Rerun failed tests from the last PEND or FAIL state.\n' 'This triggers the --use-existing option to create_test.\n' 'To use this option, provide the same options to run_sys_tests\n' 'as in the initial run, but also adding --testid-base\n' 'corresponding to the base testid used initially.\n' '(However, many of the arguments to create_test are ignored,\n' 'so it is not important for all of the options to exactly match\n' 'those in the initial run.)\n' 'This option implies --skip-testroot-creation (that option does not\n' 'need to be specified separately if using --rerun-existing-failures).') if default_machine.baseline_dir: baseline_root_default_msg = 'Default for this machine: {}'.format( default_machine.baseline_dir) else: baseline_root_default_msg = "Default for this machine: use cime's default" parser.add_argument( '--baseline-root', help='Path in which baselines should be compared and generated.\n' + baseline_root_default_msg) parser.add_argument( '--walltime', help='Walltime for each test.\n' 'If running a test suite, you can generally leave this unset,\n' 'because it is set in the file defining the test suite.\n' 'For other uses, providing this helps decrease the time spent\n' 'waiting in the queue.') parser.add_argument( '--queue', help='Queue to which tests are submitted.\n' 'The special value "{}" means do not add a --queue option to create_test,\n' 'instead allowing CIME to pick an appropriate queue for each test\n' 'using its standard mechanisms.\n' 'Default for this machine: {}'.format( CREATE_TEST_QUEUE_UNSPECIFIED, default_machine.create_test_queue)) parser.add_argument( '--retry', type=int, help='Argument to create_test: Number of times to retry failed tests.\n' 'Default for this machine: {}'.format( default_machine.create_test_retry)) parser.add_argument( '--extra-create-test-args', default='', help='String giving extra arguments to pass to create_test\n' '(To allow the argument parsing to accept this, enclose the string\n' 'in quotes, with a leading space, as in " --my-arg foo".)') parser.add_argument( '--job-launcher-nobatch', action='store_true', help='Run create_test on the login node, even if this machine\n' 'is set up to submit create_test to a compute node by default.') parser.add_argument( '--job-launcher-queue', help='Queue to which the create_test command is submitted.\n' 'Only applies on machines for which we submit the create_test command\n' 'rather than running it on the login node.\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_queue())) parser.add_argument( '--job-launcher-walltime', help='Walltime for the create_test command.\n' 'Only applies on machines for which we submit the create_test command\n' 'rather than running it on the login node.\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_walltime())) parser.add_argument( '--job-launcher-extra-args', help='Extra arguments for the command that launches the\n' 'create_test command.\n' '(To allow the argument parsing to accept this, enclose the string\n' 'in quotes, with a leading space, as in " --my-arg foo".)\n' 'Default for this machine: {}'.format( default_machine.job_launcher.get_extra_args())) parser.add_argument( '--skip-testroot-creation', action='store_true', help='Do not create the directory that will hold the tests.\n' 'This should be used if the desired testroot directory already exists.' ) parser.add_argument( '--skip-git-status', action='store_true', help='Skip printing git and manage_externals status,\n' 'both to screen and to the SRCROOT_GIT_STATUS file in TESTROOT.\n' 'This printing can often be helpful, but this option can be used to\n' 'avoid extraneous output, to reduce the time needed to run this script,\n' 'or if git or manage_externals are currently broken in your sandbox.\n' ) parser.add_argument( '--dry-run', action='store_true', help='Print what would happen, but do not run any commands.\n' '(Generally should be run with --verbose.)\n') parser.add_argument('--machine-name', default=machine_name, help='Name of machine for which create_test is run.\n' 'This typically is not needed, but can be provided\n' 'for the sake of testing this script.\n' 'Defaults to current machine: {}'.format(machine_name)) add_logging_args(parser) args = parser.parse_args() _check_arg_validity(args) return args