Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warning to package_name argument in session create() #1953

Merged
merged 5 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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