class documentation
class KedroSession: (source)
KedroSession is the object that is responsible for managing the lifecycle
of a Kedro run. Use KedroSession.create()
as
a context manager to construct a new KedroSession with session data
provided (see the example below).
Example:
>>> from kedro.framework.session import KedroSession >>> from kedro.framework.startup import bootstrap_project >>> from pathlib import Path >>> # If you are creating a session outside of a Kedro project (i.e. not using >>> # `kedro run` or `kedro jupyter`), you need to run `bootstrap_project` to >>> # let Kedro find your configuration. >>> bootstrap_project(Path("<project_root>")) >>> with KedroSession.create() as session: >>> session.run()
Class Method | create |
Create a new instance of KedroSession with the session data. |
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | close |
Close the current session and save its store to disk if save_on_close attribute is True. |
Method | load |
An instance of the project context. |
Method | run |
Runs the pipeline with a specified runner. |
Instance Variable | save |
Undocumented |
Instance Variable | session |
Undocumented |
Property | store |
Return a copy of internal store. |
Method | _get |
An instance of the config loader. |
Method | _get |
Undocumented |
Method | _init |
Undocumented |
Method | _log |
Undocumented |
Method | _setup |
Register logging specified in logging directory. |
Instance Variable | _conf |
Undocumented |
Instance Variable | _hook |
Undocumented |
Instance Variable | _package |
Undocumented |
Instance Variable | _project |
Undocumented |
Instance Variable | _run |
Undocumented |
Instance Variable | _store |
Undocumented |
Property | _logger |
Undocumented |
@classmethod
def create(cls, package_name:
def create(cls, package_name:
str
= None, project_path: Union[ Path, str]
= None, save_on_close: bool
= True, env: str
= None, extra_params: Dict[ str, Any]
= None, conf_source: Optional[ str]
= None) -> KedroSession
:
(source)
¶
Create a new instance of KedroSession with the session data.
Parameters | |
packagestr | Package name for the Kedro project the session is
created for. The package_name argument will be removed in Kedro 0.19.0 . |
projectUnion[ | Path to the project root directory. Default is current working directory Path.cwd(). |
savebool | Whether or not to save the session when it's closed. |
env:str | Environment for the KedroContext. |
extraDict[ | Optional dictionary containing extra project parameters for underlying KedroContext. If specified, will update (and therefore take precedence over) the parameters retrieved from the project configuration. |
confOptional[ | Path to a directory containing configuration |
Returns | |
KedroSession | A new KedroSession instance. |
def __init__(self, session_id:
str
, package_name: str
= None, project_path: Union[ Path, str]
= None, save_on_close: bool
= False, conf_source: Optional[ str]
= None):
(source)
¶
Undocumented
def run(self, pipeline_name:
str
= None, tags: Iterable[ str]
= None, runner: AbstractRunner
= None, node_names: Iterable[ str]
= None, from_nodes: Iterable[ str]
= None, to_nodes: Iterable[ str]
= None, from_inputs: Iterable[ str]
= None, to_outputs: Iterable[ str]
= None, load_versions: Dict[ str, str]
= None, namespace: str
= None) -> Dict[ str, Any]
:
(source)
¶
Runs the pipeline with a specified runner.
Parameters | |
pipelinestr | Name of the pipeline that is being run. |
tags:Iterable[ | 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:AbstractRunner | An optional parameter specifying the runner that you want to run the pipeline with. |
nodeIterable[ | 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. |
fromIterable[ | An optional list of node names which should be used as a starting point of the new Pipeline. |
toIterable[ | An optional list of node names which should be used as an end point of the new Pipeline. |
fromIterable[ | An optional list of input datasets which should be used as a starting point of the new Pipeline. |
toIterable[ | An optional list of output datasets which should be used as an end point of the new Pipeline. |
loadDict[ | An optional flag to specify a particular dataset version timestamp to load. |
namespace:str | The namespace of the nodes that is being run. |
Returns | |
Dict[ | 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. |
Raises | |
ValueError | If the named or __default__ pipeline is not
defined by register_pipelines . |
Exception | Any uncaught exception during the run will be re-raised after being passed to on_pipeline_error hook. |
KedroSessionError | If more than one run is attempted to be executed during a single session. |