sempy_labs package

Subpackages

Module contents

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

Bases: ConnectBase

class sempy_labs.ConnectSQLDatabase(sql_database: str | UUID, workspace: str | UUID | None = None, timeout: int = 30)

Bases: ConnectBase

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

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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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: str | UUID, workspace: str | UUID | None = None, **kwargs)

Assigns a workspace to a capacity.

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

Parameters:
  • capacity (str | uuid.UUID) – The name or ID of the capacity.

  • workspace (str | uuid.UUID, default=None) – The name or ID 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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID, file_path: str, allow_overwrite: bool = True, apply_compression: bool = True, workspace: str | UUID | None = None)

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

Parameters:
  • dataset (str | uuid.UUID) – Name or ID 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 | uuid.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.

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.

Service Principal Authentication is supported (see here for examples).

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

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

  • workspace (str | uuid.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 | UUID, request_id: str | None = None, workspace: str | UUID | None = None)

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

Parameters:
  • dataset (str | uuid.UUID) – Name or ID 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 | uuid.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.

sempy_labs.check_fabric_capacity_name_availablility(capacity_name: str, azure_subscription_id: str, region: str, **kwargs) bool

This function updates a Fabric capacity’s properties.

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

Service Principal Authentication is required (see here for examples).

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

  • azure_subscription_id (str) – The Azure subscription ID.

  • region (str) – The region name.

Returns:

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

Return type:

bool

sempy_labs.check_resource_group_existence(azure_subscription_id: str, resource_group: str) bool

Checks whether a resource group exists.

This is a wrapper function for the following API: Resource Groups - Check Existence.

Service Principal Authentication is required (see here for examples).

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

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

Returns:

True/False indicating if the resource group exists or not.

Return type:

