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

Rename addons to tools #3357

Merged
merged 19 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
2 changes: 1 addition & 1 deletion features/steps/cli_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def create_config_file(context):
context.root_project_dir = context.temp_dir / context.project_name
context.package_name = context.project_name.replace("-", "_")
config = {
"add_ons": "1-5",
"tools": "1-5",
"project_name": context.project_name,
"example_pipeline": "no",
"repo_name": context.project_name,
Expand Down
2 changes: 1 addition & 1 deletion features/steps/test_starter/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"repo_name": "{{ cookiecutter.project_name.replace(' ', '-').lower().strip('-') }}",
"python_package": "{{ cookiecutter.project_name.replace(' ', '_').replace('-', '_').lower() }}",
"kedro_version": "{{ cookiecutter.kedro_version }}",
"add_ons": "none"
"tools": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespaces = false
package_name = "{{ cookiecutter.python_package }}"
project_name = "{{ cookiecutter.project_name }}"
kedro_init_version = "{{ cookiecutter.kedro_version }}"
add_ons = "{{ cookiecutter.add_ons | default('') | string | replace('\"', '\\\"') }}"
tools = "{{ cookiecutter.tools | default('') | string | replace('\"', '\\\"') }}"

[tool.pytest.ini_options]
addopts = """
Expand Down
182 changes: 91 additions & 91 deletions kedro/framework/cli/starters.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions kedro/framework/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ProjectMetadata(NamedTuple):
project_path: Path
source_dir: Path
kedro_init_version: str
add_ons: list
tools: list


def _version_mismatch_error(kedro_init_version) -> str:
Expand Down Expand Up @@ -102,7 +102,7 @@ def _get_project_metadata(project_path: Union[str, Path]) -> ProjectMetadata:
# Default settings
source_dir = Path(metadata_dict.get("source_dir", "src")).expanduser()
source_dir = (project_path / source_dir).resolve()
metadata_dict["add_ons"] = metadata_dict.get("add_ons")
metadata_dict["tools"] = metadata_dict.get("tools")

metadata_dict["source_dir"] = source_dir
metadata_dict["config_file"] = pyproject_toml
Expand Down
2 changes: 1 addition & 1 deletion kedro/templates/project/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"repo_name": "{{ cookiecutter.project_name.strip().replace(' ', '-').replace('_', '-').lower() }}",
"python_package": "{{ cookiecutter.project_name.strip().replace(' ', '_').replace('-', '_').lower() }}",
"kedro_version": "{{ cookiecutter.kedro_version }}",
"add_ons": "none",
"tools": "none",
"example_pipeline": "no"
}
10 changes: 5 additions & 5 deletions kedro/templates/project/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from kedro.templates.project.hooks.utils import (

setup_template_add_ons,
setup_template_tools,
sort_requirements,
)

Expand All @@ -13,12 +13,12 @@ def main():
pyproject_file_path = current_dir / "pyproject.toml"
python_package_name = '{{ cookiecutter.python_package }}'

# Get the selected add-ons from cookiecutter
selected_add_ons = "{{ cookiecutter.add_ons }}"
# Get the selected tools from cookiecutter
selected_tools = "{{ cookiecutter.tools }}"
example_pipeline = "{{ cookiecutter.example_pipeline }}"

# Handle template directories and requirements according to selected add-ons
setup_template_add_ons(selected_add_ons, requirements_file_path, pyproject_file_path, python_package_name, example_pipeline)
# Handle template directories and requirements according to selected tools
setup_template_tools(selected_tools, requirements_file_path, pyproject_file_path, python_package_name, example_pipeline)

# Sort requirements.txt file in alphabetical order
sort_requirements(requirements_file_path)
Expand Down
20 changes: 10 additions & 10 deletions kedro/templates/project/hooks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,37 +141,37 @@ def _remove_pyspark_viz_starter_files(is_viz: bool, python_package_name: str) ->
_remove_file(test_pipeline_path)


def setup_template_add_ons(selected_add_ons_list: str, requirements_file_path: str, pyproject_file_path: str, python_package_name: str, example_pipeline: str) -> None:
"""Setup the templates according to the choice of add-ons.
def setup_template_tools(selected_tools_list: str, requirements_file_path: str, pyproject_file_path: str, python_package_name: str, example_pipeline: str) -> None:
"""Setup the templates according to the choice of tools.

Args:
selected_add_ons_list (str): A string contains the selected add-ons.
selected_tools_list (str): A string contains the selected tools.
requirements_file_path (str): The path of the `requiremenets.txt` in the template.
pyproject_file_path (str): The path of the `pyproject.toml` in the template
python_package_name (str): The name of the python package.
example_pipeline (str): 'True' if example pipeline was selected
"""
if "Linting" not in selected_add_ons_list:
if "Linting" not in selected_tools_list:
_remove_from_file(requirements_file_path, lint_requirements)
_remove_from_toml(pyproject_file_path, lint_pyproject_requirements)

if "Testing" not in selected_add_ons_list:
if "Testing" not in selected_tools_list:
_remove_from_file(requirements_file_path, test_requirements)
_remove_from_toml(pyproject_file_path, test_pyproject_requirements)
_remove_dir(current_dir / "tests")

if "Logging" not in selected_add_ons_list:
if "Logging" not in selected_tools_list:
_remove_file(current_dir / "conf/logging.yml")

if "Documentation" not in selected_add_ons_list:
if "Documentation" not in selected_tools_list:
_remove_from_toml(pyproject_file_path, docs_pyproject_requirements)
_remove_dir(current_dir / "docs")

if "Data Structure" not in selected_add_ons_list and example_pipeline != "True":
if "Data Structure" not in selected_tools_list and example_pipeline != "True":
_remove_dir(current_dir / "data")

if ("Pyspark" in selected_add_ons_list or "Kedro Viz" in selected_add_ons_list) and example_pipeline != "True":
_remove_pyspark_viz_starter_files("Kedro Viz" in selected_add_ons_list, python_package_name)
if ("Pyspark" in selected_tools_list or "Kedro Viz" in selected_tools_list) and example_pipeline != "True":
_remove_pyspark_viz_starter_files("Kedro Viz" in selected_tools_list, python_package_name)


def sort_requirements(requirements_file_path: Path) -> None:
Expand Down
10 changes: 5 additions & 5 deletions kedro/templates/project/prompts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ project_name:
It must contain only alphanumeric symbols, spaces, underscores and hyphens and
be at least 2 characters long.

add_ons:
title: "Project Add-Ons"
tools:
title: "Project Tools"
text: |
These optional tools can help you apply software engineering best practices.
To skip this step in future use --add-ons
To skip this step in future use --tools
To find out more: kedro.org/ # TODO - add docs link in #3048

Add-Ons
AhdraMeraliQB marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -25,10 +25,10 @@ add_ons:
6) PySpark: Configuration for working with PySpark
7) Kedro-Viz: Kedro's native visualisation tool

