Repository: kedro-org/kedro
Pull request: Allow `kedro new` with config file without tools or example
> **NOTE:** Kedro datasets are moving from `kedro.extras.datasets` to a separate `kedro-datasets` package in
> [`kedro-plugins` repository](https://github.com/kedro-org/kedro-plugins). Any changes to the dataset implementations
> should be done by opening a pull request in that repository.
## Description
<!-- Why was this PR created? -->
Fix #3342 

## Development notes
<!-- What have you changed, and how has this been tested? -->
- Only fail if `project_name` is not in `config.yml`
- Display a message saying default value is being used for "missing keys" i.e. either tools or example_pipeline
- Added a test

## Developer Certificate of Origin
We need all contributions to comply with the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). All commits must be signed off by including a `Signed-off-by` line in the commit message. [See our wiki for guidance](https://github.com/kedro-org/kedro/wiki/Guidelines-for-contributing-developers/).

If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.

## Checklist

- [ ] Read the [contributing](https://github.com/kedro-org/kedro/blob/main/CONTRIBUTING.md) guidelines
- [ ] Signed off each commit with a [Developer Certificate of Origin (DCO)](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-the-commit-signoff-policy-for-your-repository)
- [ ] Opened this PR as a 'Draft Pull Request' if it is work-in-progress
- [ ] Updated the documentation to reflect the code changes
- [ ] Added a description of this change in the [`RELEASE.md`](https://github.com/kedro-org/kedro/blob/main/RELEASE.md) file
- [ ] Added tests to cover my changes
- [ ] Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team


Problem statement:
Make it possible to create project from config without providing `add_ons` or `example_pipeline`
## Description
Creating a project from config without providing `add_ons` or `example_pipeline` fails.

## Context
`config.yml`:

```yaml
project_name: My First Kedro Project
repo_name: testing-kedro
python_package: test_kedro
```
By itself, this doesn't work - throws the following error:
```
kedro.framework.cli.utils.KedroCliError: example_pipeline, add_ons not found in config file.
Run with --verbose to see the full exception
```
I would assume these would use the default values if not provided.

## Expected behaviour
The above config yaml is valid and so project creation should succeed.

Hints from issue discussion:

Commit message: Update config validation

Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>

Patch to review:
diff --git a/kedro/framework/cli/starters.py b/kedro/framework/cli/starters.py
index f0de8f51eb..0881a9c08d 100644
--- a/kedro/framework/cli/starters.py
+++ b/kedro/framework/cli/starters.py
@@ -704,9 +704,22 @@ def _validate_config_file_against_prompts(
     if config is None:
         raise KedroCliError("Config file is empty.")
     missing_keys = set(prompts) - set(config)
-    if missing_keys:
+    missing_mandatory_keys = missing_keys - {"tools", "example_pipeline"}
+    if missing_mandatory_keys:
         click.echo(yaml.dump(config, default_flow_style=False))
-        raise KedroCliError(f"{', '.join(missing_keys)} not found in config file.")
+        raise KedroCliError(
+            f"{', '.join(missing_mandatory_keys)} not found in config file."
+        )
+    if "example_pipeline" in missing_keys:
+        click.secho(
+            "The `example_pipeline` key not found in the config file, default value 'no' is being used.",
+            fg="yellow",
+        )
+    if "tools" in missing_keys:
+        click.secho(
+            "The `tools` key not found in the config file, default value 'none' is being used.",
+            fg="yellow",
+        )
 
     if "output_dir" in config and not Path(config["output_dir"]).exists():
         raise KedroCliError(
diff --git a/tests/framework/cli/test_starters.py b/tests/framework/cli/test_starters.py
index faff14607b..c57f1da505 100644
--- a/tests/framework/cli/test_starters.py
+++ b/tests/framework/cli/test_starters.py
@@ -630,6 +630,20 @@ def test_empty_prompts(self, fake_kedro_cli):
         _assert_template_ok(result, **config)
         _clean_up_project(Path("./my-project"))
 
+    def test_config_with_no_tools_example(self, fake_kedro_cli):
+        """Test project created from config."""
+        config = {
+            "project_name": "My Project",
+            "repo_name": "my-project",
+            "python_package": "my_project",
+        }
+        _write_yaml(Path("config.yml"), config)
+        result = CliRunner().invoke(
+            fake_kedro_cli, ["new", "-v", "--config", "config.yml"]
+        )
+        _assert_template_ok(result, **config)
+        _clean_up_project(Path("./my-project"))
+
 
 @pytest.mark.usefixtures("chdir_to_tmp")
 class TestNewFromConfigFileInvalid:


Code review comments:
diff_hunk: @@ -704,9 +704,22 @@ def _validate_config_file_against_prompts(
     if config is None:
         raise KedroCliError("Config file is empty.")
     missing_keys = set(prompts) - set(config)
-    if missing_keys:
+    missing_mandatory_keys = missing_keys - {"tools", "example_pipeline"}
+    if missing_mandatory_keys:
         click.echo(yaml.dump(config, default_flow_style=False))
-        raise KedroCliError(f"{', '.join(missing_keys)} not found in config file.")
+        raise KedroCliError(
+            f"{', '.join(missing_mandatory_keys)} not found in config file."
+        )
+    if "example_pipeline" in missing_keys:
+        click.secho(
+            "The `example_pipeline` key not found in the config file, default value 'no' is being used.",
+            fg="yellow",
+        )
+    if "tools" in missing_keys:
+        click.secho(
path: kedro/framework/cli/starters.py
text: @user1:
Thanks, @author , for updating the missing_mandatory_keys! 
Sorry to bother you, but I noticed some code repetition concerning 'example_pipeline' and 'tools'. Perhaps we could streamline this by storing these in a dictionary with their default values. This way, we can consolidate the echo command to a single instance.