Skip to content

Commit

Permalink
Add deprecation warnings for CLI for kedro jupyter convert, `kedro …
Browse files Browse the repository at this point in the history
…build-docs`, `kedro build-reqs` and `kedro activate-nbstripout` (#1745)

* Add deprecation warnings

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Small refactoring to have consistent `click.secho` call

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Fix unittest failing with deprecation message

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Fix broken documentation link

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* Fixing a lot of breaking docslinkcheck due to missing stable build

Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>

* revert invalid links change
  • Loading branch information
noklam authored Aug 2, 2022
1 parent 49764da commit 5906440
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
9 changes: 8 additions & 1 deletion kedro/framework/cli/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,15 @@ def convert_notebook(
*Note*: Make sure your notebooks have unique names!
FILEPATH: Path(s) to exact notebook file(s) to be converted. Both
relative and absolute paths are accepted.
Should not be provided if --all flag is already present.
Should not be provided if --all flag is already present. (DEPRECATED)
"""

deprecation_message = (
"DeprecationWarning: Command 'kedro jupyter convert' is deprecated and "
"will not be available from Kedro 0.19.0."
)
click.secho(deprecation_message, fg="red")

project_path = metadata.project_path
source_path = metadata.source_dir
package_name = metadata.package_name
Expand Down
28 changes: 21 additions & 7 deletions kedro/framework/cli/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pathlib import Path

import click
from click import secho

from kedro.framework.cli.utils import (
KedroCliError,
Expand Down Expand Up @@ -171,10 +170,14 @@ def package(metadata: ProjectMetadata):
)
@click.pass_obj # this will pass the metadata as first argument
def build_docs(metadata: ProjectMetadata, open_docs):
"""Build the project documentation."""
"""Build the project documentation. (DEPRECATED)"""
source_path = metadata.source_dir
package_name = metadata.package_name

deprecation_message = (
"DeprecationWarning: Command 'kedro build-docs' is deprecated and "
"will not be available from Kedro 0.19.0."
)
click.secho(deprecation_message, fg="red")
python_call("pip", ["install", str(source_path / "[docs]")])
python_call("pip", ["install", "-r", str(source_path / "requirements.txt")])
python_call("ipykernel", ["install", "--user", f"--name={package_name}"])
Expand All @@ -191,7 +194,7 @@ def build_docs(metadata: ProjectMetadata, open_docs):
call(["sphinx-build", "-M", "html", "docs/source", "docs/build", "-a"])
if open_docs:
docs_page = (Path.cwd() / "docs" / "build" / "html" / "index.html").as_uri()
secho(f"Opening {docs_page}")
click.secho(f"Opening {docs_page}")
webbrowser.open(docs_page)


Expand All @@ -215,7 +218,13 @@ def build_reqs(
): # pylint: disable=unused-argument
"""Run `pip-compile` on src/requirements.txt or the user defined input file and save
the compiled requirements to src/requirements.lock or the user defined output file.
(DEPRECATED)
"""
deprecation_message = (
"DeprecationWarning: Command 'kedro build-reqs' is deprecated and "
"will not be available from Kedro 0.19.0."
)
click.secho(deprecation_message, fg="red")

source_path = metadata.source_dir
input_file = Path(input_file or source_path / "requirements.txt")
Expand All @@ -239,7 +248,7 @@ def build_reqs(
"Please specify another input or create the file and try again."
)

secho(
click.secho(
f"Requirements built! Please update {input_file.name} "
"if you'd like to make a change in your project's dependencies, "
f"and re-run build-reqs to generate the new {output_file.name}.",
Expand All @@ -252,9 +261,14 @@ def build_reqs(
def activate_nbstripout(
metadata: ProjectMetadata, **kwargs
): # pylint: disable=unused-argument
"""Install the nbstripout git hook to automatically clean notebooks."""
"""Install the nbstripout git hook to automatically clean notebooks. (DEPRECATED)"""
source_path = metadata.source_dir
secho(
deprecation_message = (
"DeprecationWarning: Command 'kedro activate-nbstripout' is deprecated and "
"will not be available from Kedro 0.19.0."
)
click.secho(deprecation_message, fg="red")
click.secho(
(
"Notebook output cells will be automatically cleared before committing"
" to git."
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/cli/test_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_convert_without_filepath_and_all_flag(
"add '--all' to convert all notebooks.\n"
)
assert result.exit_code
assert result.stdout == expected_output
assert expected_output in result.stdout

def test_non_unique_notebook_names_error(
self, fake_project_cli, mocker, fake_metadata
Expand Down

0 comments on commit 5906440

Please sign in to comment.