Which add-ons would you like to include in your project? [1-7/1,3/all/none]:
Which tools would you like to include in your project? [1-7/1,3/all/none]:
regex_validator: "^(all|none|(( )*\\d*(,\\d*)*(,( )*\\d*)*( )*|( )*((\\d+-\\d+)|(\\d+ - \\d+))( )*))$"
error_message: |
Invalid input. Please select valid options for add-ons using comma-separated values, ranges, or 'all/none'.
Invalid input. Please select valid options for project tools using comma-separated values, ranges, or 'all/none'.

example_pipeline:
title: "Example Pipeline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespaces = false
package_name = "{{ cookiecutter.python_package }}"
project_name = "{{ cookiecutter.project_name }}"
kedro_init_version = "{{ cookiecutter.kedro_version }}"
add_ons = "{{ cookiecutter.add_ons | default('') | string | replace('\"', '\\\"') }}"
tools = "{{ cookiecutter.tools | default('') | string | replace('\"', '\\\"') }}"

[tool.pytest.ini_options]
addopts = """
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def fake_metadata(fake_root_dir):
project_path=fake_root_dir / REPO_NAME,
kedro_init_version=kedro_version,
source_dir=fake_root_dir / REPO_NAME / "src",
add_ons=None,
tools=None,
)
return metadata

Expand Down
Loading
Loading