Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.62 KB

k4run-args.md

File metadata and controls

49 lines (36 loc) · 1.62 KB

Adding custom arguments to k4run

It is possible to extend k4run with custom arguments from a steering file using k4FWCore.parseArgs.

Example:

from k4FWCore.parseArgs import parser
parser.add_argument("--trackingOnly", action="store_true", help="Run only track reconstruction", default=False)
my_opts = parser.parse_known_args()[0]

# later
if my_opts.trackingOnly:
    # only run track reconstruction

The example steering file can then be executed as follows:

k4run example_steering_file.py --trackingOnly --some-other-args

Behind the scenes parser is just a normal instance of python's argparse.ArgumentParser, please refer to its documentation for usage details. Use parse_known_args() instead of parse_args() so that the normal k4run arguments keep working. The [0] is necessary because the added arguments will be in the first element of the tuple returned from parse_known_args.