kedro.framework.context.KedroContext

class kedro.framework.context.KedroContext(package_name, project_path, config_loader, hook_manager, env=None, extra_params=None)[source]

KedroContext is the base class which holds the configuration and Kedro’s main functionality.

Attributes

catalog

Read-only property referring to Kedro's DataCatalog for this context.

config_loader

Read-only property referring to Kedro's ConfigLoader for this context.

env

Property for the current Kedro environment.

params

Read-only property referring to Kedro's parameters for this context.

project_path

Read-only property containing Kedro's root project directory.

Methods

__init__(package_name, project_path, config_loader, hook_manager, env=None, extra_params=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:
  • package_name (str) – Package name for the Kedro project the context is created for.

  • project_path (Path | str) – Project path to define the context for.

  • hook_manager (PluginManager) – The PluginManager to activate hooks, supplied by the session.

  • env (str) – Optional argument for configuration default environment to be used for running the pipeline. If not specified, it defaults to “local”.

  • extra_params (dict[str, Any]) – Optional dictionary containing extra project parameters. If specified, will update (and therefore take precedence over) the parameters retrieved from the project configuration.

property catalog: DataCatalog

Read-only property referring to Kedro’s DataCatalog for this context.

Return type:

DataCatalog

Returns:

DataCatalog defined in catalog.yml.

Raises:

KedroContextError – Incorrect DataCatalog registered for the project.

property config_loader

Read-only property referring to Kedro’s ConfigLoader for this context. :returns: Instance of ConfigLoader.

Raises:

KedroContextError – Incorrect ConfigLoader registered for the project.

property env: str | None

Property for the current Kedro environment.

Return type:

str | None

Returns:

Name of the current Kedro environment.

property params: dict[str, Any]

Read-only property referring to Kedro’s parameters for this context.

Returns:

Parameters defined in parameters.yml with the addition of any

extra parameters passed at initialization.

property project_path: Path

Read-only property containing Kedro’s root project directory.

Return type:

Path

Returns:

Project directory.