kedro.context.KedroContext¶
-
class
kedro.context.KedroContext(project_path, env=None)[source]¶ Bases:
abc.ABCKedroContextis the base class which holds the configuration and Kedro’s main functionality. Project-specific context class should extend this abstract class and implement the all abstract methods.-
CONF_ROOT¶ Name of root directory containing project configuration.
-
Default name is "conf".
Example:
from kedro.context import KedroContext from kedro.pipeline import Pipeline class ProjectContext(KedroContext): @property def pipeline(self) -> Pipeline: return Pipeline([])
Attributes
KedroContext.CONF_ROOTKedroContext.catalogRead-only property referring to Kedro’s DataCatalogfor this context.KedroContext.config_loaderRead-only property referring to Kedro’s ConfigLoaderfor this context.KedroContext.ioRead-only alias property referring to Kedro’s DataCatalogfor this context.KedroContext.paramsRead-only property referring to Kedro’s parameters for this context. KedroContext.pipelineRead-only property for an instance of Pipeline. KedroContext.pipelinesRead-only property for an instance of Pipeline. KedroContext.project_nameAbstract property for Kedro project name. KedroContext.project_pathRead-only property containing Kedro’s root project directory. KedroContext.project_versionAbstract property for Kedro version. Methods
KedroContext.__init__(project_path[, env])Create a context object by providing the root of a Kedro project and the environment configuration subfolders (see kedro.config.ConfigLoader)KedroContext.run([tags, runner, node_names, …])Runs the pipeline with a specified runner. -
CONF_ROOT= 'conf'
-
__init__(project_path, env=None)[source]¶ Create a context object by providing the root of a Kedro project and the environment configuration subfolders (see
kedro.config.ConfigLoader)Raises: KedroContextError– If there is a mismatch between Kedro project version and package version.Parameters: - project_path (
Union[Path,str]) – Project path to define the context for. - env (
Optional[str]) – Optional argument for configuration default environment to be used for running the pipeline. If not specified, it defaults to “local”.
- project_path (
-
catalog¶ Read-only property referring to Kedro’s
DataCatalogfor this context.Return type: DataCatalogReturns: DataCatalog defined in catalog.yml.
-
config_loader¶ Read-only property referring to Kedro’s
ConfigLoaderfor this context.Return type: ConfigLoaderReturns: Instance of ConfigLoader.
-
io¶ Read-only alias property referring to Kedro’s
DataCatalogfor this context.Return type: DataCatalogReturns: DataCatalog defined in catalog.yml.
-
params¶ Read-only property referring to Kedro’s parameters for this context.
Return type: Dict[str,Any]Returns: Parameters defined in parameters.yml.
-
pipeline¶ Read-only property for an instance of Pipeline.
Return type: PipelineReturns: Defined pipeline.
-
pipelines¶ Read-only property for an instance of Pipeline.
Return type: Dict[str,Pipeline]Returns: A dictionary of defined pipelines.
-
project_name¶ Abstract property for Kedro project name.
Return type: strReturns: Name of Kedro project.
-
project_path¶ Read-only property containing Kedro’s root project directory.
Return type: PathReturns: Project directory.
-
project_version¶ Abstract property for Kedro version.
Return type: strReturns: Kedro version.
-
run(tags=None, runner=None, node_names=None, from_nodes=None, to_nodes=None, from_inputs=None, load_versions=None, pipeline_name=None)[source]¶ Runs the pipeline with a specified runner.
Parameters: - tags (
Optional[Iterable[str]]) – An optional list of node tags which should be used to filter the nodes of thePipeline. If specified, only the nodes containing any of these tags will be run. - runner (
Optional[AbstractRunner]) – An optional parameter specifying the runner that you want to run the pipeline with. - node_names (
Optional[Iterable[str]]) – An optional list of node names which should be used to filter the nodes of thePipeline. If specified, only the nodes with these names will be run. - from_nodes (
Optional[Iterable[str]]) – An optional list of node names which should be used as a starting point of the newPipeline. - to_nodes (
Optional[Iterable[str]]) – An optional list of node names which should be used as an end point of the newPipeline. - from_inputs (
Optional[Iterable[str]]) – An optional list of input datasets which should be used as a starting point of the newPipeline. - load_versions (
Optional[Dict[str,str]]) – An optional flag to specify a particular dataset version timestamp to load. - pipeline_name (
Optional[str]) – Name of thePipelineto execute. Defaults to “__default__”.
Raises: KedroContextError– If the resultingPipelineis empty or incorrect tags are provided.Return type: Dict[str,Any]Returns: Any node outputs that cannot be processed by the
DataCatalog. These are returned in a dictionary, where the keys are defined by the node outputs.- tags (
-