From 714b3760e0296f3fdfda24bc8ea7bca2c456c7ec Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Wed, 29 May 2024 08:44:14 +0200 Subject: [PATCH] feat: remove deprecated occurrence of `insight` JIRA: PSDK-182 --- CONTRIBUTING.md | 2 +- README.md | 2 +- .../gooddata_dbt/gooddata/api_wrapper.py | 2 +- gooddata-pandas/docs/examples.rst | 4 +- gooddata-pandas/gooddata_pandas/dataframe.py | 10 -- gooddata-sdk/README.md | 14 +-- gooddata-sdk/gooddata_sdk/__init__.py | 5 - .../gooddata_sdk/catalog/export/service.py | 40 ------- gooddata-sdk/gooddata_sdk/sdk.py | 14 +-- gooddata-sdk/gooddata_sdk/table.py | 11 -- gooddata-sdk/gooddata_sdk/visualization.py | 105 +----------------- gooddata-sdk/tests/overview.md | 2 +- 12 files changed, 15 insertions(+), 196 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc6563f09..d0d042378 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -178,7 +178,7 @@ But there is one disadvantage. One needs GD.CN instance with the original setup `docker-compose.yaml` in root of the repository is here to help. It starts: - GD.CN AIO in selected version - postgres with gooddata-fdw extension -- service which setups GD.CN AIO demo project including PDM, LDM, metrics and insights +- service which setups GD.CN AIO demo project including PDM, LDM, metrics and visualizations When a vcrpy supported test needs to be updated: - start GD.CN using above `docker-compose.yaml` diff --git a/README.md b/README.md index f75a0bd46..c03202c1c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Check out the GoodData Pandas [documentation](https://gooddata-pandas.readthedoc > GoodData Foreign Data Wrapper is currently deprecated. The [gooddata-fdw](./gooddata-fdw) package provides a way -to map GoodData Cloud semantic layer and/or insights stored in your GoodData Cloud +to map GoodData Cloud semantic layer and/or visualizations stored in your GoodData Cloud into PostgreSQL as foreign tables that you can then query using SQL. Check out the GoodData Foreign Data Wrapper [documentation](https://gooddata-fdw.readthedocs.io/en/latest/) to learn more and get started. diff --git a/gooddata-dbt/gooddata_dbt/gooddata/api_wrapper.py b/gooddata-dbt/gooddata_dbt/gooddata/api_wrapper.py index b71c24834..d0e7045f0 100644 --- a/gooddata-dbt/gooddata_dbt/gooddata/api_wrapper.py +++ b/gooddata-dbt/gooddata_dbt/gooddata/api_wrapper.py @@ -37,7 +37,7 @@ def __init__(self, sdk: GoodDataSdk, logger: logging.Logger, dry_run: bool = Fal def get_visualizations(self, workspace_id: str) -> List[Visualization]: if self.dry_run: - self.logger.info("Dry run - skipping insights listing") + self.logger.info("Dry run - skipping visualizations listing") return [] else: return self.sdk.visualizations.get_visualizations(workspace_id) diff --git a/gooddata-pandas/docs/examples.rst b/gooddata-pandas/docs/examples.rst index 014af92b2..1d2f815be 100644 --- a/gooddata-pandas/docs/examples.rst +++ b/gooddata-pandas/docs/examples.rst @@ -71,9 +71,9 @@ Data Frames ) ) - # create data frame based on the contents of the insight. if the insight contains labels and + # create data frame based on the contents of the visualization. if the visualization contains labels and # measures, the data frame will contain index or hierarchical index. - insight_df = frames.for_insight('insight_id') + visualization_df = frames.for_visualization('visualization_id') # create data frame based on the content of the items dict. if the dict contains both labels # and measures, the frame will contain index or hierarchical index. diff --git a/gooddata-pandas/gooddata_pandas/dataframe.py b/gooddata-pandas/gooddata_pandas/dataframe.py index 7e312438a..2df4f904d 100644 --- a/gooddata-pandas/gooddata_pandas/dataframe.py +++ b/gooddata-pandas/gooddata_pandas/dataframe.py @@ -2,7 +2,6 @@ from __future__ import annotations from typing import Optional, Tuple, Union -from warnings import warn import pandas from gooddata_api_client import models @@ -184,15 +183,6 @@ def for_visualization(self, visualization_id: str, auto_index: bool = True) -> p return self.for_items(columns, filter_by=filter_by, auto_index=auto_index) - def for_insight(self, insight_id: str, auto_index: bool = True) -> pandas.DataFrame: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use 'for_visualization' method instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.for_visualization(insight_id, auto_index) - def result_cache_metadata_for_exec_result_id(self, result_id: str) -> ResultCacheMetadata: """ Retrieves result cache metadata for given :result_id: diff --git a/gooddata-sdk/README.md b/gooddata-sdk/README.md index ef9b58e09..75206d167 100644 --- a/gooddata-sdk/README.md +++ b/gooddata-sdk/README.md @@ -9,7 +9,7 @@ At the moment the SDK provides services to inspect and interact with the Semanti * Catalog User Service * Catalog Permission Service * Catalog Organization Service -* Insights Service +* Visualizations Service * Compute Service * Table Service @@ -28,7 +28,7 @@ Run the following command to install the `gooddata-sdk` package on your system: ## Example -Compute an insight: +Compute an visualization: ```python import gooddata_sdk @@ -39,11 +39,11 @@ token = "some_user_token" sdk = gooddata_sdk.GoodDataSdk.create(host, token) workspace_id = "demo" -insight_id = "customers_trend" -# reads insight from workspace -insight = sdk.visualizations.get_visualization(workspace_id, insight_id) -# triggers computation for the insight. the result will be returned in a tabular form -table = sdk.tables.for_visualization(workspace_id, insight) +visualization_id = "customers_trend" +# reads visualization from workspace +visualization = sdk.visualizations.get_visualization(workspace_id, visualization_id) +# triggers computation for the visualization. the result will be returned in a tabular form +table = sdk.tables.for_visualization(workspace_id, visualization) # and this is how you can read data row-by-row and do something with it for row in table.read_all(): diff --git a/gooddata-sdk/gooddata_sdk/__init__.py b/gooddata-sdk/gooddata_sdk/__init__.py index 3aff0ab07..f893fa560 100644 --- a/gooddata-sdk/gooddata_sdk/__init__.py +++ b/gooddata-sdk/gooddata_sdk/__init__.py @@ -230,11 +230,6 @@ from gooddata_sdk.table import ExecutionTable, TableService from gooddata_sdk.utils import SideLoads from gooddata_sdk.visualization import ( - Insight, - InsightAttribute, - InsightBucket, - InsightMetric, - InsightService, Visualization, VisualizationAttribute, VisualizationBucket, diff --git a/gooddata-sdk/gooddata_sdk/catalog/export/service.py b/gooddata-sdk/gooddata_sdk/catalog/export/service.py index c71748455..be1ea2865 100644 --- a/gooddata-sdk/gooddata_sdk/catalog/export/service.py +++ b/gooddata-sdk/gooddata_sdk/catalog/export/service.py @@ -2,7 +2,6 @@ import time from pathlib import Path from typing import Callable, Optional, Tuple, Union -from warnings import warn from gooddata_api_client.exceptions import NotFoundException from gooddata_api_client.model.pdf_export_request import PdfExportRequest @@ -284,15 +283,6 @@ def _get_visualization_exec_table(self, workspace_id: str, visualization_id: str f"or visualization visualization_id='{visualization_id}' does not exist." ) - def _get_insight_exec_table(self, workspace_id: str, insight_id: str) -> Tuple[ExecutionTable, str]: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use '_get_visualization_exec_table' method instead.", - DeprecationWarning, - stacklevel=2, - ) - return self._get_visualization_exec_table(workspace_id, insight_id) - def export_tabular_by_visualization_id( self, workspace_id: str, @@ -341,33 +331,3 @@ def export_tabular_by_visualization_id( retry=retry, max_retry=max_retry, ) - - def export_tabular_by_insight_id( - self, - workspace_id: str, - insight_id: str, - file_format: str, - file_name: Optional[str] = None, - settings: Optional[ExportSettings] = None, - store_path: Union[str, Path] = Path.cwd(), - timeout: float = 60.0, - retry: float = 0.2, - max_retry: float = 5.0, - ) -> None: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use 'export_tabular_by_visualization_id' method instead.", - DeprecationWarning, - stacklevel=2, - ) - self.export_tabular_by_visualization_id( - workspace_id, - insight_id, - file_format, - file_name, - settings, - store_path, - timeout, - retry, - max_retry, - ) diff --git a/gooddata-sdk/gooddata_sdk/sdk.py b/gooddata-sdk/gooddata_sdk/sdk.py index 1b2df903a..3f4b71fe9 100644 --- a/gooddata-sdk/gooddata_sdk/sdk.py +++ b/gooddata-sdk/gooddata_sdk/sdk.py @@ -3,7 +3,6 @@ from pathlib import Path from typing import Optional -from warnings import warn from gooddata_sdk.catalog.data_source.service import CatalogDataSourceService from gooddata_sdk.catalog.export.service import ExportService @@ -17,7 +16,7 @@ from gooddata_sdk.support import SupportService from gooddata_sdk.table import TableService from gooddata_sdk.utils import PROFILES_FILE_PATH, profile_content -from gooddata_sdk.visualization import InsightService, VisualizationService +from gooddata_sdk.visualization import VisualizationService class GoodDataSdk: @@ -74,7 +73,6 @@ def __init__(self, client: GoodDataApiClient) -> None: self._catalog_organization = CatalogOrganizationService(self._client) self._catalog_user = CatalogUserService(self._client) self._compute = ComputeService(self._client) - self._insights = InsightService(self._client) self._visualizations = VisualizationService(self._client) self._tables = TableService(self._client) self._support = SupportService(self._client) @@ -101,16 +99,6 @@ def catalog_organization(self) -> CatalogOrganizationService: def compute(self) -> ComputeService: return self._compute - @property - def insights(self) -> InsightService: - warn( - "This property is deprecated and it will be removed in v1.20.0 release. " - "Please use 'visualizations' property instead.", - DeprecationWarning, - stacklevel=2, - ) - return self._insights - @property def visualizations(self) -> VisualizationService: return self._visualizations diff --git a/gooddata-sdk/gooddata_sdk/table.py b/gooddata-sdk/gooddata_sdk/table.py index 968bdf6b3..88c0b8083 100644 --- a/gooddata-sdk/gooddata_sdk/table.py +++ b/gooddata-sdk/gooddata_sdk/table.py @@ -4,7 +4,6 @@ import logging from operator import attrgetter from typing import Any, Callable, Dict, Generator, List, Optional, Union -from warnings import warn from attrs import define, field, frozen from attrs.setters import frozen as frozen_attr @@ -25,7 +24,6 @@ from gooddata_sdk.visualization import ( AttributeSortType, BucketType, - Insight, LocatorItemType, SortDirection, SortType, @@ -785,15 +783,6 @@ def for_visualization(self, workspace_id: str, visualization: Visualization) -> response = self._compute.for_exec_def(workspace_id=workspace_id, exec_def=exec_def) return _as_table(response) - def for_insight(self, workspace_id: str, insight: Insight) -> ExecutionTable: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use 'for_visualization' method instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.for_visualization(workspace_id=workspace_id, visualization=insight) - def for_items( self, workspace_id: str, items: list[Union[Attribute, Metric]], filters: Optional[list[Filter]] = None ) -> ExecutionTable: diff --git a/gooddata-sdk/gooddata_sdk/visualization.py b/gooddata-sdk/gooddata_sdk/visualization.py index 876747836..007b3e468 100644 --- a/gooddata-sdk/gooddata_sdk/visualization.py +++ b/gooddata-sdk/gooddata_sdk/visualization.py @@ -5,7 +5,6 @@ from collections import defaultdict from enum import Enum from typing import Any, Optional, Union, cast -from warnings import warn from gooddata_sdk.client import GoodDataApiClient from gooddata_sdk.compute.model.attribute import Attribute @@ -661,7 +660,7 @@ def get_metadata(self, id_obj: IdObjType) -> Optional[Any]: def get_labels_and_formats(self) -> tuple[dict[str, str], dict[str, str]]: """ - Extracts labels and custom measure formats from the insight. + Extracts labels and custom measure formats from the visualization. :return: tuple of labels dict ({"label_id":"Label"}) and formats dict ({"measure_id":"#,##0.00"}) """ @@ -759,105 +758,3 @@ def get_visualization(self, workspace_id: str, visualization_id: str) -> Visuali side_loads = SideLoads(vis_obj.included) return Visualization(vis_obj.data, side_loads) - - def get_insights(self, workspace_id: str) -> list[Visualization]: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use 'get_visualizations' method instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.get_visualizations(workspace_id) - - def get_insight(self, workspace_id: str, insight_id: str) -> Visualization: - warn( - "This method is deprecated and it will be removed in v1.20.0 release. " - "Please use 'get_visualization' method instead.", - DeprecationWarning, - stacklevel=2, - ) - return self.get_visualization(workspace_id, insight_id) - - -# Note: the classes below are going to be deprecated - - -class InsightMetric(VisualizationMetric): - def __init__(self, metric: dict[str, Any]) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationMetric' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(metric) - - -class InsightAttribute(VisualizationAttribute): - def __init__(self, attribute: dict[str, Any]) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationAttribute' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(attribute) - - -class InsightTotal(VisualizationTotal): - def __init__(self, total: dict[str, Any]) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationTotal' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(total) - - -class InsightFilter(VisualizationFilter): - def __init__(self, f: dict[str, Any]) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationFilter' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(f) - - -class InsightBucket(VisualizationBucket): - def __init__(self, bucket: dict[str, Any]) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationBucket' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(bucket) - - -class Insight(Visualization): - def __init__( - self, - from_vis_obj: dict[str, Any], - side_loads: Optional[SideLoads] = None, - ) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'Visualization' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(from_vis_obj, side_loads) - - -class InsightService(VisualizationService): - def __init__(self, api_client: GoodDataApiClient) -> None: - warn( - "This class is deprecated and it will be removed in v1.20.0 release. " - "Please use 'VisualizationService' class instead.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__(api_client) diff --git a/gooddata-sdk/tests/overview.md b/gooddata-sdk/tests/overview.md index 434bdf12b..d72b7ef99 100644 --- a/gooddata-sdk/tests/overview.md +++ b/gooddata-sdk/tests/overview.md @@ -27,7 +27,7 @@ There are three important things to remember: ### Type conversion tests -There are a bunch of tests in [compute_model](./compute_model) and [insight](./visualization) whose purpose is to verify +There are a bunch of tests in [compute_model](./compute_model) and [visualization](./visualization) whose purpose is to verify that conversion from internal models to the API models (stored in gooddata-api-client) work as intended.