mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-04 06:33:10 +00:00
Powerbi pagination fix (#9784)
* Fixed powerbi pagination logic * Added yaml changes
This commit is contained in:
parent
da856108ad
commit
08a4d33c5f
@ -1,6 +1,6 @@
|
|||||||
source:
|
source:
|
||||||
type: powerbi
|
type: powerbi
|
||||||
serviceName: local_power11
|
serviceName: local_powerbi
|
||||||
serviceConnection:
|
serviceConnection:
|
||||||
config:
|
config:
|
||||||
clientId: client_id
|
clientId: client_id
|
||||||
@ -8,6 +8,7 @@ source:
|
|||||||
tenantId: tenant_id
|
tenantId: tenant_id
|
||||||
scope:
|
scope:
|
||||||
- https://analysis.windows.net/powerbi/api/.default
|
- https://analysis.windows.net/powerbi/api/.default
|
||||||
|
pagination_entity_per_page: 100
|
||||||
type: PowerBI
|
type: PowerBI
|
||||||
sourceConfig:
|
sourceConfig:
|
||||||
config:
|
config:
|
||||||
|
@ -98,7 +98,7 @@ class PowerBiApiClient:
|
|||||||
dict
|
dict
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
entities_per_page = 1000
|
entities_per_page = min(100, self.config.pagination_entity_per_page)
|
||||||
params_data = {"$top": "1"}
|
params_data = {"$top": "1"}
|
||||||
response = self.client.get("/myorg/admin/groups", data=params_data)
|
response = self.client.get("/myorg/admin/groups", data=params_data)
|
||||||
count = response.get("@odata.count")
|
count = response.get("@odata.count")
|
||||||
|
@ -56,7 +56,10 @@ class PowerbiSource(DashboardServiceSource):
|
|||||||
):
|
):
|
||||||
|
|
||||||
super().__init__(config, metadata_config)
|
super().__init__(config, metadata_config)
|
||||||
self.workspace_data = {}
|
self.pagination_entity_per_page = min(
|
||||||
|
100, self.service_connection.pagination_entity_per_page
|
||||||
|
)
|
||||||
|
self.workspace_data = []
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
# fetch all the workspace ids
|
# fetch all the workspace ids
|
||||||
@ -65,20 +68,34 @@ class PowerbiSource(DashboardServiceSource):
|
|||||||
workspace_id_list = [workspace.get("id") for workspace in workspaces]
|
workspace_id_list = [workspace.get("id") for workspace in workspaces]
|
||||||
|
|
||||||
# Start the scan of the available workspaces for dashboard metadata
|
# Start the scan of the available workspaces for dashboard metadata
|
||||||
workspace_scan = self.client.initiate_workspace_scan(workspace_id_list)
|
workspace_paginated_list = [
|
||||||
workspace_scan_id = workspace_scan.get("id")
|
workspace_id_list[i : i + self.pagination_entity_per_page]
|
||||||
|
for i in range(
|
||||||
|
0, len(workspace_id_list), self.pagination_entity_per_page
|
||||||
|
)
|
||||||
|
]
|
||||||
|
count = 1
|
||||||
|
for workspace_ids_chunk in workspace_paginated_list:
|
||||||
|
logger.info(
|
||||||
|
f"Scanning {count}/{len(workspace_paginated_list)} set of workspaces"
|
||||||
|
)
|
||||||
|
workspace_scan = self.client.initiate_workspace_scan(
|
||||||
|
workspace_ids_chunk
|
||||||
|
)
|
||||||
|
workspace_scan_id = workspace_scan.get("id")
|
||||||
|
|
||||||
# Keep polling the scan status endpoint to check if scan is succeeded
|
# Keep polling the scan status endpoint to check if scan is succeeded
|
||||||
workspace_scan_status = self.client.wait_for_scan_complete(
|
workspace_scan_status = self.client.wait_for_scan_complete(
|
||||||
scan_id=workspace_scan_id
|
|
||||||
)
|
|
||||||
if workspace_scan_status:
|
|
||||||
response = self.client.fetch_workspace_scan_result(
|
|
||||||
scan_id=workspace_scan_id
|
scan_id=workspace_scan_id
|
||||||
)
|
)
|
||||||
self.workspace_data = response.get("workspaces")
|
if workspace_scan_status:
|
||||||
else:
|
response = self.client.fetch_workspace_scan_result(
|
||||||
logger.error("Error in fetching dashboards and charts")
|
scan_id=workspace_scan_id
|
||||||
|
)
|
||||||
|
self.workspace_data.extend(response.get("workspaces"))
|
||||||
|
else:
|
||||||
|
logger.error("Error in fetching dashboards and charts")
|
||||||
|
count += 1
|
||||||
else:
|
else:
|
||||||
logger.error("Unable to fetch any Powerbi workspaces")
|
logger.error("Unable to fetch any Powerbi workspaces")
|
||||||
return super().prepare()
|
return super().prepare()
|
||||||
|
@ -59,6 +59,12 @@
|
|||||||
},
|
},
|
||||||
"default": ["https://analysis.windows.net/powerbi/api/.default"]
|
"default": ["https://analysis.windows.net/powerbi/api/.default"]
|
||||||
},
|
},
|
||||||
|
"pagination_entity_per_page": {
|
||||||
|
"title": "Pagination Entity Per Page",
|
||||||
|
"description": "Entity Limit set here will be used to paginate the PowerBi APIs",
|
||||||
|
"type": "integer",
|
||||||
|
"default": 100
|
||||||
|
},
|
||||||
"supportsMetadataExtraction": {
|
"supportsMetadataExtraction": {
|
||||||
"title": "Supports Metadata Extraction",
|
"title": "Supports Metadata Extraction",
|
||||||
"$ref": "../connectionBasicType.json#/definitions/supportsMetadataExtraction"
|
"$ref": "../connectionBasicType.json#/definitions/supportsMetadataExtraction"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user