causallift.context package
Submodules
causallift.context.base_context module
This module provides context for Kedro project.
- class causallift.context.base_context.BaseKedroContext[source]
Bases:
ABC
KedroContext
is 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.Example:
from kedro.context import KedroContext from kedro.pipeline import Pipeline class ProjectContext(KedroContext): @property def pipeline(self) -> Pipeline: return Pipeline([])
- property catalog
Read-only property referring to Kedro’s
DataCatalog
for this context.- Return type:
DataCatalog
- Returns:
DataCatalog defined in catalog.yml.
- property io
Read-only alias property referring to Kedro’s
DataCatalog
for this context.- Return type:
DataCatalog
- Returns:
DataCatalog defined in catalog.yml.
- abstract property pipeline
Abstract property for Pipeline getter.
- Return type:
Pipeline
- Returns:
Defined pipeline.
- run(tags=None, runner=None, node_names=None, from_nodes=None, to_nodes=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
.
- Raises:
KedroContextError – If the resulting
Pipeline
is 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.
causallift.context.flexible_context module
Application entry point.
- class causallift.context.flexible_context.FlexibleKedroContext(runner=None, only_missing=False, **kwargs)[source]
Bases:
ProjectContext2
Overwrite the default runner and only_missing option for the run.
- run(tags=None, runner=None, node_names=None, only_missing=False)[source]
Runs the pipeline wi th 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.only_missing (
bool
) – An option to run only missing nodes.
- Raises:
KedroContextError – If the resulting
Pipeline
is 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.
- class causallift.context.flexible_context.ProjectContext[source]
Bases:
BaseKedroContext
Users can override the remaining methods from the parent class here, or create new ones (e.g. as required by plugins)
- property pipeline
Abstract property for Pipeline getter.
- Return type:
Pipeline
- Returns:
Defined pipeline.
- project_name = 'CausalLift'
- project_version = '0.15.0'
- run(tags=None, runner=None, node_names=None, only_missing=False)[source]
Runs the pipeline wi th 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.only_missing (
bool
) – An option to run only missing nodes.
- Raises:
KedroContextError – If the resulting
Pipeline
is 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.
- class causallift.context.flexible_context.ProjectContext1[source]
Bases:
ProjectContext
Allow to specify runner by string.
- run(runner=None, **kwargs)[source]
Runs the pipeline wi th a specified runner.
- Parameters:
tags – An optional list of node tags which should be used to filter the nodes of the
Pipeline
. If specified, only the nodes containing any of these tags will be run.runner (
Union
[AbstractRunner
,str
,None
]) – An optional parameter specifying the runner that you want to run the pipeline with.node_names – An optional list of node names which should be used to filter the nodes of the
Pipeline
. If specified, only the nodes with these names will be run.only_missing – An option to run only missing nodes.
- Raises:
KedroContextError – If the resulting
Pipeline
is 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.
- class causallift.context.flexible_context.ProjectContext2[source]
Bases:
ProjectContext1
Keep the output datasets in the catalog.
- run(**kwargs)[source]
Runs the pipeline wi th a specified runner.
- Parameters:
tags – An optional list of node tags which should be used to filter the nodes of the
Pipeline
. If specified, only the nodes containing any of these tags will be run.runner – An optional parameter specifying the runner that you want to run the pipeline with.
node_names – An optional list of node names which should be used to filter the nodes of the
Pipeline
. If specified, only the nodes with these names will be run.only_missing – An option to run only missing nodes.
- Raises:
KedroContextError – If the resulting
Pipeline
is 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.