Skip to content

Commit

Permalink
[KED-2572] Config file should still be passed to cookiecutter even wh…
Browse files Browse the repository at this point in the history
…en prompts.yml doesn't exist (#1245)

* no prompt, send no config

* Update kedro/framework/cli/starters.py

Co-authored-by: Lorena Bălan <lorena.balan@quantumblack.com>

* Update kedro/framework/cli/starters.py

Co-authored-by: Lorena Bălan <lorena.balan@quantumblack.com>

* 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 <lorena.balan@quantumblack.com>

* Moved bugfix in RELEASE.md

Moved to correct position.

Co-authored-by: Lorena Bălan <lorena.balan@quantumblack.com>
  • Loading branch information
SajidAlamQB and Lorena Bălan committed Sep 22, 2021
1 parent 7582375 commit e38febe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion kedro/framework/cli/starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions tests/framework/cli/test_starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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")
Expand Down

0 comments on commit e38febe

Please sign in to comment.