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

Use click features for project creation prompts #4387

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
66 changes: 63 additions & 3 deletions kedro/framework/cli/starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,43 @@
and out with "no".
"""

NAME_PROMPT = """
Project Name
============
Please enter a name for your new project.
Spaces, hyphens, and underscores are allowed.
To skip this step in future use --name
"""

TOOLS_PROMPT = """
Project Tools
=============
These optional tools can help you apply software engineering best practices.
To skip this step in future use --tools
To find out more: https://docs.kedro.org/en/stable/starters/new_project_tools.html

Tools
1) Lint: Basic linting with Ruff
2) Test: Basic testing with pytest
3) Log: Additional, environment-specific logging options
4) Docs: A Sphinx documentation setup
5) Data Folder: A folder structure for data management
6) PySpark: Configuration for working with PySpark
7) Kedro-Viz: Kedro's native visualisation tool

Which tools would you like to include in your project? [1-7/1,3/all/none]:
"""

EXAMPLE_PROMPT = """
Example Pipeline
================
Select whether you would like an example spaceflights pipeline included in your project.
To skip this step in the future use --example=y/n
To find out more: https://docs.kedro.org/en/stable/starters/new_project_tools.html

Would you like to include an example pipeline? :
"""


@define(order=True)
class KedroStarterSpec:
Expand Down Expand Up @@ -303,9 +340,24 @@ def starter() -> None:
@click.option("--starter", "-s", "starter_alias", help=STARTER_ARG_HELP)
@click.option("--checkout", help=CHECKOUT_ARG_HELP)
@click.option("--directory", help=DIRECTORY_ARG_HELP)
@click.option("--tools", "-t", "selected_tools", help=TOOLS_ARG_HELP)
@click.option("--name", "-n", "project_name", help=NAME_ARG_HELP)
@click.option("--example", "-e", "example_pipeline", help=EXAMPLE_ARG_HELP)
@click.option(
"--name",
"-n",
"project_name",
help=NAME_ARG_HELP,
)
@click.option(
"--tools",
"-t",
"selected_tools",
help=TOOLS_ARG_HELP,
)
@click.option(
"--example",
"-e",
"example_pipeline",
help=EXAMPLE_ARG_HELP,
)
@click.option("--telemetry", "-tc", "telemetry_consent", help=TELEMETRY_ARG_HELP)
def new( # noqa: PLR0913
config_path: str,
Expand All @@ -332,6 +384,14 @@ def new( # noqa: PLR0913
_validate_flag_inputs(flag_inputs)
starters_dict = _get_starters_dict()

if not starter_alias:
if not project_name:
project_name = click.prompt(NAME_PROMPT, default="New Kedro Project")
if not selected_tools:
selected_tools = click.prompt(TOOLS_PROMPT, default="none")
if not example_pipeline:
example_pipeline = click.prompt(EXAMPLE_PROMPT, default="no")

if starter_alias in starters_dict:
if directory:
raise KedroCliError(
Expand Down
Loading