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

Make kedro-telemetry a core dependency #3976

Merged
merged 14 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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 RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Updated error message for catalog entries when the dataset class is not found with hints on how to resolve the issue.
* Fixed a bug in the `DataCatalog` `shallow_copy()` method to ensure it returns the type of the used catalog and doesn't cast it to `DataCatalog`.
* Implemented key completion support for accessing datasets in the `DataCatalog`.

* Made [kedro-telemetry](https://github.com/kedro-org/kedro-plugins/tree/main/kedro-telemetry) a core dependency.

## Breaking changes to the API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ notebook
kedro~={{ cookiecutter.kedro_version}}
kedro-datasets[pandas-csvdataset]; python_version >= "3.9"
kedro-datasets[pandas.CSVDataset]<2.0.0; python_version < '3.9'
kedro-telemetry>=0.3.1
pytest-cov~=3.0
pytest-mock>=1.7.1, <2.0
pytest~=7.2
2 changes: 1 addition & 1 deletion kedro/framework/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def info() -> None:
click.echo(
f"{plugin_name}: {plugin_version} (entry points:{entrypoints_str})"
)
else:
else: # pragma: no cover
click.echo("No plugins installed")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ ipython>=8.10
jupyterlab>=3.0
notebook
kedro~={{ cookiecutter.kedro_version }}
kedro-telemetry>=0.3.1
pytest-cov~=3.0
pytest-mock>=1.7.1, <2.0
pytest~=7.2
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies = [
"gitpython>=3.0",
"importlib-metadata>=3.6,<9.0",
"importlib_resources>=1.3,<7.0", # The `files()` API was introduced in `importlib_resources` 1.3 and Python 3.9.
"kedro-telemetry>=0.5.0",
"more_itertools>=8.14.0",
"omegaconf>=2.1.1",
"parse>=1.19.0",
Expand Down
7 changes: 5 additions & 2 deletions tests/framework/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ def test_info_contains_plugin_versions(self, entry_point):

entry_point.load.assert_not_called()

def test_info_no_plugins(self):
def test_info_only_kedro_telemetry_plugin_installed(self):
result = CliRunner().invoke(cli, ["info"])
assert result.exit_code == 0
assert "No plugins installed" in result.output

split_result = result.output.strip().split("\n")
assert "Installed plugins" in split_result[-2]
assert "kedro_telemetry" in split_result[-1]

def test_help(self):
"""Check that `kedro --help` returns a valid help message."""
Expand Down
20 changes: 19 additions & 1 deletion tests/framework/session/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ def test_create(

expected_store["username"] = fake_username

mocker.patch(
"kedro_telemetry.plugin._check_for_telemetry_consent",
return_value=False,
)

assert session.store == expected_store
assert session.load_context() is mock_context_class.return_value
assert isinstance(session._get_config_loader(), OmegaConfigLoader)
Expand Down Expand Up @@ -362,6 +367,11 @@ def test_create_no_env_extra_params(

expected_store["username"] = fake_username

mocker.patch(
"kedro_telemetry.plugin._check_for_telemetry_consent",
return_value=False,
)

assert session.store == expected_store
assert session.load_context() is mock_context_class.return_value
assert isinstance(session._get_config_loader(), OmegaConfigLoader)
Expand Down Expand Up @@ -754,12 +764,16 @@ def test_run_multiple_times(
)

@pytest.mark.usefixtures("mock_settings_context_class")
def test_run_non_existent_pipeline(self, fake_project, mock_runner):
def test_run_non_existent_pipeline(self, fake_project, mock_runner, mocker):
pattern = (
"Failed to find the pipeline named 'doesnotexist'. "
"It needs to be generated and returned "
"by the 'register_pipelines' function."
)
mocker.patch(
"kedro_telemetry.plugin._check_for_telemetry_consent",
return_value=False,
)
with pytest.raises(ValueError, match=re.escape(pattern)):
with KedroSession.create(fake_project) as session:
session.run(runner=mock_runner, pipeline_name="doesnotexist")
Expand Down Expand Up @@ -922,6 +936,10 @@ def test_session_raise_error_with_invalid_runner_instance(
},
)
mock_runner_class = mocker.patch("kedro.runner.SequentialRunner")
mocker.patch(
"kedro_telemetry.plugin._check_for_telemetry_consent",
return_value=False,
)

session = KedroSession.create(fake_project)
with pytest.raises(
Expand Down