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

Update kedro catalog create to use new /conf structure #2884

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 1 addition & 2 deletions kedro/framework/cli/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def create_catalog(metadata: ProjectMetadata, pipeline_name, env):
context.project_path
/ settings.CONF_SOURCE
/ env
/ "catalog"
/ f"{pipeline_name}.yml"
/ f"catalog_{pipeline_name}.yml"
)
_add_missing_datasets_to_catalog(missing_ds, catalog_path)
click.echo(f"Data Catalog YAML configuration was created: {catalog_path}")
Expand Down
19 changes: 8 additions & 11 deletions tests/framework/cli/test_catalog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import shutil

import pytest
import yaml
from click.testing import CliRunner
Expand Down Expand Up @@ -242,11 +240,12 @@ class TestCatalogCreateCommand:
@staticmethod
@pytest.fixture(params=["base"])
def catalog_path(request, fake_repo_path):
catalog_path = fake_repo_path / "conf" / request.param / "catalog"
catalog_path = fake_repo_path / "conf" / request.param

yield catalog_path

shutil.rmtree(catalog_path, ignore_errors=True)
for file in catalog_path.glob("catalog_*"):
file.unlink()

def test_pipeline_argument_is_required(self, fake_project_cli):
result = CliRunner().invoke(fake_project_cli, ["catalog", "create"])
Expand Down Expand Up @@ -278,7 +277,7 @@ def test_catalog_is_created_in_base_by_default(
main_catalog_config = yaml.safe_load(main_catalog_path.read_text())
assert "example_iris_data" in main_catalog_config

data_catalog_file = catalog_path / f"{self.PIPELINE_NAME}.yml"
data_catalog_file = catalog_path / f"catalog_{self.PIPELINE_NAME}.yml"

result = CliRunner().invoke(
fake_project_cli,
Expand All @@ -302,9 +301,9 @@ def test_catalog_is_created_in_base_by_default(
def test_catalog_is_created_in_correct_env(
self, fake_project_cli, fake_metadata, catalog_path
):
data_catalog_file = catalog_path / f"{self.PIPELINE_NAME}.yml"
data_catalog_file = catalog_path / f"catalog_{self.PIPELINE_NAME}.yml"

env = catalog_path.parent.name
env = catalog_path.name
result = CliRunner().invoke(
fake_project_cli,
["catalog", "create", "--pipeline", self.PIPELINE_NAME, "--env", env],
Expand Down Expand Up @@ -335,7 +334,7 @@ def test_no_missing_datasets(
)

data_catalog_file = (
fake_repo_path / "conf" / "base" / "catalog" / f"{self.PIPELINE_NAME}.yml"
fake_repo_path / "conf" / "base" / f"catalog_{self.PIPELINE_NAME}.yml"
)

result = CliRunner().invoke(
Expand All @@ -351,9 +350,7 @@ def test_no_missing_datasets(
def test_missing_datasets_appended(
self, fake_project_cli, fake_metadata, catalog_path
):
data_catalog_file = catalog_path / f"{self.PIPELINE_NAME}.yml"
assert not catalog_path.exists()
catalog_path.mkdir()
data_catalog_file = catalog_path / f"catalog_{self.PIPELINE_NAME}.yml"

catalog_config = {
"example_test_x": {"type": "pandas.CSVDataSet", "filepath": "test.csv"}
Expand Down