sempy_labs.migration package

Module contents

sempy_labs.migration.create_pqt_file(dataset: str | UUID, workspace: str | UUID | None = None, file_name: str = 'PowerQueryTemplate')

Dynamically generates a Power Query Template file based on the semantic model. The .pqt file is saved within the Files section of your lakehouse.

Dataflows Gen2 has a limit of 50 tables. If there are more than 50 tables, this will save multiple Power Query Template files (with each file having a max of 50 tables).

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.

  • file_name (str, default='PowerQueryTemplate') – The name of the Power Query Template file to be generated.

sempy_labs.migration.migrate_calc_tables_to_lakehouse(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None, lakehouse: str | None = None, lakehouse_workspace: str | None = None)

Creates delta tables in your lakehouse based on the DAX expression of a calculated table in an import/DirectQuery semantic model. The DAX expression encapsulating the calculated table logic is stored in the new Direct Lake semantic model as model annotations.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.

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

sempy_labs.migration.migrate_calc_tables_to_semantic_model(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None, lakehouse: str | None = None, lakehouse_workspace: str | None = None)

Creates new tables in the Direct Lake semantic model based on the lakehouse tables created using the ‘migrate_calc_tables_to_lakehouse’ function.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.

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

sempy_labs.migration.migrate_direct_lake_to_import(dataset: str | UUID, workspace: str | UUID)

Migrates a semantic model from Direct Lake mode to import mode. After running this function, you must go to the semantic model settings and update the cloud connection. Not doing so will result in an inablity to refresh/use 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.

sempy_labs.migration.migrate_field_parameters(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None)

Migrates field parameters from one semantic model to another.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. 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.migration.migrate_model_objects_to_semantic_model(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None)

Adds the rest of the model objects (besides tables/columns) and their properties to a Direct Lake semantic model based on an import/DirectQuery semantic model.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. 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.migration.migrate_tables_columns_to_semantic_model(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None, lakehouse: str | None = None, lakehouse_workspace: str | None = None)

Adds tables/columns to the new Direct Lake semantic model based on an import/DirectQuery semantic model.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.

  • lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.

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

sempy_labs.migration.migration_validation(dataset: str, new_dataset: str, workspace: str | None = None, new_dataset_workspace: str | None = None) DataFrame

Shows the objects in the original semantic model and whether then were migrated successfully or not.

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

  • new_dataset (str) – Name of the Direct Lake semantic model.

  • workspace (str, default=None) – The Fabric workspace name in which the import/DirectQuery 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.

  • new_dataset_workspace (str) – The Fabric workspace name in which the Direct Lake semantic model will be created. 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 and whether they were successfully migrated. Also shows the % of objects which were migrated successfully.

Return type:

pandas.DataFrame

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

Recreates the delta tables in the lakehouse based on the DAX expressions stored as model annotations in the Direct Lake semantic model.

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

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