class documentation

class KedroSession: (source)

View In Hierarchy

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_context An instance of the project context.
Method run Runs the pipeline with a specified runner.
Instance Variable save_on_close Undocumented
Instance Variable session_id Undocumented
Property store Return a copy of internal store.
Method _get_config_loader An instance of the config loader.
Method _get_logging_config Undocumented
Method _init_store Undocumented
Method _log_exception Undocumented
Method _setup_logging Register logging specified in logging directory.
Instance Variable _conf_source Undocumented
Instance Variable _hook_manager Undocumented
Instance Variable _package_name Undocumented
Instance Variable _project_path Undocumented
Instance Variable _run_called Undocumented
Instance Variable _store Undocumented
Property _logger Undocumented
@classmethod
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
package_name:strPackage name for the Kedro project the session is created for. The package_name argument will be removed in Kedro 0.19.0.
project_path:Union[Path, str]Path to the project root directory. Default is current working directory Path.cwd().
save_on_close:boolWhether or not to save the session when it's closed.
env:strEnvironment for the KedroContext.
extra_params:Dict[str, Any]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.
conf_source:Optional[str]Path to a directory containing configuration
Returns
KedroSessionA new KedroSession instance.
def __enter__(self): (source)

Undocumented

def __exit__(self, exc_type, exc_value, tb_): (source)

Undocumented

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 close(self): (source)

Close the current session and save its store to disk if save_on_close attribute is True.

def load_context(self) -> KedroContext: (source)

An instance of the project context.

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
pipeline_name:strName of the pipeline that is being run.
tags:Iterable[str]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:AbstractRunnerAn optional parameter specifying the runner that you want to run the pipeline with.
node_names:Iterable[str]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.
from_nodes:Iterable[str]An optional list of node names which should be used as a starting point of the new Pipeline.
to_nodes:Iterable[str]An optional list of node names which should be used as an end point of the new Pipeline.
from_inputs:Iterable[str]An optional list of input datasets which should be used as a starting point of the new Pipeline.
to_outputs:Iterable[str]An optional list of output datasets which should be used as an end point of the new Pipeline.
load_versions:Dict[str, str]An optional flag to specify a particular dataset version timestamp to load.
namespace:strThe namespace of the nodes that is being run.
Returns
Dict[str, Any]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
ValueErrorIf the named or __default__ pipeline is not defined by register_pipelines.
ExceptionAny uncaught exception during the run will be re-raised after being passed to on_pipeline_error hook.
KedroSessionErrorIf more than one run is attempted to be executed during a single session.
save_on_close = (source)

Undocumented

session_id = (source)

Undocumented

@property
store: Dict[str, Any] = (source)

Return a copy of internal store.

def _get_config_loader(self) -> ConfigLoader: (source)

An instance of the config loader.

def _get_logging_config(self) -> Dict[str, Any]: (source)

Undocumented

def _init_store(self) -> BaseSessionStore: (source)

Undocumented

def _log_exception(self, exc_type, exc_value, exc_tb): (source)

Undocumented

def _setup_logging(self): (source)

Register logging specified in logging directory.

_conf_source = (source)

Undocumented

_hook_manager = (source)

Undocumented

_package_name = (source)

Undocumented

_project_path = (source)

Undocumented

_run_called: bool = (source)

Undocumented

Undocumented