Skip to content

Commit

Permalink
Add deprecation warning to package_name argument in session create() (k…
Browse files Browse the repository at this point in the history
…edro-org#1953)

Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
  • Loading branch information
merelcht authored and amaralbf committed Oct 22, 2022
1 parent d239757 commit 3180de5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions docs/source/extend_kedro/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ from kedro.framework.session import KedroSession


project_path = Path.cwd()
metadata = _get_project_metadata(project_path)
session = KedroSession.create(metadata.package_name, project_path)
session = KedroSession.create(project_path=project_path)
context = session.load_context()
```

Expand Down
6 changes: 3 additions & 3 deletions docs/source/kedro_project_setup/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ from kedro.framework.session import KedroSession
from kedro.framework.startup import bootstrap_project
from pathlib import Path

metadata = bootstrap_project(Path.cwd())
with KedroSession.create(metadata.package_name) as session:
bootstrap_project(Path.cwd())
with KedroSession.create() as session:
session.run()
```

You must tell `KedroSession` the package name of your Kedro project so it can load your settings, nodes and pipelines. Additionally, you can provide the following optional arguments in `KedroSession.create()`:
You can provide the following optional arguments in `KedroSession.create()`:

- `project_path`: Path to the project root directory
- `save_on_close`: A boolean value to indicate whether or not to save the session to disk when it's closed
Expand Down
9 changes: 4 additions & 5 deletions kedro/framework/session/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class KedroSessionError(Exception):

class KedroSession:
"""``KedroSession`` is the object that is responsible for managing the lifecycle
of a Kedro run. Use `KedroSession.create("<package_name>")` as
of a Kedro run. Use `KedroSession.create()` as
a context manager to construct a new KedroSession with session data
provided (see the example below).
Expand All @@ -87,8 +87,8 @@ class KedroSession:
>>> # 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.
>>> metadata = bootstrap_project(Path("<project_root>"))
>>> with KedroSession.create(metadata.package_name) as session:
>>> bootstrap_project(Path("<project_root>"))
>>> with KedroSession.create() as session:
>>> session.run()
"""
Expand Down Expand Up @@ -125,7 +125,7 @@ def create( # pylint: disable=too-many-arguments
Args:
package_name: Package name for the Kedro project the session is
created for.
created for. The package_name argument will be removed in Kedro `0.19.0`.
project_path: Path to the project root directory. Default is
current working directory Path.cwd().
save_on_close: Whether or not to save the session when it's closed.
Expand All @@ -138,7 +138,6 @@ def create( # pylint: disable=too-many-arguments
Returns:
A new ``KedroSession`` instance.
"""

validate_settings()

session = cls(
Expand Down

0 comments on commit 3180de5

Please sign in to comment.