Skip to content

Commit

Permalink
Merge branch 'main' into 729-enable-telemetry-for-kedro-new-and-comma…
Browse files Browse the repository at this point in the history
…nds-outside-kedro-project-folder
  • Loading branch information
DimedS authored Jul 31, 2024
2 parents de3abe8 + f6b934c commit 63a0c91
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
2 changes: 2 additions & 0 deletions kedro-datasets/RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Upcoming Release
## Major features and improvements
* Improved PartitionedDataset representation when printing.

## Bug fixes and other changes
## Breaking Changes
## Community contributions
Expand Down
16 changes: 16 additions & 0 deletions kedro-datasets/kedro_datasets/partitions/partitioned_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ def _describe(self) -> dict[str, Any]:
"dataset_config": clean_dataset_config,
}

def __repr__(self) -> str:
object_description = self._describe()

# Dummy object to call _pretty_repr
# Only clean_dataset_config parameters are exposed
kwargs = deepcopy(self._dataset_config)
kwargs[self._filepath_arg] = ""
dataset = self._dataset_type(**kwargs) # type: ignore

object_description_repr = {
"filepath": object_description["path"],
"dataset": dataset._pretty_repr(object_description["dataset_config"]),
}

return self._pretty_repr(object_description_repr)

def _invalidate_caches(self) -> None:
self._partition_cache.clear()
self._filesystem.invalidate_cache(self._normalized_path)
Expand Down
9 changes: 9 additions & 0 deletions kedro-datasets/tests/partitions/test_partitioned_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ class FakeDataset: # pylint: disable=too-few-public-methods


class TestPartitionedDatasetLocal:
@pytest.mark.parametrize("dataset", ["pandas.ParquetDataset", ParquetDataset])
def test_repr(self, dataset):
pds = PartitionedDataset(path="", dataset=dataset)
assert (
repr(pds)
== """kedro_datasets.partitions.partitioned_dataset.PartitionedDataset(filepath='', """
"""dataset='kedro_datasets.pandas.parquet_dataset.ParquetDataset()')"""
)

@pytest.mark.parametrize("dataset", LOCAL_DATASET_DEFINITION)
@pytest.mark.parametrize(
"suffix,expected_num_parts", [("", 5), (".csv", 3), ("p4", 1)]
Expand Down
9 changes: 0 additions & 9 deletions kedro-telemetry/kedro_telemetry/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def before_command_run(

self._consent = _check_for_telemetry_consent(project_path)
if not self._consent:
self._opt_out_notification()
return

# get KedroCLI and its structure from actual project root
Expand Down Expand Up @@ -205,8 +204,6 @@ def after_context_created(self, context):

if self._consent is None:
self._consent = _check_for_telemetry_consent(context.project_path)
if not self._consent:
self._opt_out_notification()
self._project_path = context.project_path

@hook_impl
Expand All @@ -231,12 +228,6 @@ def after_catalog_created(self, catalog):

self._send_telemetry_heap_event("Kedro Project Statistics")

def _opt_out_notification(self):
logger.info(
"Kedro-Telemetry is installed, but you have opted out of "
"sharing usage analytics so none will be collected.",
)

def _send_telemetry_heap_event(self, event_name: str):
"""Hook implementation to send command run data to Heap"""

Expand Down
10 changes: 0 additions & 10 deletions kedro-telemetry/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ def test_before_command_run(self, mocker, fake_metadata, caplog):
in record.message
for record in caplog.records
)
assert not any(
"Kedro-Telemetry is installed, but you have opted out of "
"sharing usage analytics so none will be collected." in record.message
for record in caplog.records
)

def test_before_command_run_with_tools(self, mocker, fake_metadata):
mocker.patch(
Expand Down Expand Up @@ -302,11 +297,6 @@ def test_before_command_run_no_consent_given(self, mocker, fake_metadata, caplog
in record.message
for record in caplog.records
)
assert any(
"Kedro-Telemetry is installed, but you have opted out of "
"sharing usage analytics so none will be collected." in record.message
for record in caplog.records
)

def test_before_command_run_connection_error(self, mocker, fake_metadata, caplog):
mocker.patch(
Expand Down

0 comments on commit 63a0c91

Please sign in to comment.