Identifying Semantic Model Storage Mode in Fabric
With the latest addition of Direct Lake as a storage mode in Power BI, the range of available storage modes continues to expand. If you look at the semantic models in the workspace, except for the Push Semantic Model, it's not possible to identify if a semantic model is in import, DirectQuery, Direct Lake, Dual storage mode. So I wrote the below script to do that.
Build Semantic Model Catalog:
!pip install semantic-link swifter --q import requests import pandas as pd import sempy.fabric as fabric def build_dataset_catalog(): ''' Sandeep Pawar | Fabric.guru Build dataset (semnatic model) catalog in Fabric ''' url = "https://analysis.windows.net/powerbi/api" token = mssparkutils.credentials.getToken(url) headers = {"Authorization": "Bearer " + token} response = requests.get("https://api.powerbi.com/v1.0/myorg/groups", headers=headers) premium_workspaces = pd.DataFrame(response.json()['value']).query('isOnDedicatedCapacity==True')[["name", "id"]] # premium_workspaces = pd.DataFrame(response.json()['value'])[["name", "id"]] dfs = [ fabric.list_datasets(ws).assign(workspace=ws) for ws in premium_workspaces['name'] ] catalog = pd.concat(dfs, ignore_index=True) cols = ['workspace'] + [col for col in catalog.columns if col != 'workspace'] return catalog.reindex(columns=cols) datasets = build_dataset_catalog()[["workspace","Dataset Name","Dataset ID"]] datasets
Use Semantic Link To Identify Partition Modes
-
Note here that the default semantic model is not a storage mode but I am still identifying it because it may be useful. Also, note that,
Mode/Type
returned here is a Python set of all modes in that semantic model. e.g. a semantic model may have two tables, one in import mode and another in DirectQuery. In that case, Mode/Type will show {'import','directquery'}. {'import'} means all partitions in this semantic model are in import mode.💡It is important to note that if a semantic model is in Direct Lake mode, it does not necessarily mean that the queries will be in Direct Lake mode as well. Direct Lake semantic model has a fallback to DirectQuery mechanism in which under certain circumstances, the "query" will be in DirectQuery mode. It's possible to restrict this behavior. Please refer to Direct Lake documentation for more details.