From e38febeadef10f4380688af65b5be77ecdab8a85 Mon Sep 17 00:00:00 2001 From: Sajid Alam <90610031+SajidAlamQB@users.noreply.github.com> Date: Wed, 22 Sep 2021 13:55:43 +0100 Subject: [PATCH] [KED-2572] Config file should still be passed to cookiecutter even when prompts.yml doesn't exist (#1245) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * no prompt, send no config * Update kedro/framework/cli/starters.py Co-authored-by: Lorena Bălan * Update kedro/framework/cli/starters.py Co-authored-by: Lorena Bălan * Updated starter.py and RELEASE.md * Added in removed config validation Accidently removed _validate_config_file * Update RELEASE.md Co-authored-by: Lorena Bălan * Moved bugfix in RELEASE.md Moved to correct position. Co-authored-by: Lorena Bălan --- RELEASE.md | 1 + kedro/framework/cli/starters.py | 3 ++- tests/framework/cli/test_starters.py | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 616ba97219..f7e737f8fe 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -3,6 +3,7 @@ ## Major features and improvements ## Bug fixes and other changes +* Fixed an issue where `kedro new --config config.yml` was ignoring the config file when `prompts.yml` didn't exist. ## Minor breaking changes to the API diff --git a/kedro/framework/cli/starters.py b/kedro/framework/cli/starters.py index 4d1c3fc804..fe39a5357c 100644 --- a/kedro/framework/cli/starters.py +++ b/kedro/framework/cli/starters.py @@ -153,6 +153,8 @@ def new( # Obtain config, either from a file or from interactive user prompts. if not prompts_required: config = {} + if config_path: + config = _fetch_config_from_file(config_path) elif config_path: config = _fetch_config_from_file(config_path) _validate_config_file(config, prompts_required) @@ -436,7 +438,6 @@ def _validate_config_file(config: Dict[str, str], prompts: Dict[str, Any]): """ if config is None: raise KedroCliError("Config file is empty.") - missing_keys = set(prompts) - set(config) if missing_keys: click.echo(yaml.dump(config, default_flow_style=False)) diff --git a/tests/framework/cli/test_starters.py b/tests/framework/cli/test_starters.py index 64aa57115c..0399dbdfed 100644 --- a/tests/framework/cli/test_starters.py +++ b/tests/framework/cli/test_starters.py @@ -328,7 +328,7 @@ def test_no_prompts(self, fake_kedro_cli): result = CliRunner().invoke( fake_kedro_cli, ["new", "--starter", "template", "--config", "config.yml"] ) - _assert_template_ok(result) + _assert_template_ok(result, **config) def test_empty_prompts(self, fake_kedro_cli): config = { @@ -342,7 +342,7 @@ def test_empty_prompts(self, fake_kedro_cli): result = CliRunner().invoke( fake_kedro_cli, ["new", "--starter", "template", "--config", "config.yml"] ) - _assert_template_ok(result) + _assert_template_ok(result, **config) @pytest.mark.usefixtures("chdir_to_tmp")