diff --git a/DaVinciSys/scripts/davinci b/DaVinciSys/scripts/davinci index e873787323e26fc814a9d70c238586291aa31ad8..d0b26478e7304586336081110c4ab6a4f57550e2 100755 --- a/DaVinciSys/scripts/davinci +++ b/DaVinciSys/scripts/davinci @@ -12,6 +12,7 @@ """ This script is meant to implement the Python Click functionality when running a DaVinci (Gaudi) application. + Two possible functions have been developed to automatically handle the differences between jobs using data or simulated input files. @@ -42,23 +43,26 @@ else: "--export", default=None, help= - "export the options in a format suitable for gaudirun.py. Filename has to be provided as argument.", + "Export the options in a format suitable for gaudirun.py.\nFilename has to be provided, with extension .opts.\nTypically used in conjunction with --dry-run.", ) @click.option( "--with-defaults", is_flag=True, default=False, help= - "explicitly include default values of properties in the final configuration", + "Explicitly include default values of properties in the final configuration.", ) @click.option( "--dry-run", is_flag=True, default=False, - help="just process the options but do not run the application", + help="Process the options but do not run the application.", ) @click.version_option(version=APP_VERSION) def main(export, with_defaults, dry_run): + """ + Try `davinci COMMAND --help` for information on COMMAND options available. + """ assert not export or export.endswith( ".opts"), "--export argument must have '.opts' extension" @@ -66,8 +70,8 @@ def main(export, with_defaults, dry_run): @main.resultcallback() def run_job(configurables, export=None, with_defaults=False, dry_run=None): """ - This function is not invoked directly in Davinci but it is used to override the - default click 'result_callback' function by means of the 'resultcallback' decorator. + This function is not invoked directly by davinci but it is used to override the + default Click 'result_callback' function by means of the 'resultcallback' decorator. The 'result_callback' method is invoked automatically when returning the values of the main subcommnads: run_mc and run_data. """ @@ -121,6 +125,12 @@ def run_job(configurables, export=None, with_defaults=False, dry_run=None): exit(app.run()) +inputfiledb_helper = "TestFileDB-like file containing job input and conditions information (.yaml). Takes the pair of values 'filedb-key', 'filedb-path'."\ + "If you want to use the standard TestFileDB set 'filedb-path' = '-'." +joboptfile_helper = "Option file containing the job information (.yaml, .py)" +simplejob_helper = "Option for running a simple DaVinci job without any specific configuration (.py)." + + @main.command( context_settings=dict( ignore_unknown_options=True, @@ -130,31 +140,21 @@ def run_job(configurables, export=None, with_defaults=False, dry_run=None): "--inputfiledb", default=("", "TestFileDB"), nargs=2, - help= - "TestFileDB-like file containing job input and conditions information (.yaml). Takes the pair of values 'filedb-key', 'filedb-path'."\ - "If you want to use the standard TestFileDB set 'filedb-path' = '-'." -) -@click.option( - "--joboptfile", - default="", - help="Option file containing the job information (.yaml, .py)") + help=inputfiledb_helper) +@click.option("--joboptfile", default="", help=joboptfile_helper) @click.option( - "--simplejob", - is_flag=True, - default=False, - help= - "Option for running a simple DaVinci jobs without any specific configuration (.py)." -) + "--simplejob", is_flag=True, default=False, help=simplejob_helper) @click.pass_context def run_mc(ctx, inputfiledb, joboptfile, simplejob): """ DaVinci function for running jobs on simulated samples. + Ctx: click.core.Context class (dict). - Predefined click object storing information about the invoked command. - All the options passed by command line which are not recognised by click are stored into the ctx.args element. + Predefined Click object storing information about the invoked command. + All options passed via the command line which are not recognised by Click are stored into the ctx.args element. Ctx.args is a simple array and each extra option is stored using two values: the first one is the key and the second one is the corresponding value. - Eg: --evt_max 100 will be stored as: ctx.args[0] = --evt_max, ctx.args[1] = 100 + Ex.: --evt_max 100 will be stored as: ctx.args[0] = --evt_max, ctx.args[1] = 100 Note: Click automatically converts "_" in "-", so this function can be invoked calling run-mc as shown in the help. @@ -188,36 +188,33 @@ def run_mc(ctx, inputfiledb, joboptfile, simplejob): "--inputfiledb", default=("", "TestFileDB"), nargs=2, - help= - "TestFileDB-like file containing job input and conditions information (.yaml). Takes the pair of values 'filedb-key', 'filedb-path'."\ - "If you want to use the standard TestFileDB set 'filedb-path' = '-'." -) + help=inputfiledb_helper) +@click.option("--joboptfile", default="", help=joboptfile_helper) @click.option( - "--joboption-file", - default="", - help="Option file containing the job information (.yaml, .py)") + "--simplejob", is_flag=True, default=False, help=simplejob_helper) @click.pass_context -def run_data(ctx, inputfiledb, optfile): +def run_data(ctx, inputfiledb, joboptfile, simplejob): """ - DaVinci function for running jobs on real data samples. - Ctx: click.core.Context class (dict). Predefined click object storing information about the invoked command. - All options passed by the command line that are not recognised by click are stored into the ctx.args element. + DaVinci function for running jobs on detector data samples. + + Ctx: click.core.Context class (dict). + Predefined Click object storing information about the invoked command. + All options passed via the command line that are not recognised by Click are stored into the ctx.args element. Ctx.args is a simple array and each extra option is stored using two values: the first one is the key and the second one is the corresponding value. - Eg: --evt_max 100 will be stored as: ctx.args[0] = --evt_max, ctx.args[1] = 100 + Ex.: --evt_max 100 will be stored as: ctx.args[0] = --evt_max, ctx.args[1] = 100 Note: - Click automatically converts "_" in "-", so this function can be invoked calling run-data as shown in the help. + Click automatically converts "_" in "-", so this function can be invoked calling run-data as shown in the help. """ raise ValueError( 'Data file with upgrade conditions are not yet available. Please use :mc function instead.' ) - # Run on data sample + # Run on a data sample options.simulation = False - - # Test file DB key request overrides inputfiledb + # TestFileDB key request overrides inputfiledb inputfiledb_key, inputfiledb_file = set_testfiledb(inputfiledb) ctx_args = (ctx.args if (len(ctx.args) > 1) else []) diff --git a/Phys/DaVinci/python/DaVinci/utilities_script.py b/Phys/DaVinci/python/DaVinci/utilities_script.py index 33d69cf6ccd9c2eb6b5e39762a8de6768c68062d..612581ffd8191988905a7abb6cd37a957778c92f 100644 --- a/Phys/DaVinci/python/DaVinci/utilities_script.py +++ b/Phys/DaVinci/python/DaVinci/utilities_script.py @@ -28,10 +28,10 @@ def dump_call(testfiledb_file, testfiledb_key, joboptfile, ctx_args): indentStr = "# " click.echo("%sDaVinci: running using the following arguments:" % indentStr) click.echo( - "%s - testfiledb-file: %s" % (indentStr, testfiledb_file)) + "%s - TestFileDB file: %s" % (indentStr, testfiledb_file)) click.echo( - "%s - testfiledb-key: %s" % (indentStr, testfiledb_key)) - click.echo("%s - joboption-file: %s" % (indentStr, joboptfile)) + "%s - TestFileDB key: %s" % (indentStr, testfiledb_key)) + click.echo("%s - joboptfile: %s" % (indentStr, joboptfile)) if len(ctx_args) > 1: for i in range(0, len(ctx_args), 2): @@ -85,14 +85,14 @@ def get_configurable_opts(configurables, with_defaults): def set_testfiledb(inputfiledb): """ - Set the testfileDB file and the related key to be used in the DV job. + Set the TestFileDB file and the related key to be used in the job. Args: - - testfiledb: pair of values containing information on the testfileDB and the key chosen by the user. + inputfiledb: pair of values containing information on the TestFileDB and the key chosen by the user. Returns: - - key for the testfileDB. - - file containing the testfileDB. + - key for the TestFileDB. + - file containing the TestFileDB. """ assert len( inputfiledb