lsst.pipe.base  13.0-11-gdf6a56c+11
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Static Public Attributes | List of all members
lsst.pipe.base.argumentParser.ArgumentParser Class Reference

An argument parser for pipeline tasks that is based on argparse.ArgumentParser. More...

Inheritance diagram for lsst.pipe.base.argumentParser.ArgumentParser:
lsst.pipe.base.argumentParser.InputOnlyArgumentParser

Public Member Functions

def __init__
 Construct an ArgumentParser. More...
 
def add_id_argument
 Add a data ID argument. More...
 
def parse_args
 Parse arguments for a pipeline task. More...
 
def handleCamera
 Perform camera-specific operations before parsing the command line. More...
 
def convert_arg_line_to_args
 Allow files of arguments referenced by @<path> to contain multiple values on each line. More...
 

Static Public Attributes

 requireOutput = True
 

Detailed Description

An argument parser for pipeline tasks that is based on argparse.ArgumentParser.

Users may wish to add additional arguments before calling parse_args.

Note
  • I would prefer to check data ID keys and values as they are parsed, but the required information comes from the butler, so I have to construct a butler before I do this checking. Constructing a butler is slow, so I only want do it once, after parsing the command line, so as to catch syntax errors quickly.

Definition at line 290 of file argumentParser.py.

Constructor & Destructor Documentation

def lsst.pipe.base.argumentParser.ArgumentParser.__init__ (   self,
  name,
  usage = "%(prog)s input [options]",
  kwargs 
)

Construct an ArgumentParser.

Parameters
[in]namename of top-level task; used to identify camera-specific override files
[in]usageusage string
[in]**kwargsadditional keyword arguments for argparse.ArgumentParser

Definition at line 303 of file argumentParser.py.

Member Function Documentation

def lsst.pipe.base.argumentParser.ArgumentParser.add_id_argument (   self,
  name,
  datasetType,
  help,
  level = None,
  doMakeDataRefList = True,
  ContainerClass = DataIdContainer 
)

Add a data ID argument.

Add an argument to specify data IDs. If datasetType is an instance of DatasetArgument, then add a second argument to specify the dataset type.

Parameters
[in]namedata ID argument (including leading dashes, if wanted)
[in]datasetTypetype of dataset; supply a string for a fixed dataset type, or a DynamicDatasetType, such as DatasetArgument, for a dynamically determined dataset type
[in]helphelp string for the argument
[in]levellevel of dataset, for butler
[in]doMakeDataRefListconstruct data references?
[in]ContainerClassdata ID container class to use to contain results; override the default if you need a special means of computing data references from data IDs

The associated data is put into namespace.<dataIdArgument.name> as an instance of ContainerClass; the container includes fields:

  • idList: a list of data ID dicts
  • refList: a list of butler data references (empty if doMakeDataRefList false)

Definition at line 381 of file argumentParser.py.

def lsst.pipe.base.argumentParser.ArgumentParser.convert_arg_line_to_args (   self,
  arg_line 
)

Allow files of arguments referenced by @<path> to contain multiple values on each line.

Parameters
[in]arg_lineline of text read from an argument file

Definition at line 667 of file argumentParser.py.

def lsst.pipe.base.argumentParser.ArgumentParser.handleCamera (   self,
  namespace 
)

Perform camera-specific operations before parsing the command line.

The default implementation does nothing.

Parameters
[in,out]namespacenamespace (an argparse.Namespace) with the following fields:
  • camera: the camera name
  • config: the config passed to parse_args, with no overrides applied
  • obsPkg: the obs_ package for this camera
  • log: a lsst.log Log

Definition at line 654 of file argumentParser.py.

def lsst.pipe.base.argumentParser.ArgumentParser.parse_args (   self,
  config,
  args = None,
  log = None,
  override = None 
)

Parse arguments for a pipeline task.

Parameters
[in,out]configconfig for the task being run
[in]argsargument list; if None use sys.argv[1:]
[in]loglog (instance lsst.log Log); if None use the default log
[in]overridea config override function; it must take the root config object as its only argument and must modify the config in place. This function is called after camera-specific overrides files are applied, and before command-line config overrides are applied (thus allowing the user the final word).
Returns
namespace: an argparse.Namespace containing many useful fields including:
  • camera: camera name
  • config: the supplied config with all overrides applied, validated and frozen
  • butler: a butler for the data
  • an entry for each of the data ID arguments registered by add_id_argument(), the value of which is a DataIdArgument that includes public elements 'idList' and 'refList'
  • log: a lsst.log Log
  • an entry for each command-line argument, with the following exceptions:
    • config is the supplied config, suitably updated
    • configfile, id and loglevel are all missing
  • obsPkg: name of obs_ package for this camera

Definition at line 424 of file argumentParser.py.

Member Data Documentation

lsst.pipe.base.argumentParser.ArgumentParser.requireOutput = True
static

Definition at line 301 of file argumentParser.py.


The documentation for this class was generated from the following file: