# 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.

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Since I am using Semantic Link, this code only works for Premium workspaces in a Fabric capacity. This is not a comprehensive list of all semantic models and supported storage modes.</div>
</div>

* **Build Semantic Model Catalog:**
    
    ```python
    !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**
    

%[https://gist.github.com/pawarbi/b48efdc9a8e864d0c4082b851d28d1ad] 

* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1700022422207/b0a75291-3573-4a6d-b38e-885fef7b451c.png align="center")
    
    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.
    
    <div data-node-type="callout">
    <div data-node-type="callout-emoji">💡</div>
    <div data-node-type="callout-text">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 <a target="_blank" rel="noopener noreferrer nofollow" href="https://learn.microsoft.com/en-us/power-bi/enterprise/directlake-overview?wt.mc_id=MVP_335074" style="pointer-events: none">documentation</a> for more details.</div>
    </div>
