Improvements to the configuration subsystem

For description of the current configuration subsystem see Developer's Survival Guide

The package location in CVS: python/Ganga/Utility/Config

Goals of improvements

  • Generate the .gangarc file on-the-fly (get rid of GANGA_CONFIG_TEMPLATE.ini)
  • Integrate better with online system and for printing reference guides, etc.
  • Make the GPI config object easier to use

Changes in the Ganga modules

Each configuration section must be declared using makeConfig() function. Each option has to be explicitly declared using addOption() method. All options should be declared at the top of the module.

 from Ganga.Utility.Config import getConfig, ConfigError
 c = makeConfig(name1,docstring,...)
 c.addOption(name2,value,docstring,...)
 ...

With makeConfig(name,doctring,is_open=False, cfile=True, hidden=False) you may specify additional information for the configuration section:

  • is_open : True users may add new options at runtime (e.g. logger)
  • cfile : True section will be written to the config file template (e.g. ganga -g option)
  • hidden : True section will not be visible in the GPI

The same keyword arguments may be used with addOption() method and additionally:

  • type : if not specified, then the type is inferred from the default value, type may be a type object such as type(1), StringType, type(None) or list
  • examples : examples of values (additional documentation)

There may be new keywords added in the future according to needs.

If you want to refer to the configuration section in another package you may do it like this:

c = getConfig(name)

There should be one point of declaration with makeConfig() and any number of places using it with getConfig(). The order does not matter.

The assignment c['x'] = v is not be supported. So the only way of setting a default value is via addOption().

It is a bad practice to depend on the existence of the option - use None to indicate that the option is not set. If option needs some default value you may also use c.getEffectiveLevel() method to see if the option was defined by the user in the configuration file. You should not override default values use c.setSessionValue() method. Look in the package - the interface is documented there.

An additional check will be provided to detect misspelled options in the config file: Ganga will complain if the option has not been declared in the core. The check will be disabled for "open" sections (such as Logging) for which the options may be added dynamically.

GPI Changes

Configuration sections and options are the attributes of the config object:

>>> config.Plugins.default_backends = 'LCG' (TAB expansion possible)

The GPI this syntax config["..."]["..."] should still at (least for a transition period) work to change a value.

Pretty-print the config object - by default only a summary is printed (the section names with the doc string).

TODO: A new syntax will be available at the command line: ganga -oPlugins.default_backends="LCG" (possible convenience improvement: quotes may be left out for a single word)

When Ganga starts up all options from the core and from the loaded runtime packages are available. TODO: The command ganga -g will generate the default config file for all the runtime packages which are loaded (so LHCb does not get ATLAS options).

Until -g option is enabled you may test the generation of the config file like this:

from Ganga.GPIDev.Lib.Config.Config import print_config_file
print_config_file()

-- JakubMoscicki - 11 Oct 2007

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2007-10-12 - UlrikEgede
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    ArdaGrid All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback