Skip to content

Commit

Permalink
feat: remove deprecated occurrence of insight
Browse files Browse the repository at this point in the history
JIRA: PSDK-182
  • Loading branch information
hkad98 committed May 29, 2024
1 parent c0626b8 commit 714b376
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 196 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion gooddata-dbt/gooddata_dbt/gooddata/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gooddata-pandas/docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions gooddata-pandas/gooddata_pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions gooddata-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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():
Expand Down
5 changes: 0 additions & 5 deletions gooddata-sdk/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
40 changes: 0 additions & 40 deletions gooddata-sdk/gooddata_sdk/catalog/export/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
14 changes: 1 addition & 13 deletions gooddata-sdk/gooddata_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
11 changes: 0 additions & 11 deletions gooddata-sdk/gooddata_sdk/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,7 +24,6 @@
from gooddata_sdk.visualization import (
AttributeSortType,
BucketType,
Insight,
LocatorItemType,
SortDirection,
SortType,
Expand Down Expand Up @@ -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:
Expand Down
105 changes: 1 addition & 104 deletions gooddata-sdk/gooddata_sdk/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"})
"""
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion gooddata-sdk/tests/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 714b376

Please sign in to comment.