sempy_labs package

Subpackages

Module contents

class sempy_labs.ConnectLakehouse(lakehouse: str, workspace: str | UUID | None = None, timeout: int | None = None)

Bases: ConnectBase

class sempy_labs.ConnectWarehouse(warehouse: str, workspace: str | UUID | None = None, timeout: int | None = None)

Bases: ConnectBase

class sempy_labs.ServicePrincipalTokenProvider(credential: ClientSecretCredential)

Bases: TokenProvider

Implementation of the sempy.fabric.TokenProvider to be used with Service Principal.

For more information on Service Principal see: Application and service principal objects in Microsoft Entra ID

classmethod from_aad_application_key_authentication(tenant_id: str, client_id: str, client_secret: str)

Generates the ServicePrincipalTokenProvider, providing the Service Principal information.

*USE THIS ONE ONLY FOR TEST PURPOSE. FOR PRODUCTION WE RECOMMEND CALLING ServicePrincipalTokenProvider.from_azure_key_vault()*

Parameters:
  • tenant_id (str) – The Fabric Tenant ID.

  • client_id (str) – The Service Principal Application Client ID.

  • client_secret (str) – The Service Principal Client Secret.

Returns:

Token provider to be used with FabricRestClient or PowerBIRestClient.

Return type:

sempy.fabric.TokenProvider