bool

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

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

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

  • workspace (str | uuid.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.

sempy_labs.commit_to_git(comment: str, item_ids: UUID | List[UUID] = None, workspace: str | UUID | 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 (uuid.UUID | List[uuid.UUID], default=None) – A list of item Ids to commit to Git. Defaults to None which commits all items to Git.

  • workspace (str | uuid.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.

sempy_labs.connect_workspace_to_azure_dev_ops(organization_name: str, project_name: str, repository_name: str, branch_name: str, directory_name: str, workspace: str | UUID | None = None)

Connects a workspace to an Azure DevOps 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.

  • workspace (str | uuid.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.

sempy_labs.connect_workspace_to_github(owner_name: str, repository_name: str, branch_name: str, directory_name: str, connection_id: UUID, source: str = 'ConfiguredConnection', workspace: str | UUID | None = None)

Connects a workspace to a GitHub git repository.

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

Parameters:
  • owner_name (str) – The owner name.

  • repository_name (str) – The repository name.

  • branch_name (str) – The branch name.

  • directory_name (str) – The directory name.

  • source (str, default="ConfiguredConnection") – The Git credentials source.

  • connection_id (uuid.UUID) – The object ID of the connection.

  • workspace (str | uuid.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.

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 | None = None, schema: str | None = None) str

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

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

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

  • delta_table_name (str, default=None) – Name of the delta table name.

  • schema (str, default=None) – The schema of the delta table.

Returns:

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

Return type:

str

sempy_labs.create_blank_semantic_model(dataset: str, compatibility_level: int = 1605, workspace: str | UUID | 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 | uuid.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.

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

Service Principal Authentication is supported (see here for examples).

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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID | 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 | uuid.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.

sempy_labs.create_environment(environment: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

sempy_labs.create_eventhouse(name: str, definition: dict | None, description: str | None = None, workspace: str | UUID | 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.

  • definition (dict) – The definition (EventhouseProperties.json) of the eventhouse.

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

  • workspace (str | uuid.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.

sempy_labs.create_eventstream(name: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

sempy_labs.create_external_data_share(item_name: str, item_type: str, paths: str | List[str], recipient: str, workspace: str | UUID | 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 | uuid.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.

sempy_labs.create_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str, region: str, sku: str, admin_members: str | List[str], tags: dict | None = None, **kwargs)

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.

Service Principal Authentication is required (see here for examples).

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.

  • 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_graphql_api(name: str, description: str | None = None, workspace: str | UUID | None = None)

Creates a GraphQL API.

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

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

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

  • workspace (str | uuid.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.

sempy_labs.create_item_schedule_cron(item: str | UUID, type: str, start_date_time: str, end_date_time: str, local_time_zone: str, job_type: str = 'DefaultJob', interval_minutes: int = 10, enabled: bool = True, workspace: str | UUID | None = None)

Create a new schedule for an item based on a chronological time.

This is a wrapper function for the following API: Job Scheduler - Create Item Schedule.

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

  • type (str) – The item type. If specifying the item name as the item, the item type is required.

  • start_date_time (str) – The start date and time of the schedule. Example: “2024-04-28T00:00:00”.

  • end_date_time (str) – The end date and time of the schedule. Must be later than the start_date_time. Example: “2024-04-30T23:59:00”.

  • local_time_zone (str) – The time zone of the schedule. Example: “Central Standard Time”.

  • job_type (str, default="DefaultJob") – The job type.

  • interval_minutes (int, default=10) – The schedule interval (in minutes).

  • enabled (bool, default=True) – Whether the schedule is enabled.

  • workspace (str | uuid.UUID, default=None) – The 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.

sempy_labs.create_item_schedule_daily(item: str | UUID, type: str, start_date_time: str, end_date_time: str, local_time_zone: str, times: List[str], job_type: str = 'DefaultJob', enabled: bool = True, workspace: str | UUID | None = None)

Create a new daily schedule for an item.

This is a wrapper function for the following API: Job Scheduler - Create Item Schedule.

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

  • type (str) –

    The item type. If specifying the item name as the item, the item type is required.

  • start_date_time (str) – The start date and time of the schedule. Example: “2024-04-28T00:00:00”.

  • end_date_time (str) – The end date and time of the schedule. Must be later than the start_date_time. Example: “2024-04-30T23:59:00”.

  • local_time_zone (str) –

    The time zone of the schedule. Example: “Central Standard Time”.

  • times (List[str]) – A list of time slots in hh:mm format, at most 100 elements are allowed. Example: [“00:00”, “12:00”].

  • job_type (str, default="DefaultJob") – The job type.

  • enabled (bool, default=True) – Whether the schedule is enabled.

  • workspace (str | uuid.UUID, default=None) – The 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.

sempy_labs.create_item_schedule_weekly(item: str | UUID, type: str, start_date_time: str, end_date_time: str, local_time_zone: str, times: List[str], weekdays: List[str], job_type: str = 'DefaultJob', enabled: bool = True, workspace: str | UUID | None = None)

Create a new daily schedule for an item.

This is a wrapper function for the following API: Job Scheduler - Create Item Schedule.

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

  • type (str) –

    The item type. If specifying the item name as the item, the item type is required.

  • start_date_time (str) – The start date and time of the schedule. Example: “2024-04-28T00:00:00”.

  • end_date_time (str) – The end date and time of the schedule. Must be later than the start_date_time. Example: “2024-04-30T23:59:00”.

  • local_time_zone (str) –

    The time zone of the schedule. Example: “Central Standard Time”.

  • times (List[str]) – A list of time slots in hh:mm format, at most 100 elements are allowed. Example: [“00:00”, “12:00”].

  • weekdays (List[str]) – A list of weekdays. Example: [“Monday”, “Tuesday”].

  • job_type (str, default="DefaultJob") – The job type.

  • enabled (bool, default=True) – Whether the schedule is enabled.

  • workspace (str | uuid.UUID, default=None) – The 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.

sempy_labs.create_kql_queryset(name: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

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

Service Principal Authentication is supported (see here for examples).

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

  • target_private_link_resource_id (uuid.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 | uuid.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.

sempy_labs.create_mirrored_database(name: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

sempy_labs.create_ml_experiment(name: str, description: str | None = None, workspace: str | UUID | 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 ML experiment.

  • workspace (str | uuid.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.

sempy_labs.create_ml_model(name: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

sempy_labs.create_model_bpa_semantic_model(dataset: str | None = 'ModelBPA', lakehouse: str | UUID | None = None, lakehouse_workspace: str | UUID | 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 | uuid.UUID, 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 | uuid.UUID, 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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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.

Service Principal Authentication is supported (see here for examples).

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

  • gateway (str | uuid.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_or_update_resource_group(azure_subscription_id: str, resource_group: str, region: str)

Creates or updates a resource group.

This is a wrapper function for the following API: Resource Groups - Create Or Update.

Service Principal Authentication is required (see here for examples).

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

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

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

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, resource_group: str, region: str, **kwargs)

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

This is a wrapper function for the following API: Resource Groups - Create Or Update.

Service Principal Authentication is required (see here for examples).

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

  • 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 | UUID | 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 | uuid.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.

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

Creates a SQL database.

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

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

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

  • workspace (str | uuid.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.

sempy_labs.create_storage_account(azure_subscription_id: str, resource_group: str, storage_account: str, region: str)

Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed.

This is a wrapper function for the following API: `Storage Accounts - Create <https://learn.microsoft.com/rest/api/storagerp/storage-accounts/create`_.

Service Principal Authentication is required (see here for examples).

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

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

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

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

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 = 'NotEncrypted', skip_test_connection: bool = False)

Creates a virtual network gateway connection.

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

Service Principal Authentication is supported (see here for examples).

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

  • gateway (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

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

  • capacity (str | uuid.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 | UUID | None = None) UUID

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 | uuid.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:

The ID of the created warehouse.

Return type:

uuid.UUID

sempy_labs.delete_connection(connection: str | UUID)

Delete a connection.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

connection (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

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

  • role_assignment_id (uuid.UUID) – The role assignment ID.

sempy_labs.delete_custom_pool(pool_name: str, workspace: str | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID, workspace: str | UUID | None = None)

Deletes a Fabric data pipeline.

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

Parameters:
  • name (str | uuid.UUID) – Name or ID of the data pipeline.

  • workspace (str | uuid.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.delete_embedded_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str)

This function deletes a Power BI Embedded capacity.

Service Principal Authentication is required (see here for examples).

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.

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

Deletes a Fabric environment.

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

Parameters:
  • environment (str | uuid.UUID) – Name or ID of the environment.

  • workspace (str | uuid.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.

sempy_labs.delete_eventhouse(name: str, workspace: str | UUID | 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 | uuid.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.

sempy_labs.delete_eventstream(eventstream: str | UUID, workspace: str | UUID | None = None, **kwargs)

Deletes a Fabric eventstream.

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

Parameters:
  • eventstream (str | uuid.UUID) – Name or ID of the eventstream.

  • workspace (str | uuid.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.

sempy_labs.delete_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str)

This function deletes a Fabric capacity.

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

Service Principal Authentication is required (see here for examples).

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.

sempy_labs.delete_gateway(gateway: str | UUID)

Deletes a gateway.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

gateway (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

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

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

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

Delete the specified role assignment for the gateway.

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

Service Principal Authentication is supported (see here for examples).

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

  • role_assignment_id (uuid.UUID) – The role assignment ID.

sempy_labs.delete_kql_database(kql_database: str | UUID, workspace: str | UUID | None = None, **kwargs)

Deletes a KQL database.

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

Parameters:
  • kql_database (str | uuid.UUID) – Name or ID of the KQL database.

  • workspace (str | uuid.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.

sempy_labs.delete_kql_queryset(kql_queryset: str | UUID, workspace: str | UUID | None = None, **kwargs)

Deletes a KQL queryset.

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

Parameters:
  • kql_queryset (str | uuid.UUID) – Name or ID of the KQL queryset.

  • workspace (str | uuid.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.

sempy_labs.delete_managed_private_endpoint(managed_private_endpoint: str | UUID, workspace: str | UUID | 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>.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • managed_private_endpoint (str | uuid.UUID) – Name or ID of the managed private endpoint.

  • workspace (str | uuid.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.

sempy_labs.delete_mirrored_database(mirrored_database: str, workspace: str | UUID | 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 | uuid.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.

sempy_labs.delete_ml_experiment(name: str, workspace: str | UUID | 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 | uuid.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.

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

Deletes a Fabric ML model.

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

Parameters:
  • name (str | uuid.UUID) – Name or ID of the ML model.

  • workspace (str | uuid.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.

sempy_labs.delete_mounted_data_factory(mounted_data_factory: str | UUID, workspace: str | UUID | None)

Deletes the specified mounted data factory.

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

Parameters:
  • mounted_data_factory (str | uuid.UUID) – The name or ID of the mounted data factory.

  • workspace (str | uuid.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.

sempy_labs.delete_premium_capacity(capacity: str | UUID, **kwargs)

This function deletes a Power BI Premium capacity.

Parameters:

capacity (str | uuid.UUID) – Name or ID of the Fabric capacity.

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

Deletes a semantic model.

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

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

  • workspace (str | uuid.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.

sempy_labs.delete_sql_database(sql_database: str | UUID, workspace: str | UUID | None = None)

Deletes a SQL Database.

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

Parameters:
  • sql_database (str | uuid.UUID) – Name of the SQL database.

  • workspace (str | uuid.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.

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

Removes a user from a workspace.

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

Service Principal Authentication is supported (see here for examples).

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

  • workspace (str | uuid.UUID, default=None) – The name or ID 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 | UUID, workspace: str | UUID | None = None)

Deletes a Fabric warehouse.

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

Parameters:
  • name (str | uuid.UUID) – Name or ID of the warehouse.

  • workspace (str | uuid.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.

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

Deletes a workspace.

This is a wrapper function for the following API: Workspaces - Delete Workspace.

Parameters:

workspace (str | uuid.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.

sempy_labs.delta_analyzer(table_name: str, approx_distinct_count: bool = True, export: bool = False, lakehouse: str | UUID | None = None, workspace: str | UUID | None = None, column_stats: bool = True, skip_cardinality: bool = True, schema: str | None = None) Dict[str, DataFrame]

Analyzes a delta table and shows the results in dictionary containing a set of 5 dataframes. If ‘export’ is set to True, the results will be saved to delta tables in the lakehouse attached to the notebook.

The 5 dataframes returned by this function are:

  • Summary

  • Parquet Files

  • Row Groups

  • Column Chunks

  • Columns

Read more about Delta Analyzer here.

Parameters:
  • table_name (str) – The delta table name.

  • approx_distinct_count (bool, default=True) – If True, uses approx_count_distinct to calculate the cardinality of each column. If False, uses COUNT(DISTINCT) instead.

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

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

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

  • column_stats (bool, default=True) – If True, collects data about column chunks and columns. If False, skips that step and only returns the other 3 dataframes.

  • skip_cardinality (bool, default=True) – If True, skips the cardinality calculation for each column. If False, calculates the cardinality for each column.

  • schema (str, default=None) – The name of the schema to which the table belongs (for schema-enabled lakehouses). If None, the default schema is used.

Returns:

A dictionary of pandas dataframes showing semantic model objects which violated the best practice analyzer rules.

Return type:

Dict[str, pandas.DataFrame]

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

Deploys a semantic model based on an existing semantic model.

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

  • source_workspace (str | uuid.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.

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

  • target_workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID 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.

  • perspective (str, default=None) – Set this to the name of a perspective in the model and it will reduce the deployed model down to the tables/columns/measures/hierarchies within that perspective.

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

Deprovisions a workspace identity for a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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.

sempy_labs.disable_qso(dataset: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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 the current query scale out settings.

Return type:

pandas.DataFrame

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

Disconnects a workspace from a git repository.

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

Parameters:

workspace (str | uuid.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.

sempy_labs.enable_semantic_model_scheduled_refresh(dataset: str | UUID, workspace: str | UUID | None = None, enable: bool = True)

Enables the scheduled refresh for the specified dataset from the specified workspace.

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

  • workspace (str | uuid.UUID, default=None) – The 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.

  • enable (bool, default=True) – If True, enables the scheduled refresh. If False, disables the scheduled refresh.

sempy_labs.evaluate_dax_impersonation(dataset: str | UUID, dax_query: str, user_name: str | None = None, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • dax_query (str) – The DAX query.

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

  • workspace (str | uuid.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 holding the result of the DAX query.

Return type:

pandas.DataFrame

sempy_labs.export_model_to_onelake(dataset: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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.

  • 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_dax_query_view_url(dataset: str | UUID, dax_string: str, workspace: str | UUID | None = None)

Prints a URL based on query provided. This URL opens DAX query view in the Power BI service, connected to the semantic model and using the query provided.

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

  • dax_string (str) – The DAX query string.

  • workspace (str | uuid.UUID, default=None) – The 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.

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 | UUID | None = None) UUID

Obtains the Capacity Id for a given workspace.

Parameters:

workspace (str | uuid.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:

The capacity Id.

Return type:

uuid.UUID

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

Obtains the capacity name for a given workspace.

Parameters:

workspace (str | uuid.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:

The capacity name.

Return type:

str

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

Obtains the definition of a data pipeline.

Parameters:
  • name (str or uuid.UUID) – The name or ID of the data pipeline.

  • workspace (str | uuid.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.

  • 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 | UUID, dax_string: str | List[str], put_in_memory: bool = False, show_vertipaq_stats: bool = True, workspace: str | UUID | 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 | uuid.UUID) – Name or ID 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 | uuid.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 the dependent columns of a given DAX query including model dependencies.

Return type:

pandas.DataFrame

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

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

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

  • dax_string (str) – The DAX query.

  • workspace (str | uuid.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:

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

Return type:

int

sempy_labs.get_delta_table_history(table_name: str, lakehouse: str | UUID | None = None, workspace: str | UUID | None = None, schema: str | None = None) DataFrame

Returns the history of a delta table as a pandas dataframe.

Parameters:
  • table_name (str) – The delta table name.

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

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

  • schema (str, default=None) – The name of the schema to which the table belongs (for schema-enabled lakehouses). If None, the default schema is used.

Returns:

A dataframe showing the history of the delta table.

Return type:

pandas.DataFrame

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

Obtains the SQL Endpoint ID of the semantic model.

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

  • workspace (str | uuid.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:

The ID of SQL Endpoint.

Return type:

uuid.UUID

sempy_labs.get_eventhouse_definition(eventhouse: str | UUID, workspace: str | UUID | None = None, return_dataframe: bool = False) dict | DataFrame

Gets the eventhouse definition.

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

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

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID in which the eventhouse 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=False) – If True, returns a dataframe. If False, returns a json dictionary.

Returns:

The eventhouse definition in .json format or as a pandas dataframe.

Return type:

dict | pandas.DataFrame

sempy_labs.get_git_connection(workspace: str | UUID | 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 | uuid.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 the Git status of items in the workspace.

Return type:

pandas.DataFrame

sempy_labs.get_git_status(workspace: str | UUID | 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 | uuid.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 the Git status of items in the workspace.

Return type:

pandas.DataFrame

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

Shows all dependencies for all measures in a semantic model.

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

  • workspace (str | uuid.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:

Shows all dependencies for all measures in the semantic model.

Return type:

pandas.DataFrame

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

Obtains the mirrored database definition.

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

Parameters:
  • mirrored_database (str | uuid.UUID) – The name or ID of the mirrored database.

  • workspace (str | uuid.UUID, default=None) – The name or ID 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:

dict

sempy_labs.get_mirroring_status(mirrored_database: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the mirrored database.

  • workspace (str | uuid.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:

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.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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:

Shows all dependencies for all objects in the semantic model.

Return type:

pandas.DataFrame

sempy_labs.get_mounted_data_factory_definition(mounted_data_factory: str | UUID, workspace: str | UUID | None = None) dict

Returns the specified MountedDataFactory public definition.

This is a wrapper function for the following API: Items - Get Mounted Data Factory Definition.

Parameters:
  • mounted_data_factory (str | uuid.UUID) – The name or ID of the mounted data factory.

  • workspace (str | uuid.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:

The ‘mountedDataFactory-content.json’ file from the mounted data factory definition.

Return type:

dict

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

Returns the user’s Git credentials configuration details.

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

Parameters:

workspace (str | uuid.UUID, default=None) – The 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 the user’s Git credentials configuration details.

Return type:

pandas.DataFrame

sempy_labs.get_notebook_definition(notebook_name: str, workspace: str | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID | None = None) DataFrame

Shows the object level security for the semantic model.

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

  • workspace (str | uuid.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 the object level security for the semantic model.

Return type:

pandas.DataFrame

sempy_labs.get_resource_group(azure_subscription_id: str, resource_group: str) DataFrame

Gets details about a specified resource group.

This is a wrapper function for the following API: Resource Groups - Get.

Service Principal Authentication is required (see here for examples).

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

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

Returns:

A pandas dataframe showing details of a specific resource group.

Return type:

pandas.DataFrame

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

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

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

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID 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.

Returns:

The Model.bim file for the semantic model.

Return type:

dict

sempy_labs.get_semantic_model_definition(dataset: str | UUID, format: str = 'TMSL', workspace: str | UUID | 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 | uuid.UUID) – Name or ID 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 | uuid.UUID, default=None) – The Fabric workspace name or ID 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 | UUID, request_id: str | None = None, workspace: str | UUID | 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 | uuid.UUID) – Name or ID 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 | uuid.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 the semantic model refresh history.

Return type:

pandas.DataFrame

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

Gets the refresh schedule for the specified dataset from the specified workspace.

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

  • workspace (str | uuid.UUID, default=None) – The 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:

Shows the refresh schedule for the specified dataset from the specified workspace.

Return type:

pandas.DataFrame

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

Gets size of the semantic model in bytes.

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

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID 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.

Returns:

The size of the semantic model in

Return type:

int

sempy_labs.get_spark_settings(workspace: str | UUID | 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 | uuid.UUID, default=None) – The name or ID 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_sql_database_columns(sql_database: str | UUID, workspace: str | UUID | None = None) DataFrame

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

Parameters:
  • sql_database (str | uuid.UUID) – Name or ID of the Fabric SQLDabatase.

  • workspace (str | uuid.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 columns in each table within the Fabric SQLDabatase.

Return type:

pandas.DataFrame

sempy_labs.get_sql_database_tables(sql_database: str | UUID, workspace: str | UUID | None = None) DataFrame

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

Parameters:
  • sql_database (str | uuid.UUID) – Name or ID of the Fabric SQLDabatase.

  • workspace (str | uuid.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 tables in the Fabric SQLDabatase.

Return type:

pandas.DataFrame

sempy_labs.get_subscription(azure_subscription_id: str) DataFrame

Gets details about a specified subscription.

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

Service Principal Authentication is required (see here for examples).

Parameters:

azure_subscription_id (str) – The Azure subscription ID.

Returns:

A pandas dataframe showing details of a specific subscription.

Return type:

pandas.DataFrame

sempy_labs.get_tables_mirroring_status(mirrored_database: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the mirrored database.

  • workspace (str | uuid.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 the mirroring status of the tables.

Return type:

pandas.DataFrame

sempy_labs.get_tenant_id()
sempy_labs.get_warehouse_columns(warehouse: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the Fabric warehouse.

  • workspace (str | uuid.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 columns in each table within the Fabric warehouse.

Return type:

pandas.DataFrame

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

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

Parameters:
  • warehouse (str | uuid.UUID) – Name or ID of the Fabric warehouse.

  • workspace (str | uuid.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 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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID | 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 | uuid.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:

Remote full SHA commit hash.

Return type:

str

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

Identifies whether a semantic model is a default semantic model.

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

  • workspace (str | uuid.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 True/False value indicating whether the semantic model is a default semantic model.

Return type:

bool

sempy_labs.list_backups(workspace: str | UUID | 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 | uuid.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 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.

Service Principal Authentication is supported (see here for examples).

Parameters:

connection (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

Returns:

A pandas dataframe showing all available connections.

Return type:

pandas.DataFrame

sempy_labs.list_custom_pools(workspace: str | UUID | 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 | uuid.UUID, 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 | UUID | None = None) DataFrame

Shows a list of the dashboards within a workspace.

Parameters:

workspace (str | uuid.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 the dashboards within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_data_pipelines(workspace: str | UUID | 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 | uuid.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 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 | UUID | None = None)

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

Parameters:

workspace (str | uuid.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 the dataflows which exist within a workspace.

Return type:

pandas.DataFrame

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

Shows the datamarts within a workspace.

Parameters:

workspace (str | uuid.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 the datamarts within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_deployment_pipeline_stage_items(deployment_pipeline: str | UUID, stage: str | UUID) 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 | uuid.UUID) – The deployment pipeline name or ID.

  • stage (str | uuid.UUID) – The deployment pipeline stage name or ID.

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 | UUID) 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 | uuid.UUID) – The deployment pipeline name or ID.

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 | UUID | None = None) DataFrame

Shows the eventhouses within a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the eventhouses within a workspace.

Return type:

pandas.DataFrame

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

Shows the eventstreams within a workspace.

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

Parameters:

workspace (str | uuid.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 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 | UUID | 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 | uuid.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 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.

Service Principal Authentication is supported (see here for examples).

Parameters:

gateway (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

Parameters:

gateway (str | uuid.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.

Service Principal Authentication is supported (see here for examples).

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_graphql_apis(workspace: str | UUID | None) DataFrame

Shows the Graph QL APIs within a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the GraphQL APIs within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_item_connections(item_name: str, item_type: str, workspace: str | UUID | 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.

Service Principal Authentication is supported (see here for examples).

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

  • item_type (str) –

    The item type.

  • workspace (str | uuid.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 the list of connections that the specified item is connected to.

Return type:

pandas.DataFrame

sempy_labs.list_item_job_instances(item: str | UUID, type: str | None = None, workspace: str | UUID | None = None) DataFrame

Returns a list of job instances for the specified item.

This is a wrapper function for the following API: Job Scheduler - List Item Job Instances.

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

  • type (str, default=None) –

    The item type. If specifying the item name as the item, the item type is required.

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID used by the lakehouse. 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 list of job instances for the specified item.

Return type:

pandas.DataFrame

sempy_labs.list_item_schedules(item: str | UUID, type: str | None = None, job_type: str = 'DefaultJob', workspace: str | UUID | None = None) DataFrame

Get scheduling settings for one specific item.

This is a wrapper function for the following API: Job Scheduler - List Item Schedules.

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

  • type (str, default=None) –

    The item type. If specifying the item name as the item, the item type is required.

  • job_type (str, default="DefaultJob") – The job type.

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID used by the lakehouse. 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 list of scheduling settings for one specific item.

Return type:

pandas.DataFrame

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

Shows the KQL databases within a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the KQL databases within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_kql_querysets(workspace: str | UUID | 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 | uuid.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 the KQL querysets within a workspace.

Return type:

pandas.DataFrame

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

Shows the lakehouses within a workspace.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the lakehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_managed_private_endpoints(workspace: str | UUID | 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>.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the managed private endpoints within a workspace.

Return type:

pandas.DataFrame

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

Shows the mirrored databases within a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the mirrored databases within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_mirrored_warehouses(workspace: str | UUID | 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 | uuid.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 the mirrored warehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_ml_experiments(workspace: str | UUID | 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 | uuid.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 the ML models within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_ml_models(workspace: str | UUID | 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 | uuid.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 the ML models within a workspace.

Return type:

pandas.DataFrame

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

Shows a list of mounted data factories from the specified workspace.

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

Parameters:

workspace (str | uuid.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 mounted data factories from the specified workspace.

Return type:

pandas.DataFrame

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

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

Parameters:
  • dataset (str | uuid.UUID, default=None) – Name or ID of the semantic model.

  • workspace (str | uuid.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 the query scale out settings.

Return type:

pandas.DataFrame

sempy_labs.list_report_semantic_model_objects(dataset: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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.

  • 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 | UUID, workspace: str | UUID | None = None) DataFrame

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

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

  • workspace (str | uuid.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 the reports which use a given semantic model.

Return type:

pandas.DataFrame

sempy_labs.list_resource_groups(azure_subscription_id: str, filter: str | None = None, top: int | None = None) DataFrame

Lists all resource groups within a subscription.

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

Service Principal Authentication is required (see here for examples).

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

  • filter (str, default=None) – The filter to apply to the operation. Example: filter=”tagname eq ‘tagvalue’”.

  • top (int, default=None) – The number of results to return. If not specified, returns all results.

Returns:

A pandas dataframe showing a list of all resource groups within the subscription.

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.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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 | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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.

  • 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 | UUID, workspace: str | UUID | None = None) DataFrame

Shows a list of semantic model objects.

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

  • workspace (str | uuid.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 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 | uuid.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 server properties.

Return type:

pandas.DataFrame

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

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

* NOTE: This function has been moved to the lakehouse subpackage. Please repoint your code to use that location. *

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

  • workspace (str | uuid.UUID, default=None) – The name or ID 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.

  • path (str, default=None) – The path within lakehouse where to look for shortcuts. If provied, must start with either “Files” or “Tables”. Examples: Tables/FolderName/SubFolderName; Files/FolderName/SubFolderName. Defaults to None which will retun all shortcuts on the given lakehouse

Returns:

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

Return type:

pandas.DataFrame

sempy_labs.list_skus(azure_subscription_id: str) DataFrame

Lists eligible SKUs for Microsoft Fabric resource provider.

This is a wrapper function for the following API: Fabric Capacities - List Skus For Capacity.

Service Principal Authentication is required (see here for examples).

Parameters:

azure_subscription_id (str) – The Azure subscription ID.

Returns:

A pandas dataframe showing a list of eligible SKUs for Microsoft Fabric resource provider.

Return type:

pandas.DataFrame

sempy_labs.list_skus_for_capacity(capacity: str, azure_subscription_id: str, resource_group: str) DataFrame

Lists eligible SKUs for a Microsoft Fabric resource.

This is a wrapper function for the following API: Fabric Capacities - List Skus For Capacity.

Service Principal Authentication is required (see here for examples).

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

  • azure_subscription_id (str) – The Azure subscription ID.

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

Returns:

A pandas dataframe showing a list of eligible SKUs for a Microsoft Fabric resource.

Return type:

pandas.DataFrame

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

Lists all SQL databases in the Fabric workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 SQL databases in the Fabric workspace.

Return type:

pandas.DataFrame

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

Shows the SQL endpoints within a workspace.

Parameters:

workspace (str | uuid.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 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_storage_accounts(azure_subscription_id: str, resource_group: str | None = None) DataFrame

Lists all the storage accounts available under the subscription (or resource group). Note that storage keys are not returned; use the ListKeys operation for this.

This is a wrapper function for the following APIs: Storage Accounts - List, Storage Accounts - List By Resource Group.

Service Principal Authentication is required (see here for examples).

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

  • resource_group (str, default=None) – If set to None, retrieves all storage accounts for the subscription. If not None, shows the storage accounts within that resource group.

Returns:

A pandas dataframe showing a list of all storage accounts within the subscription (or resource group).

Return type:

pandas.DataFrame

sempy_labs.list_subscriptions() DataFrame

Gets all subscriptions for a tenant.

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

Service Principal Authentication is required (see here for examples).

Returns:

A pandas dataframe showing a list of all subscriptions for a tenant.

Return type:

pandas.DataFrame

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

Gets the tenants for your account.

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

Service Principal Authentication is required (see here for examples).

Returns:

A pandas dataframe showing a list of all tenants for your account.

Return type:

pandas.DataFrame

sempy_labs.list_upstream_dataflows(dataflow: str | UUID, workspace: str | UUID | 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.UUID) – Name or UUID of the dataflow.

  • workspace (str | uuid.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 upstream dataflows for the specified dataflow.

Return type:

pandas.DataFrame

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

Shows the warehouses within a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the warehouses within a workspace.

Return type:

pandas.DataFrame

sempy_labs.list_workloads(capacity: str | UUID, **kwargs) 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 (str | uuid.UUID) – The capacity name or ID.

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 | UUID | None = None) DataFrame

Shows the members of a given workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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 the members of a given workspace and their roles.

Return type:

pandas.DataFrame

sempy_labs.list_workspace_users(workspace: str | UUID | 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.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.UUID, default=None) – The name or ID 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 | UUID, measure_name: str, workspace: str | UUID | None = None)

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

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

  • measure_name (str) – Name of the measure.

  • workspace (str | uuid.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.

sempy_labs.migrate_capacities(azure_subscription_id: str, resource_group: str | dict, capacities: str | List[str] | None = None, use_existing_rg_for_A_sku: bool = True, p_sku_only: bool = True, **kwargs)

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.

  • 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_fabric_trial_capacity(azure_subscription_id: str, resource_group: str, source_capacity: str, target_capacity: str, target_capacity_sku: str = 'F64', target_capacity_admin_members: str | List[str] | None = None, **kwargs)

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.

  • 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_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: str | UUID, workload_name: str, state: str | None = None, max_memory_percentage: int | None = None, **kwargs)

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 (str | uuid.UUID) – The capacity name or ID.

  • 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 | UUID | None = None)

Provisions a workspace identity for a workspace.

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

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.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.

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

Publishes a Fabric environment.

This is a wrapper function for the following API: Spark Libraries - Publish Environment.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • environment (str | uuid.UUID) – Name or ID of the environment.

  • workspace (str | uuid.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.

sempy_labs.qso_sync(dataset: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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.

sempy_labs.qso_sync_status(dataset: str | UUID, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

  • workspace (str | uuid.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:

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 | UUID | None = None, visualize: bool = False, commit_mode: str = 'transactional') DataFrame | None

Refreshes a semantic model.

Parameters:
  • dataset (str | uuid.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 | uuid.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.

  • 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: str | UUID | None = None, **kwargs) UUID

Obtains the capacity Id for a given capacity name.

Parameters:

capacity (str | uuid.UUID, default=None) – The capacity name or ID. 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.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.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 | UUID, workspace: str | UUID | None = None) Tuple[UUID, str, UUID, str]

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

Parameters:
  • report (str | uuid.UUID) – The name or ID of the Power BI report.

  • workspace (str | uuid.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:

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

Return type:

Tuple[uuid.UUID, str, uuid.UUID, str]

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

Obtains the ID of the semantic model.

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

  • workspace (str | uuid.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.

Returns:

The ID of the semantic model.

Return type:

uuid.UUID

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

Obtains the name of the semantic model.

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

  • workspace (str | uuid.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.

Returns:

The name of the semantic model.

Return type:

str

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

Obtains the environment Id for a given environment.

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

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID 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.

Returns:

The environment Id.

Return type:

uuid.UUID

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

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

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

  • workspace (str | uuid.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:

The item type for the item Id.

Return type:

str

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

Obtains the ID of the Fabric lakehouse.

Parameters:
  • lakehouse (str | uuid.UUID, default=None) – The name or ID of the Fabric lakehouse.

  • workspace (str | uuid.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:

The ID of the Fabric lakehouse.

Return type:

uuid.UUID

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

Obtains the name of the Fabric lakehouse.

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

  • workspace (str | uuid.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:

The name of the Fabric lakehouse.

Return type:

str

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

Obtains the ID of the Power BI report.

Parameters:
  • report (str | uuid.UUID) – The name or ID of the Power BI report.

  • workspace (str | uuid.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:

The ID of the Power BI report.

Return type:

uuid.UUID

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

Obtains the name of the Power BI report.

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

  • workspace (str | uuid.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:

The name of the Power BI report.

Return type:

str

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

Obtains the Id for a given warehouse.

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

  • workspace (str | uuid.UUID, default=None) – The Fabric workspace name or ID 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.

Returns:

The warehouse Id.

Return type:

uuid.UUID

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

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

Parameters:

workspace (str | uuid.UUID, default=None) – The Fabric workspace name or UUID. 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.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 | UUID | 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 | uuid.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.

sempy_labs.resume_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str)

This function resumes a Fabric capacity.

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

Service Principal Authentication is required (see here for examples).

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.

sempy_labs.revoke_external_data_share(external_data_share_id: UUID, item_name: str, item_type: str, workspace: str | UUID | 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.UUID) – The external data share ID.

  • item_name (str) – The item name.

  • item_type (str) –

    The item type.

  • workspace (str | uuid.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.

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, check_dependencies: bool = True, **kwargs)

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

The Best Practice Analyzer rules are based on the rules defined here. The framework for the Best Practice Analyzer and rules are based on the foundation set by Tabular Editor.

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

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

  • workspace (str | uuid.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.

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

  • check_dependencies (bool, default=True) – If True, leverages the model dependencies from get_model_calc_dependencies to evaluate the rules. Set this parameter to False if running the rules against a semantic model in a shared capacity.

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 | UUID | None = None, workspace: str | UUID | 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 | uuid.UUID, default=None) – The Fabric lakehouse name or ID. Defaults to None which resolves to the lakehouse attached to the notebook.

  • workspace (str | uuid.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.

sempy_labs.service_principal_authentication(key_vault_uri: str, key_vault_tenant_id: str, key_vault_client_id: str, key_vault_client_secret: str)

Establishes an authentication via Service Principal.

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.

sempy_labs.set_qso(dataset: str | UUID, auto_sync: bool = True, max_read_only_replicas: int = -1, workspace: str | UUID | 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 | uuid.UUID) – Name or ID 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 | uuid.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 the current query scale-out settings.

Return type:

pandas.DataFrame

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

Sets the semantic model storage format.

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

  • storage_format (str) – The storage format for the semantic model. Valid options: ‘Large’, ‘Small’.

  • workspace (str | uuid.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.

sempy_labs.set_workspace_default_storage_format(storage_format: str, workspace: str | UUID | 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 | uuid.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.

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

Starts the mirroring for a database.

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

Parameters:
  • mirrored_database (str | uuid.UUID) – Name or ID of the mirrored database.

  • workspace (str | uuid.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.

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

Stops the mirroring for a database.

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

Parameters:
  • mirrored_database (str | uuid.UUID) – Name or ID of the mirrored database.

  • workspace (str | uuid.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.

sempy_labs.suspend_fabric_capacity(capacity_name: str, azure_subscription_id: str, resource_group: str)

This function suspends a Fabric capacity.

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

Service Principal Authentication is required (see here for examples).

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.

sempy_labs.translate_semantic_model(dataset: str | UUID, languages: str | List[str], exclude_characters: str | None = None, workspace: str | UUID | None = None) DataFrame

Translates names, descriptions, display folders for all objects in a semantic model.

Parameters:
  • dataset (str | uuid.UUID) – Name or ID 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 | uuid.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:

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 | UUID | None = None)

Unassigns a workspace from its assigned capacity.

This is a wrapper function for the following API: Workspaces - Unassign From Capacity.

Service Principal Authentication is supported (see here for examples).

Parameters:

workspace (str | uuid.UUID, default=None) – The name or ID 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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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, 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.

Service Principal Authentication is required (see here for examples).

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.

  • 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 | UUID | 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 | uuid.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.

sempy_labs.update_item(item_type: str, current_name: str, new_name: str, description: str | None = None, workspace: str | UUID | 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 | uuid.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.

sempy_labs.update_mirrored_database_definition(mirrored_database: str | UUID, mirrored_database_content: dict, workspace: str | UUID | None = None)

Updates an existing notebook with a new definition.

Parameters:
  • mirrored_database (str | uuid.UUID) – The name or ID of the mirrored database to be updated.

  • mirrored_database_content (dict) – The mirrored database definition (not in Base64 format).

  • workspace (str | uuid.UUID, default=None) – The name or ID 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_my_git_credentials(source: str, connection_id: UUID | None = None, workspace: str | UUID | None = None)

Updates the user’s Git credentials configuration details.

This is a wrapper function for the following API: Git - Update My Git Credentials.

Parameters:
  • source (str) – The Git credentials source. Valid options: ‘Automatic’, ‘ConfiguredConnection’, ‘None’.

  • connection_id (UUID, default=None) – The object ID of the connection. Valid only for the ‘ConfiguredConnection’ source.

  • workspace (str | uuid.UUID, default=None) – The 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.

sempy_labs.update_notebook_definition(name: str, notebook_content: str, workspace: str | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID, 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.

Service Principal Authentication is supported (see here for examples).

Parameters:
  • gateway (str | uuid.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 | UUID, bim_file: dict, workspace: str | UUID | 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 | uuid.UUID) – Name or ID of the semantic model.

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

  • workspace (str | uuid.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.

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 | UUID | 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 | uuid.UUID, default=None) – The name or ID 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 | UUID, 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.

Service Principal Authentication is supported (see here for examples).

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

  • capacity (str | uuid.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 | UUID | None = None)

Updates a user’s role within a workspace.

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

Service Principal Authentication is supported (see here for examples).

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 | uuid.UUID, default=None) – The name or ID 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 | UUID, workspace: str | UUID | None = None, export: str | None = None, read_stats_from_data: bool = False, **kwargs) dict[str, DataFrame]

Displays an HTML visualization of the Vertipaq Analyzer statistics from a semantic model.

Vertipaq Analyzer is an open-sourced tool built by SQLBI. It provides a detailed analysis of the VertiPaq engine, which is the in-memory engine used by Power BI and Analysis Services Tabular models.

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

  • workspace (str| uuid.UUID, default=None) – The Fabric workspace name or ID 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).

Returns:

A dictionary of pandas dataframes showing the vertipaq analyzer statistics.

Return type:

dict[str, pandas.DataFrame]