From da744a4ca0b77be9d851060b2144c5d687bffe91 Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Tue, 27 Sep 2022 17:35:37 +0100 Subject: [PATCH 1/8] Update message for VersionNotFoundError Signed-off-by: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> --- kedro/io/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kedro/io/core.py b/kedro/io/core.py index 9765e0baea..b4f3e7e89c 100644 --- a/kedro/io/core.py +++ b/kedro/io/core.py @@ -538,9 +538,13 @@ def _fetch_latest_load_version(self) -> str: most_recent = next( (path for path in version_paths if self._exists_function(path)), None ) - + protocol = getattr(self, "_protocol", None) if not most_recent: - raise VersionNotFoundError(f"Did not find any versions for {self}") + if protocol in CLOUD_PROTOCOLS: + message = f"Did not find any versions for {self}. This could be due to insufficient permission." + else: + message = f"Did not find any versions for {self}" + raise VersionNotFoundError(message) return PurePath(most_recent).parent.name From 5637a94df97f11c844a8ec5529609a6e6fbe829a Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Thu, 29 Sep 2022 12:06:14 +0100 Subject: [PATCH 2/8] Add test for VersionNotFoundError for cloud protocols --- kedro/io/core.py | 3 ++- tests/io/test_data_catalog.py | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/kedro/io/core.py b/kedro/io/core.py index b4f3e7e89c..e90e6e02cc 100644 --- a/kedro/io/core.py +++ b/kedro/io/core.py @@ -541,7 +541,8 @@ def _fetch_latest_load_version(self) -> str: protocol = getattr(self, "_protocol", None) if not most_recent: if protocol in CLOUD_PROTOCOLS: - message = f"Did not find any versions for {self}. This could be due to insufficient permission." + message = f"Did not find any versions for {self} This could be " \ + f"due to insufficient permission." else: message = f"Did not find any versions for {self}" raise VersionNotFoundError(message) diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index f1c7b608ea..791dfd6462 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -19,7 +19,7 @@ LambdaDataSet, MemoryDataSet, ) -from kedro.io.core import VERSION_FORMAT, generate_timestamp +from kedro.io.core import VERSION_FORMAT, generate_timestamp, Version @pytest.fixture @@ -652,3 +652,17 @@ def test_replacing_nonword_characters(self): assert "ds2_spark" in catalog.datasets.__dict__ assert "ds3__csv" in catalog.datasets.__dict__ assert "jalapeño" in catalog.datasets.__dict__ + + def test_no_version_cloud(self): + """Check the error if no versions are available for load from cloud storage""" + version = Version(load=None, save=None) + dummy_credentials = \ + {'client_kwargs': {'aws_access_key_id': 'FAKE', 'aws_secret_access_key': 'FAKE'}} + ds = CSVDataSet( + "s3://bucket/file.csv", + version=version, + credentials=dummy_credentials) + pattern = re.escape(f"Did not find any versions for {ds} " + f"This could be due to insufficient permission.") + with pytest.raises(DataSetError, match=pattern): + ds.load() From 6d070c8b344c86a9c64723eecbeca94d4d20af8c Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Thu, 29 Sep 2022 13:55:29 +0100 Subject: [PATCH 3/8] Update test_data_catalog.py Update NoVersionFoundError test --- tests/io/test_data_catalog.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index 791dfd6462..83936e3a99 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -656,12 +656,9 @@ def test_replacing_nonword_characters(self): def test_no_version_cloud(self): """Check the error if no versions are available for load from cloud storage""" version = Version(load=None, save=None) - dummy_credentials = \ - {'client_kwargs': {'aws_access_key_id': 'FAKE', 'aws_secret_access_key': 'FAKE'}} ds = CSVDataSet( "s3://bucket/file.csv", - version=version, - credentials=dummy_credentials) + version=version) pattern = re.escape(f"Did not find any versions for {ds} " f"This could be due to insufficient permission.") with pytest.raises(DataSetError, match=pattern): From 5af187dc174efe07b219051dec6783fb89f52346 Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:37:04 +0100 Subject: [PATCH 4/8] minor linting update --- kedro/io/core.py | 6 ++++-- tests/io/test_data_catalog.py | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kedro/io/core.py b/kedro/io/core.py index e90e6e02cc..bcf963a20f 100644 --- a/kedro/io/core.py +++ b/kedro/io/core.py @@ -541,8 +541,10 @@ def _fetch_latest_load_version(self) -> str: protocol = getattr(self, "_protocol", None) if not most_recent: if protocol in CLOUD_PROTOCOLS: - message = f"Did not find any versions for {self} This could be " \ - f"due to insufficient permission." + message = ( + f"Did not find any versions for {self} This could be " + f"due to insufficient permission." + ) else: message = f"Did not find any versions for {self}" raise VersionNotFoundError(message) diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index 83936e3a99..6872ac3154 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -19,7 +19,7 @@ LambdaDataSet, MemoryDataSet, ) -from kedro.io.core import VERSION_FORMAT, generate_timestamp, Version +from kedro.io.core import VERSION_FORMAT, Version, generate_timestamp @pytest.fixture @@ -656,10 +656,10 @@ def test_replacing_nonword_characters(self): def test_no_version_cloud(self): """Check the error if no versions are available for load from cloud storage""" version = Version(load=None, save=None) - ds = CSVDataSet( - "s3://bucket/file.csv", - version=version) - pattern = re.escape(f"Did not find any versions for {ds} " - f"This could be due to insufficient permission.") + ds = CSVDataSet("s3://bucket/file.csv", version=version) + pattern = re.escape( + f"Did not find any versions for {ds} " + f"This could be due to insufficient permission." + ) with pytest.raises(DataSetError, match=pattern): ds.load() From 6088e00159a9ee844dfee312673654b6d248f931 Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Thu, 29 Sep 2022 16:25:57 +0100 Subject: [PATCH 5/8] update docs link + styling changes --- docs/source/deployment/databricks.md | 2 +- tests/io/test_data_catalog.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/deployment/databricks.md b/docs/source/deployment/databricks.md index 1ecaa4daee..8e46e692d8 100644 --- a/docs/source/deployment/databricks.md +++ b/docs/source/deployment/databricks.md @@ -159,7 +159,7 @@ Then press `Confirm` button. Your cluster will be restarted to apply the changes Congratulations, you are now ready to run your Kedro project from the Databricks! -[Create your Databricks notebook](https://docs.databricks.com/notebooks/notebooks-manage.html#create-a-notebook) and remember to [attach it to the cluster](https://docs.databricks.com/notebooks/notebooks-manage.html#attach) you have just configured. +[Create your Databricks notebook](https://docs.databricks.com/notebooks/notebooks-manage.html#create-a-notebook) and remember to [attach it to the cluster](https://docs.databricks.com/notebooks/notebooks-manage.html#attach-a-notebook-to-a-cluster) you have just configured. In your newly-created notebook, put each of the below code snippets into a separate cell, then [run all cells](https://docs.databricks.com/notebooks/notebooks-use.html#run-notebooks): diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index 6872ac3154..6eecff522c 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -653,13 +653,13 @@ def test_replacing_nonword_characters(self): assert "ds3__csv" in catalog.datasets.__dict__ assert "jalapeño" in catalog.datasets.__dict__ - def test_no_version_cloud(self): + def test_no_versions_cloud_protocol(self): """Check the error if no versions are available for load from cloud storage""" version = Version(load=None, save=None) - ds = CSVDataSet("s3://bucket/file.csv", version=version) + versioned_dataset = CSVDataSet("s3://bucket/file.csv", version=version) pattern = re.escape( - f"Did not find any versions for {ds} " + f"Did not find any versions for {versioned_dataset} " f"This could be due to insufficient permission." ) with pytest.raises(DataSetError, match=pattern): - ds.load() + versioned_dataset.load() From 3ed6c93353481be0cb0c0f47074c6baefe8a4e0e Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Thu, 29 Sep 2022 17:21:21 +0100 Subject: [PATCH 6/8] Revert "update docs link + styling changes" This reverts commit 6088e00159a9ee844dfee312673654b6d248f931. --- docs/source/deployment/databricks.md | 2 +- tests/io/test_data_catalog.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/deployment/databricks.md b/docs/source/deployment/databricks.md index 8e46e692d8..1ecaa4daee 100644 --- a/docs/source/deployment/databricks.md +++ b/docs/source/deployment/databricks.md @@ -159,7 +159,7 @@ Then press `Confirm` button. Your cluster will be restarted to apply the changes Congratulations, you are now ready to run your Kedro project from the Databricks! -[Create your Databricks notebook](https://docs.databricks.com/notebooks/notebooks-manage.html#create-a-notebook) and remember to [attach it to the cluster](https://docs.databricks.com/notebooks/notebooks-manage.html#attach-a-notebook-to-a-cluster) you have just configured. +[Create your Databricks notebook](https://docs.databricks.com/notebooks/notebooks-manage.html#create-a-notebook) and remember to [attach it to the cluster](https://docs.databricks.com/notebooks/notebooks-manage.html#attach) you have just configured. In your newly-created notebook, put each of the below code snippets into a separate cell, then [run all cells](https://docs.databricks.com/notebooks/notebooks-use.html#run-notebooks): diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index 6eecff522c..6872ac3154 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -653,13 +653,13 @@ def test_replacing_nonword_characters(self): assert "ds3__csv" in catalog.datasets.__dict__ assert "jalapeño" in catalog.datasets.__dict__ - def test_no_versions_cloud_protocol(self): + def test_no_version_cloud(self): """Check the error if no versions are available for load from cloud storage""" version = Version(load=None, save=None) - versioned_dataset = CSVDataSet("s3://bucket/file.csv", version=version) + ds = CSVDataSet("s3://bucket/file.csv", version=version) pattern = re.escape( - f"Did not find any versions for {versioned_dataset} " + f"Did not find any versions for {ds} " f"This could be due to insufficient permission." ) with pytest.raises(DataSetError, match=pattern): - versioned_dataset.load() + ds.load() From 211c449b68a52d3204dcb884b9af671d24753b1f Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:21:35 +0100 Subject: [PATCH 7/8] Update test with styling changes --- kedro/io/core.py | 2 +- tests/io/test_data_catalog.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kedro/io/core.py b/kedro/io/core.py index bcf963a20f..fc6dea587c 100644 --- a/kedro/io/core.py +++ b/kedro/io/core.py @@ -542,7 +542,7 @@ def _fetch_latest_load_version(self) -> str: if not most_recent: if protocol in CLOUD_PROTOCOLS: message = ( - f"Did not find any versions for {self} This could be " + f"Did not find any versions for {self}. This could be " f"due to insufficient permission." ) else: diff --git a/tests/io/test_data_catalog.py b/tests/io/test_data_catalog.py index 6872ac3154..76e18dcae3 100644 --- a/tests/io/test_data_catalog.py +++ b/tests/io/test_data_catalog.py @@ -653,13 +653,13 @@ def test_replacing_nonword_characters(self): assert "ds3__csv" in catalog.datasets.__dict__ assert "jalapeño" in catalog.datasets.__dict__ - def test_no_version_cloud(self): + def test_no_versions_with_cloud_protocol(self): """Check the error if no versions are available for load from cloud storage""" version = Version(load=None, save=None) - ds = CSVDataSet("s3://bucket/file.csv", version=version) + versioned_dataset = CSVDataSet("s3://bucket/file.csv", version=version) pattern = re.escape( - f"Did not find any versions for {ds} " + f"Did not find any versions for {versioned_dataset}. " f"This could be due to insufficient permission." ) with pytest.raises(DataSetError, match=pattern): - ds.load() + versioned_dataset.load() From 0456e0196401e9e9dad60d67ce4aed13037e539f Mon Sep 17 00:00:00 2001 From: Ankita Katiyar <110245118+ankatiyar@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:38:21 +0100 Subject: [PATCH 8/8] Update RELEASE.md Signed-off-by: ankatiyar --- RELEASE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE.md b/RELEASE.md index 2dad086227..becee02e0f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -13,6 +13,7 @@ ## Major features and improvements ## Bug fixes and other changes +* Updated error message for `VersionNotFoundError` to handle insufficient permission issues for cloud storage. ## Upcoming deprecations for Kedro 0.19.0