classmethod from_azure_key_vault(key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

Generates the ServicePrincipalTokenProvider, providing the Azure Key Vault details.

For more information on Azure Key Vault, click here.

Parameters:
  • key_vault_uri (str) – Azure Key Vault URI.

  • key_vault_tenant_id (str) – Name of the secret in the Key Vault with the Fabric Tenant ID.

  • key_vault_client_id (str) – Name of the secret in the Key Vault with the Service Principal Client ID.

  • key_vault_client_secret (str) – Name of the secret in the Key Vault with the Service Principal Client Secret.

Returns:

Token provider to be used with FabricRestClient or PowerBIRestClient.

Return type:

sempy.fabric.TokenProvider

sempy_labs.add_user_to_workspace(email_address: str, role_name: str, principal_type: str | None = 'User', workspace: str | None = None)

Adds a user to a workspace.

This is a wrapper function for the following API: Groups - Add Group User.

Parameters:
  • email_address (str) – The email address of the user. Also accepts the user identifier.

  • role_name (str) – The role of the user within the workspace.

  • principal_type (str, default='User') – The principal type.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.assign_workspace_to_capacity(capacity_name: str, workspace: str | None = None)

Assigns a workspace to a capacity.

This is a wrapper function for the following API: Workspaces - Assign To Capacity.

Parameters:
  • capacity_name (str) – The name of the capacity.

  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.assign_workspace_to_dataflow_storage(dataflow_storage_account: str, workspace: str | None = None)

Assigns a dataflow storage account to a workspace.

This is a wrapper function for the following API: Dataflow Storage Accounts - Groups AssignToDataflowStorage.

Parameters:
  • dataflow_storage_account (str) – The name of the dataflow storage account.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.backup_semantic_model(dataset: str, file_path: str, allow_overwrite: bool = True, apply_compression: bool = True, workspace: str | None = None)

Backs up a semantic model to the ADLS Gen2 storage account connected to the workspace.

Parameters:
  • dataset (str) – Name of the semantic model.

  • file_path (str) – The ADLS Gen2 storage account location in which to backup the semantic model. Always saves within the ‘power-bi-backup/<workspace name>’ folder. Must end in ‘.abf’. Example 1: file_path = ‘MyModel.abf’ Example 2: file_path = ‘MyFolder/MyModel.abf’

  • allow_overwrite (bool, default=True) – If True, overwrites backup files of the same name. If False, the file you are saving cannot have the same name as a file that already exists in the same location.

  • apply_compression (bool, default=True) – If True, compresses the backup file. Compressed backup files save disk space, but require slightly higher CPU utilization.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.bind_semantic_model_to_gateway(dataset: str | UUID, gateway: str | UUID, workspace: str | UUID | None = None)

Binds the specified dataset from the specified workspace to the specified gateway.

This is a wrapper function for the following API: Datasets - Bind To Gateway In Group.

Parameters:
  • dataset (str | UUID) – The name or ID of the semantic model.

  • gateway (str | UUID) – The name or ID of the gateway.

  • workspace (str | UUID, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.cancel_dataset_refresh(dataset: str, request_id: str | None = None, workspace: str | None = None)

Cancels the refresh of a semantic model which was executed via the Enhanced Refresh API

Parameters:
  • dataset (str) – Name of the semantic model.

  • request_id (str, default=None) – The request id of a semantic model refresh. Defaults to finding the latest active refresh of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.check_fabric_capacity_name_availablility(capacity_name: str, azure_subscription_id: str, region: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str) bool

This function updates a Fabric capacity’s properties.

This is a wrapper function for the following API: Fabric Capacities - Check Name Availability.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • region (str) – The region name.

  • key_vault_uri (str) – The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

Returns:

An indication as to whether the Fabric capacity name is available or not.

Return type:

bool

sempy_labs.clear_cache(dataset: str, workspace: str | None = None)

Clears the cache of a semantic model. See here for documentation.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.commit_to_git(comment: str, item_ids: str | List[str] = None, workspace: str | None = None)

Commits all or a selection of items within a workspace to Git.

This is a wrapper function for the following API: Git - Commit to Git.

Parameters:
  • comment (str) – The Git commit comment.

  • item_ids (str | List[str], default=None) – A list of item Ids to commit to Git. Defaults to None which commits all items to Git.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.connect_workspace_to_git(organization_name: str, project_name: str, repository_name: str, branch_name: str, directory_name: str, git_provider_type: str = 'AzureDevOps', workspace: str | None = None)

Connects a workspace to a git repository.

This is a wrapper function for the following API: Git - Connect.

Parameters:
  • organization_name (str) – The organization name.

  • project_name (str) – The project name.

  • repository_name (str) – The repository name.

  • branch_name (str) – The branch name.

  • directory_name (str) – The directory name.

  • git_provider_type (str, default="AzureDevOps") – A Git provider type.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.convert_to_friendly_case(text: str) str

Converts a string of pascal/camel/snake case to business-friendly case.

Parameters:

text (str) – The text to convert.

Returns:

Text converted into a business-friendly text.

Return type:

str

sempy_labs.copy_semantic_model_backup_file(source_workspace: str, target_workspace: str, source_file_name: str, target_file_name: str, storage_account: str, source_file_system: str = 'power-bi-backup', target_file_system: str = 'power-bi-backup')

Copies a semantic model backup file (.abf) from an Azure storage account to another location within the Azure storage account.

Requirements:
  1. Must have an Azure storage account and connect it to both the source and target workspace.

  2. Must be a ‘Storage Blob Data Contributor’ for the storage account.
    Steps:
    1. Navigate to the storage account within the Azure Portal

    2. Navigate to ‘Access Control (IAM)’

    3. Click ‘+ Add’ -> Add Role Assignment

    4. Search for ‘Storage Blob Data Contributor’, select it and click ‘Next’

    5. Add yourself as a member, click ‘Next’

    6. Click ‘Review + assign’

Parameters:
  • source_workspace (str) – The workspace name of the source semantic model backup file.

  • target_workspace (str) – The workspace name of the target semantic model backup file destination.

  • source_file_name (str) – The name of the source backup file (i.e. MyModel.abf).

  • target_file_name (str) – The name of the target backup file (i.e. MyModel.abf).

  • storage_account (str) – The name of the storage account.

  • source_file_system (str, default="power-bi-backup") – The container in which the source backup file is located.

  • target_file_system (str, default="power-bi-backup") – The container in which the target backup file will be saved.

sempy_labs.create_abfss_path(lakehouse_id: UUID, lakehouse_workspace_id: UUID, delta_table_name: str) str

Creates an abfss path for a delta table in a Fabric lakehouse.

Parameters:
  • lakehouse_id (UUID) – ID of the Fabric lakehouse.

  • lakehouse_workspace_id (UUID) – ID of the Fabric workspace.

  • delta_table_name (str) – Name of the delta table name.

Returns:

An abfss path which can be used to save/reference a delta table in a Fabric lakehouse.

Return type:

str

sempy_labs.create_blank_semantic_model(dataset: str, compatibility_level: int = 1605, workspace: str | None = None, overwrite: bool = True)

Creates a new blank semantic model (no tables/columns etc.).

Parameters:
  • dataset (str) – Name of the semantic model.

  • compatibility_level (int, default=1605) – The compatibility level of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • overwrite (bool, default=False) – If set to True, overwrites the existing semantic model in the workspace if it exists.

sempy_labs.create_cloud_connection(name: str, server_name: str, database_name: str, user_name: str, password: str, privacy_level: str, connection_encryption: str = 'NotEncrypted', skip_test_connection: bool = False)

Creates a shared cloud connection.

This is a wrapper function for the following API: Connections - Create Connection.

Parameters:
  • name (str) – The name of the connection.

  • server_name (str) – The name of the server.

  • database_name (str) – The name of the database.

  • user_name (str) – The username.

  • password (str) – The password.

  • privacy_level (str) – The privacy level of the connection.

  • connection_encryption (str, default="NotEncrypted") – The connection encrpytion.

  • skip_test_connection (bool, default=False) – If True, skips the test connection.

sempy_labs.create_custom_pool(pool_name: str, node_size: str, min_node_count: int, max_node_count: int, min_executors: int, max_executors: int, node_family: str = 'MemoryOptimized', auto_scale_enabled: bool = True, dynamic_executor_allocation_enabled: bool = True, workspace: str | None = None)

Creates a custom pool within a workspace.

This is a wrapper function for the following API: Custom Pools - Create Workspace Custom Pool.

Parameters:
  • pool_name (str) – The custom pool name.

  • node_size (str) – The node size.

  • min_node_count (int) – The minimum node count.

  • max_node_count (int) – The maximum node count.

  • min_executors (int) – The minimum executors.

  • max_executors (int) – The maximum executors.

  • node_family (str, default='MemoryOptimized') – The node family.

  • auto_scale_enabled (bool, default=True) – The status of auto scale.

  • dynamic_executor_allocation_enabled (bool, default=True) – The status of the dynamic executor allocation.

  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_data_pipeline(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric data pipeline.

This is a wrapper function for the following API: Items - Create Data Pipeline.

Parameters:
  • name (str) – Name of the data pipeline.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_environment(environment: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric environment.

This is a wrapper function for the following API: Items - Create Environment.

Parameters:
  • environment (str) – Name of the environment.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_eventhouse(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric eventhouse.

This is a wrapper function for the following API: Items - Create Eventhouse.

Parameters:
  • name (str) – Name of the eventhouse.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_eventstream(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric eventstream.

This is a wrapper function for the following API: Items - Create Eventstream.

Parameters:
  • name (str) – Name of the eventstream.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_external_data_share(item_name: str, item_type: str, paths: str | List[str], recipient: str, workspace: str | None = None)

Creates an external data share for a given path or list of paths in the specified item.

This is a wrapper function for the following API: External Data Shares - Create External Data Share.

Parameters:
  • item_name (str) – The item name.

  • item_type (str) – The item type.

  • paths (str | List[str]) – The path or list of paths that are to be externally shared. Currently, only a single path is supported.

  • recipient (str) – The email address of the recipient.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_fabric_capacity(capacity_name: str, azure_subscription_id: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str, resource_group: str, region: str, sku: str, admin_members: str | List[str], tags: dict | None = None)

This function creates a new Fabric capacity within an Azure subscription.

This is a wrapper function for the following API: Fabric Capacities - Create Or Update.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

  • resource_group (str) – The name of the Azure resource group.

  • region (str) – The name of the region in which the capacity will be created.

  • sku (str) – The sku size of the Fabric capacity.

  • admin_members (str | List[str]) – The email address(es) of the admin(s) of the Fabric capacity.

  • tags (dict, default=None) – Tag(s) to add to the capacity. Example: {‘tagName’: ‘tagValue’}.

sempy_labs.create_kql_database(name: str, description: str | None = None, workspace: str | None = None)

Creates a KQL database.

This is a wrapper function for the following API: Items - Create KQL Database.

Parameters:
  • name (str) – Name of the KQL database.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_kql_queryset(name: str, description: str | None = None, workspace: str | None = None)

Creates a KQL queryset.

This is a wrapper function for the following API: Items - Create KQL Queryset.

Parameters:
  • name (str) – Name of the KQL queryset.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_managed_private_endpoint(name: str, target_private_link_resource_id: UUID, target_subresource_type: str, request_message: str | None = None, workspace: str | None = None)

Creates a managed private endpoint.

This is a wrapper function for the following API: Managed Private Endpoints - Create Workspace Managed Private Endpoint <https://learn.microsoft.com/rest/api/fabric/core/managed-private-endpoints/create-workspace-managed-private-endpoint>.

Parameters:
  • name (str) – Name of the managed private endpoint.

  • target_private_link_resource_id (UUID) – Resource Id of data source for which private endpoint needs to be created.

  • target_subresource_type (str) – Sub-resource pointing to Private-link resoure.

  • request_message (str, default=None) – Message to approve private endpoint request. Should not be more than 140 characters.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_mirrored_database(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric mirrored database.

This is a wrapper function for the following API: Items - Create Mirrored Database.

Parameters:
  • name (str) – Name of the mirrored database.

  • description (str, default=None) – A description of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_ml_experiment(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric ML experiment.

This is a wrapper function for the following API: Items - Create ML Experiment.

Parameters:
  • name (str) – Name of the ML experiment.

  • description (str, default=None) – A description of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_ml_model(name: str, description: str | None = None, workspace: str | None = None)

Creates a Fabric ML model.

This is a wrapper function for the following API: Items - Create ML Model.

Parameters:
  • name (str) – Name of the ML model.

  • description (str, default=None) – A description of the ML model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_model_bpa_semantic_model(dataset: str | None = 'ModelBPA', lakehouse: str | None = None, lakehouse_workspace: str | None = None)

Dynamically generates a Direct Lake semantic model based on the ‘modelbparesults’ delta table which contains the Best Practice Analyzer results. This semantic model used in combination with the corresponding Best Practice Analyzer report can be used to analyze multiple semantic models on multiple workspaces at once (and over time).

The semantic model is always created within the same workspace as the lakehouse.

Parameters:
  • dataset (str, default='ModelBPA') – Name of the semantic model to be created.

  • lakehouse (str, default=None) – Name of the Fabric lakehouse which contains the ‘modelbparesults’ delta table. Defaults to None which resolves to the default lakehouse attached to the notebook.

  • lakehouse_workspace (str, default=None) – The workspace in which the lakehouse resides. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_notebook(name: str, notebook_content: str, type: str = 'py', description: str | None = None, workspace: str | None = None)

Creates a new notebook with a definition within a workspace.

Parameters:
  • name (str) – The name of the notebook to be created.

  • notebook_content (str) – The Jupyter notebook content (not in Base64 format).

  • type (str, default="py") – The notebook type.

  • description (str, default=None) – The description of the notebook. Defaults to None which does not place a description.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_on_prem_connection(name: str, gateway: str | UUID, server_name: str, database_name: str, credentials: str, privacy_level: str, connection_encryption: str = 'NotEncrypted', skip_test_connection: bool = False)

Creates an on-premises connection.

This is a wrapper function for the following API: Connections - Create Connection.

Parameters:
  • name (str) – The name of the connection.

  • gateway (str | UUID) – The name or Id of the gateway.

  • server_name (str) – The name of the server.

  • database_name (str) – The name of the database.

  • user_name (str) – The username.

  • password (str) – The password.

  • privacy_level (str) –

    The privacy level of the connection.

  • connection_encryption (str, default="NotEncrypted") – The connection encrpytion.

  • skip_test_connection (bool, default=False) – If True, skips the test connection.

sempy_labs.create_relationship_name(from_table: str, from_column: str, to_table: str, to_column: str) str

Formats a relationship’s table/columns into a fully qualified name.

Parameters:
  • from_table (str) – The name of the table on the ‘from’ side of the relationship.

  • from_column (str) – The name of the column on the ‘from’ side of the relationship.

  • to_table (str) – The name of the table on the ‘to’ side of the relationship.

  • to_column (str) – The name of the column on the ‘to’ side of the relationship.

Returns:

The fully qualified relationship name.

Return type:

str

sempy_labs.create_resource_group(azure_subscription_id: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str, resource_group: str, region: str)

This function creates a resource group in a region within an Azure subscription.

This is a wrapper function for the following API: ResourceGroupsOperations Class - CreateOrUpdate.

Parameters:
  • azure_subscription_id (str) – The Azure subscription ID.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

  • resource_group (str) – The name of the Azure resource group to be created.

  • region (str) – The name of the region in which the resource group will be created.

sempy_labs.create_semantic_model_from_bim(dataset: str, bim_file: dict, workspace: str | None = None)

Creates a new semantic model based on a Model.bim file.

This is a wrapper function for the following API: Items - Create Semantic Model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • bim_file (dict) – The model.bim file.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.create_vnet_connection(name: str, gateway: str | UUID, server_name: str, database_name: str, user_name: str, password: str, privacy_level: str, connection_encryption: str | None = 'NotEncrypted', skip_test_connection: bool = False)

Creates a virtual network gateway connection.

This is a wrapper function for the following API: Connections - Create Connection.

Parameters:
  • name (str) – The name of the connection.

  • gateway (str | UUID) – The name or Id of the gateway.

  • server_name (str) – The name of the server.

  • database_name (str) – The name of the database.

  • user_name (str) – The username.

  • password (str) – The password.

  • privacy_level (str) –

    The privacy level of the connection.

  • connection_encryption (str, default="NotEncrypted") – The connection encrpytion.

  • skip_test_connection (bool, default=False) – If True, skips the test connection.

sempy_labs.create_vnet_gateway(name: str, capacity: str | UUID, inactivity_minutes_before_sleep: int, number_of_member_gateways: int, subscription_id: str, resource_group: str, virtual_network: str, subnet: str)

Creates a virtual network gateway.

This is a wrapper function for the following API: Gateways - Create Gateway.

Parameters:
  • name (str) – The gateway name.

  • capacity (str | UUID) – The capacity name or Id.

  • inactivity_minutes_before_sleep (int) – The minutes of inactivity before the virtual network gateway goes into auto-sleep. Must be one of the following values: 30, 60, 90, 120, 150, 240, 360, 480, 720, 1440.

  • number_of_member_gateways (int) – The number of member gateways. A number between 1 and 7.

  • subscription_id (str) – The subscription ID.

  • resource_group (str) – The name of the resource group.

  • virtual_network (str) – The name of the virtual network.

  • subnet (str) – The name of the subnet.

sempy_labs.create_warehouse(warehouse: str, description: str | None = None, case_insensitive_collation: bool = False, workspace: str | None = None)

Creates a Fabric warehouse.

This is a wrapper function for the following API: Items - Create Warehouse.

Parameters:
  • warehouse (str) – Name of the warehouse.

  • description (str, default=None) – A description of the warehouse.

  • case_insensitive_collation (bool, default=False) – If True, creates the warehouse with case-insensitive collation.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_connection(connection: str | UUID)

Delete a connection.

This is a wrapper function for the following API: Connections - Delete Connection.

Parameters:

connection (str | UUID) – The connection name or ID.

sempy_labs.delete_connection_role_assignment(connection: str | UUID, role_assignment_id: UUID)

Delete the specified role assignment for the connection.

This is a wrapper function for the following API: Connections - Delete Connection Role Assignment.

Parameters:
  • connection (str | UUID) – The connection name or ID.

  • role_assignment_id (UUID) – The role assignment ID.

sempy_labs.delete_custom_pool(pool_name: str, workspace: str | None = None)

Deletes a custom pool within a workspace.

This is a wrapper function for the following API: Custom Pools - Delete Workspace Custom Pool.

Parameters:
  • pool_name (str) – The custom pool name.

  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_data_pipeline(name: str, workspace: str | None = None)

Deletes a Fabric data pipeline.

This is a wrapper function for the following API: Items - Delete Data Pipeline.

Parameters:
  • name (str) – Name of the data pipeline.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_embedded_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

This function deletes a Power BI Embedded capacity.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • resource_group (str) – The name of the Azure resource group.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

sempy_labs.delete_environment(environment: str, workspace: str | None = None)

Deletes a Fabric environment.

This is a wrapper function for the following API: Items - Delete Environment.

Parameters:
  • environment (str) – Name of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_eventhouse(name: str, workspace: str | None = None)

Deletes a Fabric eventhouse.

This is a wrapper function for the following API: Items - Delete Eventhouse.

Parameters:
  • name (str) – Name of the eventhouse.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_eventstream(name: str, workspace: str | None = None)

Deletes a Fabric eventstream.

This is a wrapper function for the following API: Items - Delete Eventstream.

Parameters:
  • name (str) – Name of the eventstream.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

This function deletes a Fabric capacity.

This is a wrapper function for the following API: Fabric Capacities - Delete.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • resource_group (str) – The name of the Azure resource group.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

sempy_labs.delete_gateway(gateway: str | UUID)

Deletes a gateway.

This is a wrapper function for the following API: Gateways - Delete Gateway.

Parameters:

gateway (str | UUID) – The gateway name or ID.

sempy_labs.delete_gateway_member(gateway: str | UUID, gateway_member: str | UUID)

Delete gateway member of an on-premises gateway.

This is a wrapper function for the following API: Gateways - Delete Gateway Member.

Parameters:
  • gateway (str | UUID) – The gateway name or ID.

  • gateway_member (str | UUID) – The gateway member name or ID.

sempy_labs.delete_gateway_role_assignment(gateway: str | UUID, role_assignement_id: UUID)

Delete the specified role assignment for the gateway.

This is a wrapper function for the following API: Gateways - Delete Gateway Role Assignment.

Parameters:
  • gateway (str | UUID) – The gateway name or ID.

  • role_assignement_id (UUID) – The role assignment ID.

sempy_labs.delete_kql_database(name: str, workspace: str | None = None)

Deletes a KQL database.

This is a wrapper function for the following API: Items - Delete KQL Database.

Parameters:
  • name (str) – Name of the KQL database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_kql_queryset(name: str, workspace: str | None = None)

Deletes a KQL queryset.

This is a wrapper function for the following API: Items - Delete KQL Queryset.

Parameters:
  • name (str) – Name of the KQL queryset.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_managed_private_endpoint(managed_private_endpoint: str, workspace: str | None = None)

Deletes a Fabric managed private endpoint.

This is a wrapper function for the following API: Managed Private Endpoints - Delete Workspace Managed Private Endpoint <https://learn.microsoft.com/rest/api/fabric/core/managed-private-endpoints/delete-workspace-managed-private-endpoint>.

Parameters:
  • managed_private_endpoint (str) – Name of the managed private endpoint.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_mirrored_database(mirrored_database: str, workspace: str | None = None)

Deletes a mirrored database.

This is a wrapper function for the following API: Items - Delete Mirrored Database.

Parameters:
  • mirrored_database (str) – Name of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_ml_experiment(name: str, workspace: str | None = None)

Deletes a Fabric ML experiment.

This is a wrapper function for the following API: Items - Delete ML Experiment.

Parameters:
  • name (str) – Name of the ML experiment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_ml_model(name: str, workspace: str | None = None)

Deletes a Fabric ML model.

This is a wrapper function for the following API: Items - Delete ML Model.

Parameters:
  • name (str) – Name of the ML model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_premium_capacity(capacity_name: str)

This function deletes a Power BI Premium capacity.

Parameters:

capacity_name (str) – Name of the Fabric capacity.

sempy_labs.delete_user_from_workspace(email_address: str, workspace: str | None = None)

Removes a user from a workspace.

This is a wrapper function for the following API: Groups - Delete User In Group.

Parameters:
  • email_address (str) – The email address of the user.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.delete_warehouse(name: str, workspace: str | None = None)

Deletes a Fabric warehouse.

This is a wrapper function for the following API: Items - Delete Warehouse.

Parameters:
  • name (str) – Name of the warehouse.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.deploy_semantic_model(source_dataset: str, source_workspace: str | None = None, target_dataset: str | None = None, target_workspace: str | None = None, refresh_target_dataset: bool = True, overwrite: bool = False)

Deploys a semantic model based on an existing semantic model.

Parameters:
  • source_dataset (str) – Name of the semantic model to deploy.

  • source_workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • target_dataset (str) – Name of the new semantic model to be created.

  • target_workspace (str, default=None) – The Fabric workspace name in which the new semantic model will be deployed. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • refresh_target_dataset (bool, default=True) – If set to True, this will initiate a full refresh of the target semantic model in the target workspace.

  • overwrite (bool, default=False) – If set to True, overwrites the existing semantic model in the workspace if it exists.

sempy_labs.deprovision_workspace_identity(workspace: str | None = None)

Deprovisions a workspace identity for a workspace.

This is a wrapper function for the following API: Workspaces - Derovision Identity.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.disable_qso(dataset: str, workspace: str | None = None) DataFrame

Sets the max read-only replicas to 0, disabling query scale out.

This is a wrapper function for the following API: Datasets - Update Dataset In Group.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the current query scale out settings.

Return type:

pandas.DataFrame

sempy_labs.disconnect_workspace_from_git(workspace: str | None = None)

Disconnects a workpsace from a git repository.

This is a wrapper function for the following API: Git - Disconnect.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.evaluate_dax_impersonation(dataset: str, dax_query: str, user_name: str | None = None, workspace: str | None = None)

Runs a DAX query against a semantic model using the REST API.

Compared to evaluate_dax this allows passing the user name for impersonation. Note that the REST API has significant limitations compared to the XMLA endpoint.

Parameters:
  • dataset (str) – Name of the semantic model.

  • dax_query (str) – The DAX query.

  • user_name (str) – The user name (i.e. hello@goodbye.com).

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe holding the result of the DAX query.

Return type:

pandas.DataFrame

sempy_labs.export_model_to_onelake(dataset: str, workspace: str | None = None, destination_lakehouse: str | None = None, destination_workspace: str | None = None)

Exports a semantic model’s tables to delta tables in the lakehouse. Creates shortcuts to the tables if a lakehouse is specified.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • destination_lakehouse (str, default=None) – The name of the Fabric lakehouse where shortcuts will be created to access the delta tables created by the export. If the lakehouse specified does not exist, one will be created with that name. If no lakehouse is specified, shortcuts will not be created.

  • destination_workspace (str, default=None) – The name of the Fabric workspace in which the lakehouse resides.

sempy_labs.format_dax_object_name(table: str, column: str) str

Formats a table/column combination to the ‘Table Name’[Column Name] format.

Parameters:
  • table (str) – The name of the table.

  • column (str) – The name of the column.

Returns:

The fully qualified object name.

Return type:

str

sempy_labs.generate_embedded_filter(filter: str) str

Converts the filter expression to a filter expression which can be used by a Power BI embedded URL.

Parameters:

filter (str) – The filter expression for an embedded Power BI report.

Returns:

A filter expression usable by a Power BI embedded URL.

Return type:

str

sempy_labs.get_capacity_id(workspace: str | None = None) UUID

Obtains the Capacity Id for a given workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The capacity Id.

Return type:

UUID

sempy_labs.get_capacity_name(workspace: str | None = None) str

Obtains the capacity name for a given workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The capacity name.

Return type:

str

sempy_labs.get_data_pipeline_definition(name: str, workspace: str | None = None, decode: bool = True) dict | DataFrame

Obtains the definition of a data pipeline.

Parameters:
  • name (str) – The name of the data pipeline.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • decode (bool, default=True) – decode : bool, default=True If True, decodes the data pipeline definition file into .json format. If False, obtains the data pipeline definition file a pandas DataFrame format.

Returns:

A pandas dataframe showing the data pipelines within a workspace.

Return type:

dict | pandas.DataFrame

sempy_labs.get_dax_query_dependencies(dataset: str, dax_string: str | List[str], put_in_memory: bool = False, show_vertipaq_stats: bool = True, workspace: str | None = None) DataFrame

Obtains the columns on which a DAX query depends, including model dependencies. Shows Vertipaq statistics (i.e. Total Size, Data Size, Dictionary Size, Hierarchy Size) for easy prioritizing.

Parameters:
  • dataset (str) – Name of the semantic model.

  • dax_string (str | List[str]) – The DAX query or list of DAX queries.

  • put_in_memory (bool, default=False) – If True, ensures that the dependent columns are put into memory in order to give realistic Vertipaq stats (i.e. Total Size etc.).

  • show_vertipaq_stats (bool, default=True) – If True, shows vertipaq stats (i.e. Total Size, Data Size, Dictionary Size, Hierarchy Size)

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the dependent columns of a given DAX query including model dependencies.

Return type:

pandas.DataFrame

sempy_labs.get_dax_query_memory_size(dataset: str, dax_string: str, workspace: str | None = None) int

Obtains the total size, in bytes, used by all columns that a DAX query depends on.

Parameters:
  • dataset (str) – Name of the semantic model.

  • dax_string (str) – The DAX query.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The total size, in bytes, used by all columns that the DAX query depends on.

Return type:

int

sempy_labs.get_direct_lake_sql_endpoint(dataset: str, workspace: str | None = None) UUID

Obtains the SQL Endpoint ID of the semantic model.

Parameters:
  • dataset (str) – The name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The ID of SQL Endpoint.

Return type:

uuid.UUID

sempy_labs.get_git_connection(workspace: str | None = None) DataFrame

Obtains the Git status of items in the workspace, that can be committed to Git.

This is a wrapper function for the following API: Git - Get Connection.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the Git status of items in the workspace.

Return type:

pandas.DataFrame

sempy_labs.get_git_status(workspace: str | None = None) DataFrame

Obtains the Git status of items in the workspace, that can be committed to Git.

This is a wrapper function for the following API: `Git - Get Status <https://learn.microsoft.com/rest/api/fabric/core/git/get-status>.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the Git status of items in the workspace.

Return type:

pandas.DataFrame

sempy_labs.get_measure_dependencies(dataset: str, workspace: str | None = None) DataFrame

Shows all dependencies for all measures in a semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

Shows all dependencies for all measures in the semantic model.

Return type:

pandas.DataFrame

sempy_labs.get_mirrored_database_definition(mirrored_database: str, workspace: str | None = None, decode: bool = True) str

Obtains the mirrored database definition.

This is a wrapper function for the following API: Items - Get Mirrored Database Definition.

Parameters:
  • mirrored_database (str) – The name of the mirrored database.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • decode (bool, default=True) – If True, decodes the mirrored database definition file into .json format. If False, obtains the mirrored database definition file in base64 format.

Returns:

The mirrored database definition.

Return type:

str

sempy_labs.get_mirroring_status(mirrored_database: str, workspace: str | None = None) str

Get the status of the mirrored database.

This is a wrapper function for the following API: Mirroring - Get Mirroring Status.

Parameters:
  • mirrored_database (str) – Name of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The status of a mirrored database.

Return type:

str

sempy_labs.get_model_calc_dependencies(dataset: str | UUID, workspace: str | None = None) DataFrame

Shows all dependencies for all objects in a semantic model.

Parameters:
  • dataset (str | UUID) – Name or ID of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

Shows all dependencies for all objects in the semantic model.

Return type:

pandas.DataFrame

sempy_labs.get_notebook_definition(notebook_name: str, workspace: str | None = None, decode: bool = True) str

Obtains the notebook definition.

This is a wrapper function for the following API: Items - Get Notebook Definition.

Parameters:
  • notebook_name (str) – The name of the notebook.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • decode (bool, default=True) – If True, decodes the notebook definition file into .ipynb format. If False, obtains the notebook definition file in base64 format.

Returns:

The notebook definition.

Return type:

str

sempy_labs.get_object_level_security(dataset: str | UUID, workspace: str | None = None) DataFrame

Shows the object level security for the semantic model.

Parameters:
  • dataset (str | UUID) – Name or ID of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the object level security for the semantic model.

Return type:

pandas.DataFrame

sempy_labs.get_semantic_model_bim(dataset: str, workspace: str | None = None, save_to_file_name: str | None = None, lakehouse_workspace: str | None = None) dict

Extracts the Model.bim file for a given semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the semantic model resides. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • save_to_file_name (str, default=None) – If specified, saves the Model.bim as a file in the lakehouse attached to the notebook.

  • lakehouse_workspace (str, default=None) – The Fabric workspace name in which the lakehouse attached to the workspace resides. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The Model.bim file for the semantic model.

Return type:

dict

sempy_labs.get_semantic_model_definition(dataset: str, format: str = 'TMSL', workspace: str | None = None, return_dataframe: bool = True) DataFrame | dict | List

Extracts the semantic model definition.

This is a wrapper function for the following API: Items - Get Semantic Model Definition.

Parameters:
  • dataset (str) – Name of the semantic model.

  • format (str, default="TMSL") – The output format. Valid options are “TMSL” or “TMDL”. “TMSL” returns the .bim file whereas “TMDL” returns the collection of TMDL files. Can also enter ‘bim’ for the TMSL version.

  • workspace (str, default=None) – The Fabric workspace name in which the semantic model resides. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • return_dataframe (bool, default=True) – If True, returns a dataframe. If False, returns the .bim file for TMSL format. Returns a list of the TMDL files (decoded) for TMDL format.

Returns:

A pandas dataframe with the semantic model definition or the file or files comprising the semantic model definition.

Return type:

pandas.DataFrame | dict | List

sempy_labs.get_semantic_model_refresh_history(dataset: str, request_id: str | None = None, workspace: str | None = None) DataFrame

Obtains the semantic model refresh history (refreshes executed via the Enhanced Refresh API).

This is a wrapper function for the following API: Datasets - Get Refresh History In Group.

Parameters:
  • dataset (str) – Name of the semantic model.

  • request_id (str, default=None) – The request id of a semantic model refresh. Defaults to None which resolves to showing all refresh requests for the given semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the semantic model refresh history.

Return type:

pandas.DataFrame

sempy_labs.get_semantic_model_size(dataset: str, workspace: str | None = None)
sempy_labs.get_spark_settings(workspace: str | None = None, return_dataframe: bool = True) DataFrame | dict

Shows the spark settings for a workspace.

This is a wrapper function for the following API: Workspace Settings - Get Spark Settings.

Parameters:
  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • return_dataframe (bool, default=True) – If True, returns a pandas dataframe. If False, returns a json dictionary.

Returns:

A pandas dataframe showing the spark settings for a workspace.

Return type:

pandas.DataFrame | dict

sempy_labs.get_tables_mirroring_status(mirrored_database: str, workspace: str | None = None) DataFrame

Gets the mirroring status of the tables.

This is a wrapper function for the following API: Mirroring - Get Tables Mirroring Status.

Parameters:
  • mirrored_database (str) – Name of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the mirroring status of the tables.

Return type:

pandas.DataFrame

sempy_labs.get_tenant_id()
sempy_labs.get_warehouse_columns(warehouse: str, workspace: str | None = None) DataFrame

Shows a list of the columns in each table within the Fabric warehouse. This function is based on INFORMATION_SCHEMA.COLUMNS.

Parameters:
  • warehouse (str) – Name of the Fabric warehouse.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of the columns in each table within the Fabric warehouse.

Return type:

pandas.DataFrame

sempy_labs.get_warehouse_tables(warehouse: str, workspace: str | None = None) DataFrame

Shows a list of the tables in the Fabric warehouse. This function is based on INFORMATION_SCHEMA.TABLES.

Parameters:
  • warehouse (str) – Name of the Fabric warehouse.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of the tables in the Fabric warehouse.

Return type:

pandas.DataFrame

sempy_labs.import_notebook_from_web(notebook_name: str, url: str, description: str | None = None, workspace: str | None = None, overwrite: bool = False)

Creates a new notebook within a workspace based on a Jupyter notebook hosted in the web.

Note: When specifying a notebook from GitHub, please use the raw file path. Note that if the non-raw file path is specified, the url will be converted to the raw URL as the raw URL is needed to obtain the notebook content.

Parameters:
  • notebook_name (str) – The name of the notebook to be created.

  • url (str) – The url of the Jupyter Notebook (.ipynb)

  • description (str, default=None) – The description of the notebook. Defaults to None which does not place a description.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • overwrite (bool, default=False) – If set to True, overwrites the existing notebook in the workspace if it exists.

sempy_labs.import_vertipaq_analyzer(folder_path: str, file_name: str)

Imports and visualizes the vertipaq analyzer info from a saved .zip file in your lakehouse.

Parameters:
  • folder_path (str) – The folder within your lakehouse in which the .zip file containing the vertipaq analyzer info has been saved.

  • file_name (str) – The file name of the file which contains the vertipaq analyzer info.

Returns:

A visualization of the Vertipaq Analyzer statistics.

Return type:

str

sempy_labs.initialize_git_connection(workspace: str | None = None) str

Initializes a connection for a workspace that is connected to Git.

This is a wrapper function for the following API: Git - Initialize Connection.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

Remote full SHA commit hash.

Return type:

str

sempy_labs.is_default_semantic_model(dataset: str, workspace: str | None = None) bool

Identifies whether a semantic model is a default semantic model.

Parameters:
  • dataset (str) – The name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A True/False value indicating whether the semantic model is a default semantic model.

Return type:

bool

sempy_labs.list_backups(workspace: str | None = None) DataFrame

Shows a list of backup files contained within a workspace’s ADLS Gen2 storage account. Requirement: An ADLS Gen2 storage account must be connected to the workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of backup files contained within a workspace’s ADLS Gen2 storage account.

Return type:

pandas.DataFrame

sempy_labs.list_capacities() DataFrame

Shows the capacities and their properties.

Returns:

A pandas dataframe showing the capacities and their properties

Return type:

pandas.DataFrame

sempy_labs.list_connection_role_assignments(connection: str | UUID) DataFrame

Returns a list of connection role assignments.

This is a wrapper function for the following API: Connections - List Connection Role Assignments.

Parameters:

connection (str | UUID) – The connection name or ID.

Returns:

A pandas dataframe showing a list of connection role assignments.

Return type:

pandas.DataFrame

sempy_labs.list_connections() DataFrame

Lists all available connections.

Returns:

A pandas dataframe showing all available connections.

Return type:

pandas.DataFrame

sempy_labs.list_custom_pools(workspace: str | None = None) DataFrame

Lists all custom pools within a workspace.

This is a wrapper function for the following API: Custom Pools - List Workspace Custom Pools.

Parameters:

workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing all the custom pools within the Fabric workspace.

Return type:

pandas.DataFrame

sempy_labs.list_dashboards(workspace: str | None = None) DataFrame

Shows a list of the dashboards within a workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the dashboards within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_data_pipelines(workspace: str | None = None) DataFrame

Shows the data pipelines within a workspace.

This is a wrapper function for the following API: Items - List Data Pipelines.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the data pipelines within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_dataflow_storage_accounts() DataFrame

Shows the accessible dataflow storage accounts.

This is a wrapper function for the following API: Dataflow Storage Accounts - Get Dataflow Storage Accounts.

Returns:

A pandas dataframe showing the accessible dataflow storage accounts.

Return type:

pandas.DataFrame

sempy_labs.list_dataflows(workspace: str | None = None)

Shows a list of all dataflows which exist within a workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the dataflows which exist within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_datamarts(workspace: str | None = None) DataFrame

Shows the datamarts within a workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the datamarts within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_deployment_pipeline_stage_items(deployment_pipeline: str, stage_name: str) DataFrame

Shows the supported items from the workspace assigned to the specified stage of the specified deployment pipeline.

This is a wrapper function for the following API: Deployment Pipelines - List Deployment Pipeline Stage Items.

Parameters:
  • deployment_pipeline (str) – The deployment pipeline name.

  • stage_name (str) – The deployment pipeline stage name.

Returns:

A pandas dataframe showing the supported items from the workspace assigned to the specified stage of the specified deployment pipeline.

Return type:

pandas.DataFrame

sempy_labs.list_deployment_pipeline_stages(deployment_pipeline: str) DataFrame

Shows the specified deployment pipeline stages.

This is a wrapper function for the following API: Deployment Pipelines - List Deployment Pipeline Stages.

Parameters:

deployment_pipeline (str) – The deployment pipeline name.

Returns:

A pandas dataframe showing the specified deployment pipeline stages.

Return type:

pandas.DataFrame

sempy_labs.list_deployment_pipelines() DataFrame

Shows a list of deployment pipelines the user can access.

This is a wrapper function for the following API: Deployment Pipelines - List Deployment Pipelines.

Returns:

A pandas dataframe showing a list of deployment pipelines the user can access.

Return type:

pandas.DataFrame

sempy_labs.list_eventhouses(workspace: str | None = None) DataFrame

Shows the eventhouses within a workspace.

This is a wrapper function for the following API: Items - List Eventhouses.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the eventhouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_eventstreams(workspace: str | None = None) DataFrame

Shows the eventstreams within a workspace.

This is a wrapper function for the following API: Items - List Eventstreams.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the eventstreams within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_external_data_shares_in_item(item_name: str, item_type: str, workspace: str | None = None) DataFrame

Returns a list of the external data shares that exist for the specified item.

This is a wrapper function for the following API: `External Data Shares - List External Data Shares In Item <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares/list-external-data-shares-in-item`_.

Parameters:
  • item_name (str) – The item name.

  • item_type (str) –

    The item type.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of the external data shares that exist for the specified item.

Return type:

pandas.DataFrame

sempy_labs.list_gateway_members(gateway: str | UUID) DataFrame

Lists gateway members of an on-premises gateway.

This is a wrapper function for the following API: Gateways - List Gateway Members.

Parameters:

gateway (str | UUID) – The gateway name or ID.

Returns:

A pandas dataframe showing a list of gateway members of an on-premises gateway.

Return type:

pandas.DataFrame

sempy_labs.list_gateway_role_assigments(gateway: str | UUID) DataFrame

Returns a list of gateway role assignments.

This is a wrapper function for the following API: Gateways - List Gateway Role Assignments.

Parameters:

gateway (str | UUID) – The gateway name or ID.

Returns:

A pandas dataframe showing a list of gateway role assignments.

Return type:

pandas.DataFrame

sempy_labs.list_gateways() DataFrame

Returns a list of all gateways the user has permission for, including on-premises, on-premises (personal mode), and virtual network gateways.

This is a wrapper function for the following API: Gateways - List Gateways.

Returns:

A pandas dataframe showing a list of all gateways the user has permission for, including on-premises, on-premises (personal mode), and virtual network gateways.

Return type:

pandas.DataFrame

sempy_labs.list_item_connections(item_name: str, item_type: str, workspace: str | None = None) DataFrame

Shows the list of connections that the specified item is connected to.

This is a wrapper function for the following API: Items - List Item Connections.

Parameters:
  • item_name (str) – The item name.

  • item_type (str) –

    The item type.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the list of connections that the specified item is connected to.

Return type:

pandas.DataFrame

sempy_labs.list_kql_databases(workspace: str | None = None) DataFrame

Shows the KQL databases within a workspace.

This is a wrapper function for the following API: Items - List KQL Databases.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the KQL databases within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_kql_querysets(workspace: str | None = None) DataFrame

Shows the KQL querysets within a workspace.

This is a wrapper function for the following API: Items - List KQL Querysets.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the KQL querysets within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_lakehouses(workspace: str | None = None) DataFrame

Shows the lakehouses within a workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the lakehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_managed_private_endpoints(workspace: str | None = None) DataFrame

Shows the managed private endpoints within a workspace.

This is a wrapper function for the following API: Managed Private Endpoints - List Workspace Managed Private Endpoints <https://learn.microsoft.com/rest/api/fabric/core/managed-private-endpoints/list-workspace-managed-private-endpoints>.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the managed private endpoints within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_mirrored_databases(workspace: str | None = None) DataFrame

Shows the mirrored databases within a workspace.

This is a wrapper function for the following API: Items - List Mirrored Databases.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the mirrored databases within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_mirrored_warehouses(workspace: str | None = None) DataFrame

Shows the mirrored warehouses within a workspace.

This is a wrapper function for the following API: Items - List Mirrored Warehouses.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the mirrored warehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_ml_experiments(workspace: str | None = None) DataFrame

Shows the ML experiments within a workspace.

This is a wrapper function for the following API: Items - List ML Experiments.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the ML models within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_ml_models(workspace: str | None = None) DataFrame

Shows the ML models within a workspace.

This is a wrapper function for the following API: Items - List ML Models.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the ML models within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_qso_settings(dataset: str | None = None, workspace: str | None = None) DataFrame

Shows the query scale out settings for a semantic model (or all semantic models within a workspace).

Parameters:
  • dataset (str, default=None) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the query scale out settings.

Return type:

pandas.DataFrame

sempy_labs.list_report_semantic_model_objects(dataset: str, workspace: str | None = None, extended: bool = False) DataFrame

Shows a list of semantic model objects (i.e. columns, measures, hierarchies) used in all reports which feed data from a given semantic model.

Note: As with all functions which rely on the ReportWrapper, this function requires the report(s) to be in the ‘PBIR’ format.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • extended (bool, default=False) – If True, adds an extra column called ‘Valid Semantic Model Object’ which identifies whether the semantic model object used in the report exists in the semantic model which feeds data to the report.

Returns:

  • pandas.DataFrame – A pandas dataframe showing a list of semantic model objects (i.e. columns, measures, hierarchies) used in all reports which feed data from

  • a given semantic model.

sempy_labs.list_reports_using_semantic_model(dataset: str, workspace: str | None = None) DataFrame

Shows a list of all the reports (in all workspaces) which use a given semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the reports which use a given semantic model.

Return type:

pandas.DataFrame

sempy_labs.list_semantic_model_errors(dataset: str | UUID, workspace: str | UUID | None) DataFrame

Shows a list of a semantic model’s errors and their error messages (if they exist).

Parameters:
  • dataset (str | UUID) – Name or ID of the semantic model.

  • workspace (str | UUID, default=None) – The Fabric workspace name or ID. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of the errors and error messages for a given semantic model.

Return type:

pandas.DataFrame

sempy_labs.list_semantic_model_object_report_usage(dataset: str, workspace: str | None = None, include_dependencies: bool = False, extended: bool = False) DataFrame

Shows a list of semantic model objects and how many times they are referenced in all reports which rely on this semantic model.

Requirement: Reports must be in the PBIR format.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • include_dependencies (bool, default=False) – If True, includes measure dependencies.

  • extended (bool, default=False) – If True, adds columns ‘Total Size’, ‘Data Size’, ‘Dictionary Size’, ‘Hierarchy Size’ based on Vertipaq statistics.

Returns:

A pandas dataframe showing a list of semantic model objects and how many times they are referenced in all reports which rely on this semantic model. By default, the dataframe is sorted descending by ‘Report Usage Count’.

Return type:

pandas.DataFrame

sempy_labs.list_semantic_model_objects(dataset: str, workspace: str | None = None) DataFrame

Shows a list of semantic model objects.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of objects in the semantic model

Return type:

pandas.DataFrame

sempy_labs.list_server_properties(workspace: str | UUID | None = None) DataFrame

Lists the properties of the Analysis Services instance.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of the server properties.

Return type:

pandas.DataFrame

sempy_labs.list_shortcuts(lakehouse: str | None = None, workspace: str | None = None) DataFrame

Shows all shortcuts which exist in a Fabric lakehouse and their properties.

Parameters:
  • lakehouse (str, default=None) – The Fabric lakehouse name. Defaults to None which resolves to the lakehouse attached to the notebook.

  • workspace (str, default=None) – The name of the Fabric workspace in which lakehouse resides. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing all the shortcuts which exist in the specified lakehouse.

Return type:

pandas.DataFrame

sempy_labs.list_sql_endpoints(workspace: str | None = None) DataFrame

Shows the SQL endpoints within a workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the SQL endpoints within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_storage_account_files(storage_account: str, container: str = 'power-bi-backup') DataFrame

Shows a list of files within an ADLS Gen2 storage account.

Parameters:
  • storage_account (str) – The name of the ADLS Gen2 storage account.

  • container (str, default='power-bi-backup') – The name of the container.

Returns:

A pandas dataframe showing a list of files contained within an ADLS Gen2 storage account.

Return type:

pandas.DataFrame

sempy_labs.list_upstream_dataflows(dataflow: str | UUID, workspace: str | None = None) DataFrame

Shows a list of upstream dataflows for the specified dataflow.

This is a wrapper function for the following API: Dataflows - Get Upstream Dataflows In Group.

Parameters:
  • dataflow (str | UUID) – Name or UUID of the dataflow.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing a list of upstream dataflows for the specified dataflow.

Return type:

pandas.DataFrame

sempy_labs.list_warehouses(workspace: str | None = None) DataFrame

Shows the warehouses within a workspace.

This is a wrapper function for the following API: Items - List Warehouses.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the warehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_workloads(capacity_name: str) DataFrame

Returns the current state of the specified capacity workloads. If a workload is enabled, the percentage of maximum memory that the workload can consume is also returned.

This is a wrapper function for the following API: Capacities - Get Workloads.

Parameters:

capacity_name (str) – The capacity name.

Returns:

A pandas dataframe showing the current state of the specified capacity workloads.

Return type:

pandas.DataFrame

sempy_labs.list_workspace_role_assignments(workspace: str | None = None) DataFrame

Shows the members of a given workspace.

This is a wrapper function for the following API: Workspaces - List Workspace Role Assignments.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the members of a given workspace and their roles.

Return type:

pandas.DataFrame

sempy_labs.list_workspace_users(workspace: str | None = None) DataFrame

A list of all the users of a workspace and their roles.

This is a wrapper function for the following API: Workspaces - List Workspace Role Assignments.

Parameters:

workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe the users of a workspace and their properties.

Return type:

pandas.DataFrame

sempy_labs.measure_dependency_tree(dataset: str, measure_name: str, workspace: str | None = None)

Prints a measure dependency tree of all dependent objects for a measure in a semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • measure_name (str) – Name of the measure.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.migrate_access_settings(source_capacity: str, target_capacity: str)

This function migrates the access settings from a source capacity to a target capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_capacities(azure_subscription_id: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str, resource_group: str | dict, capacities: str | List[str] | None = None, use_existing_rg_for_A_sku: bool = True, p_sku_only: bool = True)

This function creates new Fabric capacities for given A or P sku capacities and reassigns their workspaces to the newly created capacity.

Parameters:
  • azure_subscription_id (str) – The Azure subscription ID.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

  • resource_group (str | dict) – The name of the Azure resource group. For A skus, this parameter will be ignored and the resource group used for the F sku will be the same as the A sku’s resource group. For P skus, if this parameter is a string, it will use that resource group for all of the newly created F skus. If this parameter is a dictionary, it will use that mapping (capacity name -> resource group) for creating capacities with the mapped resource groups.

  • capacities (str | List[str], default=None) – The capacity(ies) to migrate from A/P -> F sku. Defaults to None which migrates all accessible A/P sku capacities to F skus.

  • use_existing_rg_for_A_sku (bool, default=True) – If True, the F sku inherits the resource group from the A sku (for A sku migrations)

  • p_sku_only (bool, default=True) – If set to True, only migrates P skus. If set to False, migrates both P and A skus.

sempy_labs.migrate_capacity_settings(source_capacity: str, target_capacity: str)

This function migrates a capacity’s settings to another capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_delegated_tenant_settings(source_capacity: str, target_capacity: str)

This function migrates the delegated tenant settings from a source capacity to a target capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_disaster_recovery_settings(source_capacity: str, target_capacity: str)

This function migrates a capacity’s disaster recovery settings to another capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_fabric_trial_capacity(azure_subscription_id: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str, resource_group: str, source_capacity: str, target_capacity: str, target_capacity_sku: str = 'F64', target_capacity_admin_members: str | List[str] | None = None)

This function migrates a Fabric trial capacity to a Fabric capacity. If the ‘target_capacity’ does not exist, it is created with the relevant target capacity parameters (sku, region, admin members).

Parameters:
  • azure_subscription_id (str) – The Azure subscription ID.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

  • resource_group (str) – The name of the Azure resource group.

  • source_capacity (str) – The name of the Fabric trial capacity.

  • target_capacity (str) – The name of the new Fabric capacity (F SKU). If this capacity does not exist, it will be created.

  • target_capacity_sku (str, default="F64") – If the target capacity does not exist, this property sets the SKU size for the target capacity.

  • target_capacity_admin_members (str, default=None) – If the target capacity does not exist, this property sets the admin members for the target capacity. Defaults to None which resolves to the admin members on the Trial SKU.

sempy_labs.migrate_notification_settings(source_capacity: str, target_capacity: str)

This function migrates the notification settings from a source capacity to a target capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_spark_settings(source_capacity: str, target_capacity: str)

This function migrates a capacity’s spark settings to another capacity.

Requirement: The target capacity must be able to accomodate the spark pools being migrated from the source capacity.

Parameters:
  • source_capacity (str) – Name of the source capacity.

  • target_capacity (str) – Name of the target capacity.

sempy_labs.migrate_workspaces(source_capacity: str, target_capacity: str, workspaces: str | List[str] | None = None)

This function migrates the workspace(s) from one capacity to another capacity. Limitation: source & target capacities must be in the same region. If not all the workspaces succesfully migrated to the target capacity, the migrated workspaces will rollback to be assigned to the source capacity.

Parameters:
  • source_capacity (str) – Name of the source Fabric capacity.

  • target_capacity (str) – Name of the target/destination Fabric capacity.

  • workspaces (str | List[str], default=None) – The name of the workspace(s) specified will be reassigned from the source capacity to the target capacity. Defaults to None which will reassign all workspaces in the source capacity to the target capacity.

sempy_labs.model_bpa_rules(dependencies: DataFrame | None = None, **kwargs) DataFrame

Shows the default rules for the semantic model BPA used by the run_model_bpa function.

Parameters:

dependencies (pd.DataFrame, default=None) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.

Returns:

A pandas dataframe containing the default rules for the run_model_bpa function.

Return type:

pandas.DataFrame

sempy_labs.patch_workload(capacity_name: str, workload_name: str, state: str | None = None, max_memory_percentage: int | None = None)

Changes the state of a specific workload to Enabled or Disabled. When enabling a workload, specify the percentage of maximum memory that the workload can consume.

This is a wrapper function for the following API: Capacities - Patch Workload.

Parameters:
  • capacity_name (str) – The capacity name.

  • workload_name (str) – The workload name.

  • state (str, default=None) – The capacity workload state.

  • max_memory_percentage (int, default=None) – The percentage of the maximum memory that a workload can consume (set by the user).

sempy_labs.provision_workspace_identity(workspace: str | None = None)

Provisions a workspace identity for a workspace.

This is a wrapper function for the following API: Workspaces - Provision Identity.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.publish_environment(environment: str, workspace: str | None = None)

Publishes a Fabric environment.

Parameters:
  • environment (str) – Name of the environment.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.qso_sync(dataset: str, workspace: str | None = None)

Triggers a query scale-out sync of read-only replicas for the specified dataset from the specified workspace.

This is a wrapper function for the following API: Datasets - Trigger Query Scale Out Sync In Group.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.qso_sync_status(dataset: str, workspace: str | None = None) Tuple[DataFrame, DataFrame]

Returns the query scale-out sync status for the specified dataset from the specified workspace.

This is a wrapper function for the following API: Datasets - Get Query Scale Out Sync Status In Group.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

2 pandas dataframes showing the query scale-out sync status.

Return type:

Tuple[pandas.DataFrame, pandas.DataFrame]

sempy_labs.refresh_semantic_model(dataset: str | UUID, tables: str | List[str] | None = None, partitions: str | List[str] | None = None, refresh_type: str = 'full', retry_count: int = 0, apply_refresh_policy: bool = True, max_parallelism: int = 10, workspace: str | None = None, visualize: bool = False, commit_mode: str = 'transactional') DataFrame | None

Refreshes a semantic model.

Parameters:
  • dataset (str | UUID) – Name or ID of the semantic model.

  • tables (str, List[str], default=None) – A string or a list of tables to refresh.

  • partitions (str, List[str], default=None) – A string or a list of partitions to refresh. Partitions must be formatted as such: ‘Table Name’[Partition Name].

  • refresh_type (str, default="full") – The type of processing to perform. Types align with the TMSL refresh command types: full, clearValues, calculate, dataOnly, automatic, and defragment. The add type isn’t supported. Defaults to “full”.

  • retry_count (int, default=0) – Number of times the operation retries before failing.

  • apply_refresh_policy (bool, default=True) – If an incremental refresh policy is defined, determines whether to apply the policy. Modes are true or false. If the policy isn’t applied, the full process leaves partition definitions unchanged, and fully refreshes all partitions in the table. If commitMode is transactional, applyRefreshPolicy can be true or false. If commitMode is partialBatch, applyRefreshPolicy of true isn’t supported, and applyRefreshPolicy must be set to false.

  • max_parallelism (int, default=10) – Determines the maximum number of threads that can run the processing commands in parallel. This value aligns with the MaxParallelism property that can be set in the TMSL Sequence command or by using other methods. Defaults to 10.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • visualize (bool, default=False) – If True, displays a Gantt chart showing the refresh statistics for each table/partition.

  • commit_mode (str, default="transactional") – Determines whether to commit objects in batches or only when complete. Modes are “transactional” and “partialBatch”. Defaults to “transactional”.

Returns:

If ‘visualize’ is set to True, returns a pandas dataframe showing the SSAS trace output used to generate the visualization.

Return type:

pandas.DataFrame | None

sempy_labs.resolve_capacity_id(capacity_name: str | None = None) UUID

Obtains the capacity Id for a given capacity name.

Parameters:

capacity_name (str, default=None) – The capacity name. Defaults to None which resolves to the capacity id of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

Returns:

The capacity Id.

Return type:

UUID

sempy_labs.resolve_capacity_name(capacity_id: UUID | None = None) str

Obtains the capacity name for a given capacity Id.

Parameters:

capacity_id (UUID, default=None) – The capacity Id. Defaults to None which resolves to the capacity name of the workspace of the attached lakehouse or if no lakehouse attached, resolves to the capacity name of the workspace of the notebook.

Returns:

The capacity name.

Return type:

str

sempy_labs.resolve_dataset_from_report(report: str, workspace: str | None = None) Tuple[UUID, str, UUID, str]

Obtains the basic semantic model properties from which the report’s data is sourced.

Parameters:
  • report (str) – The name of the Power BI report.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The semantic model UUID, semantic model name, semantic model workspace UUID, semantic model workspace name

Return type:

Tuple[UUID, str, UUID, str]

sempy_labs.resolve_dataset_id(dataset: str | UUID, workspace: str | None = None) UUID

Obtains the ID of the semantic model.

Parameters:
  • dataset (str | UUID) – The name or ID of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The ID of the semantic model.

Return type:

UUID

sempy_labs.resolve_dataset_name(dataset_id: UUID, workspace: str | None = None) str

Obtains the name of the semantic model.

Parameters:
  • dataset_id (UUID) – The name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The name of the semantic model.

Return type:

str

sempy_labs.resolve_environment_id(environment: str, workspace: str | None = None) UUID

Obtains the environment Id for a given environment.

Parameters:

environment (str) – Name of the environment.

Returns:

The environment Id.

Return type:

UUID

sempy_labs.resolve_item_type(item_id: UUID, workspace: str | None = None) str

Obtains the item type for a given Fabric Item Id within a Fabric workspace.

Parameters:
  • item_id (UUID) – The item/artifact Id.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The item type for the item Id.

Return type:

str

sempy_labs.resolve_lakehouse_id(lakehouse: str, workspace: str | None = None) UUID

Obtains the ID of the Fabric lakehouse.

Parameters:
  • lakehouse (str) – The name of the Fabric lakehouse.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The ID of the Fabric lakehouse.

Return type:

UUID

sempy_labs.resolve_lakehouse_name(lakehouse_id: UUID | None = None, workspace: str | None = None) str

Obtains the name of the Fabric lakehouse.

Parameters:
  • lakehouse_id (UUID, default=None) – The name of the Fabric lakehouse. Defaults to None which resolves to the lakehouse attached to the notebook.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The name of the Fabric lakehouse.

Return type:

str

sempy_labs.resolve_report_id(report: str, workspace: str | None = None) UUID

Obtains the ID of the Power BI report.

Parameters:
  • report (str) – The name of the Power BI report.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The ID of the Power BI report.

Return type:

UUID

sempy_labs.resolve_report_name(report_id: UUID, workspace: str | None = None) str

Obtains the name of the Power BI report.

Parameters:
  • report_id (UUID) – The name of the Power BI report.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

The name of the Power BI report.

Return type:

str

sempy_labs.resolve_warehouse_id(warehouse: str, workspace: str | None) UUID

Obtains the Id for a given warehouse.

Parameters:

warehouse (str) – The warehouse name

Returns:

The warehouse Id.

Return type:

UUID

sempy_labs.resolve_workspace_capacity(workspace: str | None = None) Tuple[UUID, str]

Obtains the capacity Id and capacity name for a given workspace.

Parameters:

workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

capacity Id; capacity came.

Return type:

Tuple[UUID, str]

sempy_labs.restore_semantic_model(dataset: str, file_path: str, allow_overwrite: bool = True, ignore_incompatibilities: bool = True, force_restore: bool = False, workspace: str | None = None)

Restores a semantic model based on a backup (.abf) file within the ADLS Gen2 storage account connected to the workspace.

Parameters:
  • dataset (str) – Name of the semantic model.

  • file_path (str) – The location in which to backup the semantic model. Must end in ‘.abf’. Example 1: file_path = ‘MyModel.abf’ Example 2: file_path = ‘MyFolder/MyModel.abf’

  • allow_overwrite (bool, default=True) – If True, overwrites backup files of the same name. If False, the file you are saving cannot have the same name as a file that already exists in the same location.

  • ignore_incompatibilities (bool, default=True) – If True, ignores incompatibilities between Azure Analysis Services and Power BI Premium.

  • force_restore (bool, default=False) – If True, restores the semantic model with the existing semantic model unloaded and offline.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.resume_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

This function resumes a Fabric capacity.

This is a wrapper function for the following API: Fabric Capacities - Resume.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • resource_group (str) – The name of the Azure resource group.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

sempy_labs.revoke_external_data_share(external_data_share_id: UUID, item_name: str, item_type: str, workspace: str | None = None)

Revokes the specified external data share. Note: This action cannot be undone.

This is a wrapper function for the following API: `External Data Shares - Revoke External Data Share <https://learn.microsoft.com/rest/api/fabric/core/external-data-shares/revoke-external-data-share`_.

Parameters:
  • external_data_share_id (UUID) – The external data share ID.

  • item_name (str) – The item name.

  • item_type (str) –

    The item type.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.run_model_bpa(dataset: str | UUID, rules: DataFrame | None = None, workspace: str | None = None, export: bool = False, return_dataframe: bool = False, extended: bool = False, language: str | None = None, **kwargs)

Displays an HTML visualization of the results of the Best Practice Analyzer scan for a semantic model.

Parameters:
  • dataset (str | UUID) – Name or ID of the semantic model.

  • rules (pandas.DataFrame, default=None) – A pandas dataframe containing rules to be evaluated.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • export (bool, default=False) – If True, exports the resulting dataframe to a delta table in the lakehouse attached to the notebook.

  • return_dataframe (bool, default=False) – If True, returns a pandas dataframe instead of the visualization.

  • extended (bool, default=False) – If True, runs the set_vertipaq_annotations function to collect Vertipaq Analyzer statistics to be used in the analysis of the semantic model.

  • language (str, default=None) – Specifying a language name or code (i.e. ‘it-IT’ for Italian) will auto-translate the Category, Rule Name and Description into the specified language. Defaults to None which resolves to English.

Returns:

A pandas dataframe in HTML format showing semantic model objects which violated the best practice analyzer rules.

Return type:

pandas.DataFrame

sempy_labs.run_model_bpa_bulk(rules: DataFrame | None = None, extended: bool = False, language: str | None = None, workspace: str | List[str] | None = None, skip_models: str | List[str] | None = ['ModelBPA', 'Fabric Capacity Metrics'], skip_models_in_workspace: dict | None = None)

Runs the semantic model Best Practice Analyzer across all semantic models in a workspace (or all accessible workspaces). Saves (appends) the results to the ‘modelbparesults’ delta table in the lakehouse attached to the notebook. Default semantic models are skipped in this analysis.

Parameters:
  • rules (pandas.DataFrame, default=None) – A pandas dataframe containing rules to be evaluated. Based on the format of the dataframe produced by the model_bpa_rules function.

  • extended (bool, default=False) – If True, runs the set_vertipaq_annotations function to collect Vertipaq Analyzer statistics to be used in the analysis of the semantic model.

  • language (str, default=None) – The language (code) in which the rules will appear. For example, specifying ‘it-IT’ will show the Rule Name, Category and Description in Italian. Defaults to None which resolves to English.

  • workspace (str | List[str], default=None) – The workspace or list of workspaces to scan. Defaults to None which scans all accessible workspaces.

  • skip_models (str | List[str], default=['ModelBPA', 'Fabric Capacity Metrics']) – The semantic models to always skip when running this analysis.

  • skip_models_in_workspace (dict, default=None) –

    A dictionary showing specific semantic models within specific workspaces to skip. See the example below: {

    ”Workspace A”: [“Dataset1”, “Dataset2”], “Workspace B”: [“Dataset5”, “Dataset 8”],

    }

sempy_labs.save_as_delta_table(dataframe, delta_table_name: str, write_mode: str, merge_schema: bool = False, schema: dict | None = None, lakehouse: str | None = None, workspace: str | None = None)

Saves a pandas dataframe as a delta table in a Fabric lakehouse.

Parameters:
  • dataframe (pandas.DataFrame) – The dataframe to be saved as a delta table.

  • delta_table_name (str) – The name of the delta table.

  • write_mode (str) – The write mode for the save operation. Options: ‘append’, ‘overwrite’.

  • merge_schema (bool, default=False) – Merges the schemas of the dataframe to the delta table.

  • schema (dict, default=None) – A dictionary showing the schema of the columns and their data types.

  • lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.set_qso(dataset: str, auto_sync: bool = True, max_read_only_replicas: int = -1, workspace: str | None = None) DataFrame

Sets the query scale out settings for a semantic model.

This is a wrapper function for the following API: Datasets - Update Dataset In Group.

Parameters:
  • dataset (str) – Name of the semantic model.

  • auto_sync (bool, default=True) – Whether the semantic model automatically syncs read-only replicas.

  • max_read_only_replicas (int, default=-1) – To enable semantic model scale-out, set max_read_only_replicas to -1, or any non-0 value. A value of -1 allows Power BI to create as many read-only replicas as your Power BI capacity supports. You can also explicitly set the replica count to a value lower than that of the capacity maximum. Setting max_read_only_replicas to -1 is recommended.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

A pandas dataframe showing the current query scale-out settings.

Return type:

pandas.DataFrame

sempy_labs.set_semantic_model_storage_format(dataset: str, storage_format: str, workspace: str | None = None)

Sets the semantic model storage format.

Parameters:
  • dataset (str) – Name of the semantic model.

  • storage_format (str) – The storage format for the semantic model. Valid options: ‘Large’, ‘Small’.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.set_workspace_default_storage_format(storage_format: str, workspace: str | None = None)

Sets the default storage format for semantic models within a workspace.

Parameters:
  • storage_format (str) – The storage format for the semantic model. Valid options: ‘Large’, ‘Small’.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.start_mirroring(mirrored_database: str, workspace: str | None = None)

Starts the mirroring for a database.

This is a wrapper function for the following API: Mirroring - Start Mirroring.

Parameters:
  • mirrored_database (str) – Name of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.stop_mirroring(mirrored_database: str, workspace: str | None = None)

Stops the mirroring for a database.

This is a wrapper function for the following API: Mirroring - Stop Mirroring.

Parameters:
  • mirrored_database (str) – Name of the mirrored database.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.suspend_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

This function suspends a Fabric capacity.

This is a wrapper function for the following API: Fabric Capacities - Suspend.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • resource_group (str) – The name of the Azure resource group.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

sempy_labs.translate_semantic_model(dataset: str, languages: str | List[str], exclude_characters: str | None = None, workspace: str | None = None) DataFrame

Translates names, descriptions, display folders for all objects in a semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • languages (str, List[str]) – The language code(s) in which to translate the semantic model.

  • exclude_characters (str) – A string specifying characters which will be replaced by a space in the translation text when sent to the translation service.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

Returns:

Shows a pandas dataframe which displays all of the translations in the semantic model.

Return type:

pandas.DataFrame

sempy_labs.unassign_workspace_from_capacity(workspace: str | None = None)

Unassigns a workspace from its assigned capacity.

This is a wrapper function for the following API: Workspaces - Unassign From Capacity.

Parameters:

workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_custom_pool(pool_name: str, node_size: str | None = None, min_node_count: int | None = None, max_node_count: int | None = None, min_executors: int | None = None, max_executors: int | None = None, node_family: str | None = None, auto_scale_enabled: bool | None = None, dynamic_executor_allocation_enabled: bool | None = None, workspace: str | None = None)

Updates the properties of a custom pool within a workspace.

This is a wrapper function for the following API: Custom Pools - Update Workspace Custom Pool.

Parameters:
  • pool_name (str) – The custom pool name.

  • node_size (str, default=None) –

    The node size. Defaults to None which keeps the existing property setting.

  • min_node_count (int, default=None) –

    The minimum node count. Defaults to None which keeps the existing property setting.

  • max_node_count (int, default=None) – The maximum node count. Defaults to None which keeps the existing property setting.

  • min_executors (int, default=None) –

    The minimum executors. Defaults to None which keeps the existing property setting.

  • max_executors (int, default=None) – The maximum executors. Defaults to None which keeps the existing property setting.

  • node_family (str, default=None) –

    The node family. Defaults to None which keeps the existing property setting.

  • auto_scale_enabled (bool, default=None) –

    The status of auto scale. Defaults to None which keeps the existing property setting.

  • dynamic_executor_allocation_enabled (bool, default=None) –

    The status of the dynamic executor allocation. Defaults to None which keeps the existing property setting.

  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str, sku: str | None = None, admin_members: str | List[str] | None = None, tags: dict | None = None)

This function updates a Fabric capacity’s properties.

This is a wrapper function for the following API: Fabric Capacities - Update.

Parameters:
  • capacity_name (str) – Name of the Fabric capacity.

  • azure_subscription_id (str) – The Azure subscription ID.

  • resource_group (str) – The name of the Azure resource group.

  • key_vault_uri (str) –

    The name of the Azure key vault URI. Example: “https://<Key Vault Name>.vault.azure.net/”

  • key_vault_tenant_id (str) – The name of the Azure key vault secret storing the Tenant ID.

  • key_vault_client_id (str) – The name of the Azure key vault secret storing the Client ID.

  • key_vault_client_secret (str) – The name of the Azure key vault secret storing the Client Secret.

  • sku (str, default=None) –

    The sku size of the Fabric capacity.

  • admin_members (str | List[str], default=None) – The email address(es) of the admin(s) of the Fabric capacity.

  • tags (dict, default=None) – Tag(s) to add to the capacity. Example: {‘tagName’: ‘tagValue’}.

sempy_labs.update_from_git(remote_commit_hash: str, conflict_resolution_policy: str, workspace_head: str | None = None, allow_override: bool = False, workspace: str | None = None)

Updates the workspace with commits pushed to the connected branch.

This is a wrapper function for the following API: Git - Update From Git.

Parameters:
  • remote_commit_hash (str) – Remote full SHA commit hash.

  • confilict_resolution_policy (str) – The conflict resolution policy.

  • workspace_head (str) – Full SHA hash that the workspace is synced to. This value may be null only after Initialize Connection. In other cases, the system will validate that the given value is aligned with the head known to the system.

  • allow_override (bool, default=False) – User consent to override incoming items during the update from Git process. When incoming items are present and the allow override items is not specified or is provided as false, the update operation will not start. Default value is false.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_item(item_type: str, current_name: str, new_name: str, description: str | None = None, workspace: str | None = None)

Updates the name/description of a Fabric item.

Parameters:
  • item_type (str) – Type of item to update.

  • current_name (str) – The current name of the item.

  • new_name (str) – The new name of the item.

  • description (str, default=None) – A description of the item.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_mirrored_database_definition(mirrored_database: str, mirrored_database_content: dict, workspace: str | None = None)

Updates an existing notebook with a new definition.

Parameters:
  • mirrored_database (str) – The name of the mirrored database to be created.

  • mirrored_database_content (dict) – The mirrored database definition (not in Base64 format).

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_notebook_definition(name: str, notebook_content: str, workspace: str | None = None)

Updates an existing notebook with a new definition.

Parameters:
  • name (str) – The name of the notebook to be updated.

  • notebook_content (str) – The Jupyter notebook content (not in Base64 format).

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_on_premises_gateway(gateway: str, allow_cloud_connection_refresh: bool | None = None, allow_custom_connectors: bool | None = None, load_balancing_setting: str | None = None)

Updates an on-premises gateway.

This is a wrapper function for the following API: Gateways - Update Gateway.

Parameters:
  • gateway (str | UUID) – The gateway name or ID.

  • allow_cloud_connection_refresh (bool, default=None) – Whether to allow cloud connections to refresh through this on-premises gateway. True - Allow, False - Do not allow.

  • allow_custom_connectors (bool, default=None) – Whether to allow custom connectors to be used with this on-premises gateway. True - Allow, False - Do not allow.

  • load_balancing_setting (str, default=None) – The load balancing setting of the on-premises gateway.

sempy_labs.update_semantic_model_from_bim(dataset: str, bim_file: dict, workspace: str | None = None)

Updates a semantic model definition based on a Model.bim file.

This is a wrapper function for the following API: Items - Update Semantic Model Definition.

Parameters:
  • dataset (str) – Name of the semantic model.

  • bim_file (dict) – The model.bim file.

  • workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_spark_settings(automatic_log_enabled: bool | None = None, high_concurrency_enabled: bool | None = None, customize_compute_enabled: bool | None = None, default_pool_name: str | None = None, max_node_count: int | None = None, max_executors: int | None = None, environment_name: str | None = None, runtime_version: str | None = None, workspace: str | None = None)

Updates the spark settings for a workspace.

This is a wrapper function for the following API: Workspace Settings - Update Spark Settings.

Parameters:
  • automatic_log_enabled (bool, default=None) – The status of the automatic log. Defaults to None which keeps the existing property setting.

  • high_concurrency_enabled (bool, default=None) – The status of the high concurrency for notebook interactive run. Defaults to None which keeps the existing property setting.

  • customize_compute_enabled (bool, default=None) – Customize compute configurations for items. Defaults to None which keeps the existing property setting.

  • default_pool_name (str, default=None) – Default pool for workspace. Defaults to None which keeps the existing property setting.

  • max_node_count (int, default=None) – The maximum node count. Defaults to None which keeps the existing property setting.

  • max_executors (int, default=None) – The maximum executors. Defaults to None which keeps the existing property setting.

  • environment_name (str, default=None) – The name of the default environment. Empty string indicated there is no workspace default environment Defaults to None which keeps the existing property setting.

  • runtime_version (str, default=None) – The runtime version. Defaults to None which keeps the existing property setting.

  • workspace (str, default=None) – The name of the Fabric workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.update_vnet_gateway(gateway: str, capacity: str | UUID, inactivity_minutes_before_sleep: int | None = None, number_of_member_gateways: int | None = None)

Updates a virtual network gateway.

This is a wrapper function for the following API: Gateways - Update Gateway.

Parameters:
  • gateway (str | UUID) – The gateway name or ID.

  • capacity (str | UUID) – The capacity name or ID.

  • inactivity_minutes_before_sleep (int, default=None) – The minutes of inactivity before the virtual network gateway goes into auto-sleep. Must be one of the following values: 30, 60, 90, 120, 150, 240, 360, 480, 720, 1440.

  • number_of_member_gateways (int, default=None) – The number of member gateways. A number between 1 and 7.

sempy_labs.update_workspace_user(email_address: str, role_name: str, principal_type: str | None = 'User', workspace: str | None = None)

Updates a user’s role within a workspace.

This is a wrapper function for the following API: Groups - Update Group User.

Parameters:
  • email_address (str) – The email address of the user.

  • role_name (str) –

    The role of the user within the workspace.

  • principal_type (str, default='User') –

    The principal type.

  • workspace (str, default=None) – The name of the workspace. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

sempy_labs.vertipaq_analyzer(dataset: str, workspace: str | None = None, export: str | None = None, read_stats_from_data: bool = False, **kwargs)

Displays an HTML visualization of the Vertipaq Analyzer statistics from a semantic model.

Parameters:
  • dataset (str) – Name of the semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the semantic model exists. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • export (str, default=None) – Specifying ‘zip’ will export the results to a zip file in your lakehouse (which can be imported using the import_vertipaq_analyzer function. Specifying ‘table’ will export the results to delta tables (appended) in your lakehouse. Default value: None.

  • read_stats_from_data (bool, default=False) – Setting this parameter to true has the function get Column Cardinality and Missing Rows using DAX (Direct Lake semantic models achieve this using a Spark query to the lakehouse).