Component¶
-
class
ctapipe.core.
Component
(**kwargs: Any)[source]¶ Bases:
traitlets.config.configurable.Configurable
Base class of all Components.
Components are classes that are configurable via traitlets and setup a logger in the ctapipe logging hierarchy.
traitlets
can validate values and provide defaults and descriptions. These will be automatically translated into configuration parameters (command-line, config file, etc). Note that any parameter that should be externally configurable must have itsconfig
attribute set toTrue
, e.g. defined likemyparam = Integer(0, help='the parameter').tag(config=True)
.All components also contain a
Logger
instance in theirlog
attribute, that you must use to output info, debugging data, warnings, etc (do not useprint()
statements, instead useself.log.info()
,self.log.warning()
,self.log.debug()
, etc).Components are generally used within
ctapipe.core.Tool
subclasses, which provide configuration handling and command-line tool generation.For example:
from ctapipe.core import Component from traitlets import (Integer, Float) class MyComponent(Component): """ Does something """ some_option = Integer(default_value=6, help='a value to set').tag(config=True) comp = MyComponent() comp.some_option = 6 # ok comp.some_option = 'test' # will fail validation
Methods Summary
from_name
(name[, config, parent])Obtain an instance of a subclass via its name
return the current configuration as a dict (e.g.
get dict{name: cls} of non abstract subclasses, subclasses can possibly be definded in plugins
Methods Documentation
-
classmethod
from_name
(name, config=None, parent=None, **kwargs)[source]¶ Obtain an instance of a subclass via its name
- Parameters
- namestr
Name of the subclass to obtain
- configtraitlets.loader.Config
Configuration specified by config file or cmdline arguments. Used to set traitlet values. This argument is typically only specified when using this method from within a Tool.
- parentctapipe.core.Tool
Tool executable that is calling this component. Passes the correct logger and configuration to the component. This argument is typically only specified when using this method from within a Tool (config need not be passed if parent is used).
- kwargs
- Returns
- instace
Instance of subclass to this class
-
classmethod