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

Draft - path traversal #3577

Closed
wants to merge 5 commits into from
Closed
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
9 changes: 9 additions & 0 deletions docs/source/notebooks_and_ipython/kedro_and_notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@

For more details, run `%reload_kedro?`.

#### Line magic function `%reload_kedro` not found.
If you start your Jupyter instance with `kedro jupyter notebook/lab/setup` command, this command should be available whenever you start a notebook with the Kedro kernel.

To fix this, you just need to start your notebook with one of the `kedro jupyter` command. Alternatively, you can always include an extra line at the top of your notebook

Check warning on line 215 in docs/source/notebooks_and_ipython/kedro_and_notebooks.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/notebooks_and_ipython/kedro_and_notebooks.md#L215

[Kedro.words] Use '' instead of 'just'.
Raw output
{"message": "[Kedro.words] Use '' instead of 'just'.", "location": {"path": "docs/source/notebooks_and_ipython/kedro_and_notebooks.md", "range": {"start": {"line": 215, "column": 18}}}, "severity": "WARNING"}

Check warning on line 215 in docs/source/notebooks_and_ipython/kedro_and_notebooks.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/notebooks_and_ipython/kedro_and_notebooks.md#L215

[Kedro.toowordy] 'Alternatively' is too wordy
Raw output
{"message": "[Kedro.toowordy] 'Alternatively' is too wordy", "location": {"path": "docs/source/notebooks_and_ipython/kedro_and_notebooks.md", "range": {"start": {"line": 215, "column": 92}}}, "severity": "WARNING"}

Check warning on line 215 in docs/source/notebooks_and_ipython/kedro_and_notebooks.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/source/notebooks_and_ipython/kedro_and_notebooks.md#L215

[Kedro.weaselwords] 'Alternatively' is a weasel word!
Raw output
{"message": "[Kedro.weaselwords] 'Alternatively' is a weasel word!", "location": {"path": "docs/source/notebooks_and_ipython/kedro_and_notebooks.md", "range": {"start": {"line": 215, "column": 92}}}, "severity": "WARNING"}
`%load_ext kedro.ipython`, this get run automatically if your kernel is set up properly.

After running this command, you should see `%reload_kedro` and `%load_node` are available to use.


## How to use tags to convert functions from Jupyter notebooks into Kedro nodes

You can use the notebook to write experimental code for your Kedro project. If you later want to convert functions you've written to Kedro nodes, you can do this using `node` tags to export them to a Python file. Say you have the following code in your notebook:
Expand Down
20 changes: 15 additions & 5 deletions kedro/framework/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,20 @@ class _ProjectLogging(UserDict):
def __init__(self) -> None:
"""Initialise project logging. The path to logging configuration is given in
environment variable KEDRO_LOGGING_CONFIG (defaults to default_logging.yml)."""
path = os.environ.get(
"KEDRO_LOGGING_CONFIG", Path(__file__).parent / "default_logging.yml"
)
logging_config = Path(path).read_text(encoding="utf-8")
path = os.environ.get("KEDRO_LOGGING_CONFIG")

if not path:
sanitized_path = Path(__file__).parent / "default_logging.yml"
else:
# Validate Path

sanitized_path = os.path.normpath(path)

sanitized_path = Path(sanitized_path=os.path.normpath(path))

with open(sanitized_path, encoding="utf-8") as f:
logging_config = f.read()
# logging_config = sanitized_path.read_text(encoding="utf-8")
self.configure(yaml.safe_load(logging_config))

def configure(self, logging_config: dict[str, Any]) -> None:
Expand All @@ -241,9 +251,9 @@ def set_project_logging(self, package_name: str) -> None:


PACKAGE_NAME = None
settings = _ProjectSettings()
LOGGING = _ProjectLogging()

settings = _ProjectSettings()

pipelines = _ProjectPipelines()

Expand Down
Loading