{ "cells": [ { "cell_type": "markdown", "id": "5c27dfd1-4fe0-4a97-92e6-ddf78889aa93", "metadata": { "nteract": { "transient": { "deleting": false } } }, "source": [ "### Install the latest .whl package\n", "\n", "Check [here](https://pypi.org/project/semantic-link-labs/) to see the latest version." ] }, { "cell_type": "code", "execution_count": null, "id": "d5cae9db-cef9-48a8-a351-9c5fcc99645c", "metadata": { "jupyter": { "outputs_hidden": true, "source_hidden": false }, "nteract": { "transient": { "deleting": false } } }, "outputs": [], "source": [ "%pip install semantic-link-labs" ] }, { "cell_type": "markdown", "id": "b195eae8", "metadata": {}, "source": [ "### Import the library and necessary packages" ] }, { "cell_type": "code", "execution_count": null, "id": "1344e286", "metadata": {}, "outputs": [], "source": [ "import sempy_labs as labs\n", "source_dataset = '' # Name of the semantic model to backup\n", "target_dataset = '' # Name of the semantic model to restore\n", "source_workspace = '' # Name of the workspace in which the semantic model resides\n", "target_workspace = '' # Destination workspace of the semantic model\n", "source_file_path = '' # Name/path of the backup file to create\n", "target_file_path = '' # Name/path of the backup file to be copied to the target workspace\n", "storage_account = '' # Name of the ADLS Gen2 storage account associated with both source & target workspaces" ] }, { "cell_type": "markdown", "id": "d4f5356a", "metadata": {}, "source": [ "#### Prerequisites\n", "* [Create an ADLS Gen2 storage account (in the Azure Portal)](https://learn.microsoft.com/azure/storage/common/storage-account-create?tabs=azure-portal)\n", "* Assign the ADLS Gen2 storage account to both source and target workspaces\n", " * Navigate to your workspace.\n", " * Select 'Workspace settings'.\n", " * Select 'Azure connections'.\n", " * Within 'Azure Data Lake Gen2 Storage' click 'Configure'.\n", " * Enter your Subscription, Resource Group and Storage Account.\n", " * Click 'Save'.\n" ] }, { "cell_type": "markdown", "id": "55e5ca67", "metadata": {}, "source": [ "### Backup, copy and restore a semantic model to a new workspace" ] }, { "cell_type": "code", "execution_count": null, "id": "5a985c1f", "metadata": {}, "outputs": [], "source": [ "labs.backup_semantic_model(\n", " dataset=source_dataset,\n", " file_path=source_file_path,\n", " workspace=source_workspace,\n", ")\n", "labs.copy_semantic_model_backup_file(\n", " source_workspace=source_workspace,\n", " target_workspace=target_workspace,\n", " source_file_name=source_file_path,\n", " target_file_name=target_file_path,\n", " storage_account=storage_account,\n", ")\n", "labs.restore_semantic_model(\n", " dataset=target_dataset,\n", " file_path=target_file_path,\n", " workspace=target_workspace,\n", ")" ] } ], "metadata": { "kernel_info": { "name": "synapse_pyspark" }, "kernelspec": { "display_name": "Synapse PySpark", "language": "Python", "name": "synapse_pyspark" }, "language_info": { "name": "python" }, "microsoft": { "language": "python" }, "nteract": { "version": "nteract-front-end@1.0.0" }, "spark_compute": { "compute_id": "/trident/default" }, "synapse_widget": { "state": {}, "version": "0.1" }, "widgets": {} }, "nbformat": 4, "nbformat_minor": 5 }