gooddata-pandas 1.28.1.dev2__py3-none-any.whl → 1.28.1.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gooddata-pandas might be problematic. Click here for more details.

@@ -6,7 +6,7 @@ from typing import Any, Optional, Union
6
6
  from gooddata_sdk import (
7
7
  Attribute,
8
8
  AttributeFilter,
9
- CatalogWorkspaceContent,
9
+ CatalogAttribute,
10
10
  ExecutionDefinition,
11
11
  ExecutionResponse,
12
12
  Filter,
@@ -16,6 +16,7 @@ from gooddata_sdk import (
16
16
  ObjId,
17
17
  TableDimension,
18
18
  )
19
+ from gooddata_sdk.utils import IdObjType
19
20
 
20
21
  from gooddata_pandas.utils import (
21
22
  ColumnsDef,
@@ -311,27 +312,32 @@ def _extract_for_metrics_only(response: ExecutionResponse, cols: list, col_to_me
311
312
  """
312
313
  exec_def = response.exec_def
313
314
  result = response.read_result(len(exec_def.metrics))
314
- data = dict()
315
+ if len(result.data) == 0:
316
+ return {col: [] for col in cols}
315
317
 
316
- for col in cols:
317
- data[col] = [result.data[col_to_metric_idx[col]]]
318
+ return {col: [result.data[col_to_metric_idx[col]]] for col in cols}
318
319
 
319
- return data
320
320
 
321
+ def _find_attribute(attributes: list[CatalogAttribute], id_obj: IdObjType) -> Union[CatalogAttribute, None]:
322
+ for attribute in attributes:
323
+ if attribute.find_label(id_obj) is not None:
324
+ return attribute
325
+ return None
321
326
 
322
- def _typed_result(catalog: CatalogWorkspaceContent, attribute: Attribute, result_values: list[Any]) -> list[Any]:
327
+
328
+ def _typed_result(attributes: list[CatalogAttribute], attribute: Attribute, result_values: list[Any]) -> list[Any]:
323
329
  """
324
330
  Internal function to convert result_values to proper data types.
325
331
 
326
332
  Args:
327
- catalog (CatalogWorkspaceContent): The catalog workspace content.
333
+ attributes (list[CatalogAttribute]): The catalog of attributes.
328
334
  attribute (Attribute): The attribute for which the typed result will be computed.
329
335
  result_values (list[Any]): A list of raw values.
330
336
 
331
337
  Returns:
332
338
  list[Any]: A list of converted values with proper data types.
333
339
  """
334
- catalog_attribute = catalog.find_label_attribute(attribute.label)
340
+ catalog_attribute = _find_attribute(attributes, attribute.label)
335
341
  if catalog_attribute is None:
336
342
  raise ValueError(f"Unable to find attribute {attribute.label} in catalog")
337
343
  return [_typed_attribute_value(catalog_attribute, value) for value in result_values]
@@ -339,7 +345,7 @@ def _typed_result(catalog: CatalogWorkspaceContent, attribute: Attribute, result
339
345
 
340
346
  def _extract_from_attributes_and_maybe_metrics(
341
347
  response: ExecutionResponse,
342
- catalog: CatalogWorkspaceContent,
348
+ attributes: list[CatalogAttribute],
343
349
  cols: list[str],
344
350
  col_to_attr_idx: dict[str, int],
345
351
  col_to_metric_idx: dict[str, int],
@@ -382,12 +388,12 @@ def _extract_from_attributes_and_maybe_metrics(
382
388
  for idx_name in index:
383
389
  rs = result.get_all_header_values(attribute_dim, safe_index_to_attr_idx[idx_name])
384
390
  attribute = index_to_attribute[idx_name]
385
- index[idx_name] += _typed_result(catalog, attribute, rs)
391
+ index[idx_name] += _typed_result(attributes, attribute, rs)
386
392
  for col in cols:
387
393
  if col in col_to_attr_idx:
388
394
  rs = result.get_all_header_values(attribute_dim, col_to_attr_idx[col])
389
395
  attribute = col_to_attribute[col]
390
- data[col] += _typed_result(catalog, attribute, rs)
396
+ data[col] += _typed_result(attributes, attribute, rs)
391
397
  elif col_to_metric_idx[col] < len(result.data):
392
398
  data[col] += result.data[col_to_metric_idx[col]]
393
399
  if result.is_complete(attribute_dim):
@@ -440,10 +446,10 @@ def compute_and_extract(
440
446
  if not exec_def.has_attributes():
441
447
  return _extract_for_metrics_only(response, cols, col_to_metric_idx), dict()
442
448
  else:
443
- catalog = sdk.catalog_workspace_content.get_full_catalog(workspace_id)
449
+ attributes = sdk.catalog_workspace_content.get_attributes_catalog(workspace_id, include=["labels", "datasets"])
444
450
  return _extract_from_attributes_and_maybe_metrics(
445
451
  response,
446
- catalog,
452
+ attributes,
447
453
  cols,
448
454
  col_to_attr_idx,
449
455
  col_to_metric_idx,
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gooddata-pandas
3
- Version: 1.28.1.dev2
3
+ Version: 1.28.1.dev4
4
4
  Summary: GoodData Cloud to pandas
5
5
  Author: GoodData
6
6
  Author-email: support@gooddata.com
7
7
  License: MIT
8
- Project-URL: Documentation, https://gooddata-pandas.readthedocs.io/en/v1.28.1.dev2
8
+ Project-URL: Documentation, https://gooddata-pandas.readthedocs.io/en/v1.28.1.dev4
9
9
  Project-URL: Source, https://github.com/gooddata/gooddata-python-sdk
10
10
  Keywords: gooddata,pandas,series,data,frame,data_frame,analytics,headless,business,intelligence,headless-bi,cloud,native,semantic,layer,sql,metrics
11
11
  Classifier: Development Status :: 5 - Production/Stable
@@ -22,7 +22,7 @@ Classifier: Typing :: Typed
22
22
  Requires-Python: >=3.9.0
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.txt
25
- Requires-Dist: gooddata-sdk ~=1.28.1.dev2
25
+ Requires-Dist: gooddata-sdk ~=1.28.1.dev4
26
26
  Requires-Dist: pandas <3.0.0,>=2.0.0
27
27
 
28
28
  # GoodData Pandas
@@ -1,14 +1,14 @@
1
1
  gooddata_pandas/__init__.py,sha256=Ta3qIIDq7kBRUsYSV3aC69AQBFvFvhtWDQucgP-l88w,297
2
2
  gooddata_pandas/_version.py,sha256=960vTs6l7xsN2BOXWCxOc4PSKdzzKhnNEPTMnmMTCQs,119
3
- gooddata_pandas/data_access.py,sha256=JqiaEKZLrL6hisiO-4uy4A0Eng9X6shzAb_hiMuONJs,18753
3
+ gooddata_pandas/data_access.py,sha256=u64xnvPUCHmF41A6I02A1bhqmszuPNzoKuycIH6y3jc,19109
4
4
  gooddata_pandas/dataframe.py,sha256=SeNIx-tlf7PjmGppkhNDPEl8RQN6BRKOC3UJ89uFnjo,13000
5
5
  gooddata_pandas/good_pandas.py,sha256=ePEm2Lmeiftz5td0BLC71q7my5Aj8aABn3xV0myRmqI,3444
6
6
  gooddata_pandas/py.typed,sha256=u_MS29sadlaIqGRPYFjWml5u0gQnoQfvbsf9pu3TZJU,94
7
7
  gooddata_pandas/result_convertor.py,sha256=r7uFrjeM6cxMy08YcS3LywF1iUPSyEyG3BAddh0DkIQ,25807
8
8
  gooddata_pandas/series.py,sha256=wTvJR_I0FUteyxo4RwHzP20eU7rei0dP8ZdqfrLbf5c,5759
9
9
  gooddata_pandas/utils.py,sha256=JQZOuGjDfpPZqBnz-KdN8EwjzXXTbQCONWmUEE3cY9M,7217
10
- gooddata_pandas-1.28.1.dev2.dist-info/LICENSE.txt,sha256=3RjzQk8y9HG1_LgqvbEqWZKJnTQGOO1cpzYzBc13Myk,149825
11
- gooddata_pandas-1.28.1.dev2.dist-info/METADATA,sha256=nuwMgaJFQGneRP5j-09T9dxXdAJVreyvLpBefbVbMho,2843
12
- gooddata_pandas-1.28.1.dev2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
13
- gooddata_pandas-1.28.1.dev2.dist-info/top_level.txt,sha256=B7K_WFxlxplJbEbv5Mf0YhX74dbOpTPgDX-W6I7CssI,16
14
- gooddata_pandas-1.28.1.dev2.dist-info/RECORD,,
10
+ gooddata_pandas-1.28.1.dev4.dist-info/LICENSE.txt,sha256=3RjzQk8y9HG1_LgqvbEqWZKJnTQGOO1cpzYzBc13Myk,149825
11
+ gooddata_pandas-1.28.1.dev4.dist-info/METADATA,sha256=TrYPzQwPF4Dj2A-_LUJSMPtMp8ddYIU6sO_VS42UBy4,2843
12
+ gooddata_pandas-1.28.1.dev4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
13
+ gooddata_pandas-1.28.1.dev4.dist-info/top_level.txt,sha256=B7K_WFxlxplJbEbv5Mf0YhX74dbOpTPgDX-W6I7CssI,16
14
+ gooddata_pandas-1.28.1.dev4.dist-info/RECORD,,