Created
January 29, 2026 09:40
-
-
Save Guust-Franssens/a15e54fa373fd93c47578d45cc5f586c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"cells":[{"cell_type":"code","source":["%pip install ms-fabric-cli\n"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:35:44.3461757Z","session_start_time":null,"execution_start_time":"2026-01-29T09:35:45.9175928Z","execution_finish_time":"2026-01-29T09:36:01.0079908Z","parent_msg_id":"650a09ec-1ee2-45c6-8bf1-6e622dd5be80"}},"metadata":{}},{"output_type":"stream","name":"stdout","text":["Collecting ms-fabric-cli\n Downloading ms_fabric_cli-1.3.1-py3-none-any.whl.metadata (9.8 kB)\nRequirement already satisfied: msal<2,>=1.29 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from msal[broker]<2,>=1.29->ms-fabric-cli) (1.33.0)\nRequirement already satisfied: msal_extensions in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (1.3.1)\nCollecting questionary (from ms-fabric-cli)\n Downloading questionary-2.1.1-py3-none-any.whl.metadata (5.4 kB)\nRequirement already satisfied: prompt_toolkit>=3.0.41 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (3.0.52)\nRequirement already satisfied: cachetools>=5.5.0 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (5.5.2)\nRequirement already satisfied: jmespath in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (1.0.1)\nRequirement already satisfied: pyyaml==6.0.2 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (6.0.2)\nCollecting argcomplete>=3.6.2 (from ms-fabric-cli)\n Downloading argcomplete-3.6.3-py3-none-any.whl.metadata (16 kB)\nRequirement already satisfied: psutil==7.0.0 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from ms-fabric-cli) (7.0.0)\nRequirement already satisfied: requests<3,>=2.0.0 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (2.32.5)\nRequirement already satisfied: PyJWT<3,>=1.0.0 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from PyJWT[crypto]<3,>=1.0.0->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (2.8.0)\nRequirement already satisfied: cryptography<48,>=2.5 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (45.0.6)\nCollecting pymsalruntime<0.19,>=0.18 (from msal[broker]<2,>=1.29->ms-fabric-cli)\n Downloading pymsalruntime-0.18.1-cp311-cp311-manylinux_2_35_x86_64.whl.metadata (264 bytes)\nRequirement already satisfied: wcwidth in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from prompt_toolkit>=3.0.41->ms-fabric-cli) (0.2.13)\nRequirement already satisfied: cffi>=1.14 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from cryptography<48,>=2.5->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (1.17.1)\nRequirement already satisfied: charset_normalizer<4,>=2 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from requests<3,>=2.0.0->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (3.4.3)\nRequirement already satisfied: idna<4,>=2.5 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from requests<3,>=2.0.0->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (3.10)\nRequirement already satisfied: urllib3<3,>=1.21.1 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from requests<3,>=2.0.0->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (2.2.2)\nRequirement already satisfied: certifi>=2017.4.17 in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from requests<3,>=2.0.0->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (2024.7.4)\nRequirement already satisfied: pycparser in /home/trusted-service-user/jupyter-env/python3.11/lib/python3.11/site-packages (from cffi>=1.14->cryptography<48,>=2.5->msal<2,>=1.29->msal[broker]<2,>=1.29->ms-fabric-cli) (2.22)\nDownloading ms_fabric_cli-1.3.1-py3-none-any.whl (319 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m319.5/319.5 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n\u001b[?25hDownloading argcomplete-3.6.3-py3-none-any.whl (43 kB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.8/43.8 kB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25hDownloading questionary-2.1.1-py3-none-any.whl (36 kB)\nDownloading pymsalruntime-0.18.1-cp311-cp311-manylinux_2_35_x86_64.whl (93.3 MB)\n\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m93.3/93.3 MB\u001b[0m \u001b[31m15.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m00:01\u001b[0m\n\u001b[?25hInstalling collected packages: pymsalruntime, argcomplete, questionary, ms-fabric-cli\nSuccessfully installed argcomplete-3.6.3 ms-fabric-cli-1.3.1 pymsalruntime-0.18.1 questionary-2.1.1\nNote: you may need to restart the kernel to use updated packages.\n"]}],"execution_count":1,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"},"jupyter":{"outputs_hidden":true}},"id":"a2a8b9e8-3ac1-4d4a-82a4-509c022d7cbd"},{"cell_type":"code","source":["import os\n","import subprocess"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:35:45.4064062Z","session_start_time":null,"execution_start_time":"2026-01-29T09:36:01.0094765Z","execution_finish_time":"2026-01-29T09:36:01.372236Z","parent_msg_id":"5a944a6e-87c1-49b2-8fdc-896cbba5324c"}},"metadata":{}}],"execution_count":2,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"}},"id":"b37b2fb4-ce58-4777-a8a2-ec244362074d"},{"cell_type":"code","source":["token = notebookutils.credentials.getToken('pbi')\n","os.environ['FAB_TOKEN'] = token\n","os.environ['FAB_TOKEN_ONELAKE'] = token\n","\n","def run_fab_command( command, capture_output: bool = False, silently_continue: bool = False):\n"," result = subprocess.run([\"fab\", \"-c\", command], capture_output=capture_output, text=True)\n"," if (not(silently_continue) and (result.returncode > 0 or result.stderr)):\n"," raise Exception(f\"Error running fab command. exit_code: '{result.returncode}'; stderr: '{result.stderr}'\") \n"," if (capture_output): \n"," output = result.stdout.strip()\n"," return output\n"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:35:50.2540883Z","session_start_time":null,"execution_start_time":"2026-01-29T09:36:01.3734806Z","execution_finish_time":"2026-01-29T09:36:01.7046057Z","parent_msg_id":"55525e66-d4a3-4221-bdcd-eac02ca79e1e"}},"metadata":{}}],"execution_count":3,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"}},"id":"67274dcb-ffe5-4120-a99d-b32ed7169fea"},{"cell_type":"code","source":["workspace_name = \"DEMO customs\"\n","items = run_fab_command(f\"ls {workspace_name}.workspace\")"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:35:54.2361501Z","session_start_time":null,"execution_start_time":"2026-01-29T09:36:01.7058051Z","execution_finish_time":"2026-01-29T09:36:04.6589949Z","parent_msg_id":"d1ff4474-b240-4dd8-9561-895e6c3cb7cc"}},"metadata":{}},{"output_type":"stream","name":"stdout","text":["H7 Douane Analysis.Report\r\nLH_transform.Lakehouse\r\nLH_transform.SQLEndpoint\r\nmirrored-sql-douane.MirroredDatabase\r\nmirrored-sql-douane.SQLEndpoint\r\nNB_check_table_settings.Notebook\r\nNB_define_MLV.Notebook\r\nNB_generate_1_billion_records.Notebook\r\nNB_load_one_billion_records.Notebook\r\nSM_H7_fraud_analysis.SemanticModel\r\n"]}],"execution_count":4,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"}},"id":"cd2a3497-b111-4096-b988-dbb3a4cfec34"},{"cell_type":"code","source":["os.listdir(\"/lakehouse/default/Files\")"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:36:29.1798675Z","session_start_time":null,"execution_start_time":"2026-01-29T09:36:29.1808Z","execution_finish_time":"2026-01-29T09:36:29.5481389Z","parent_msg_id":"e31ed831-043e-4ead-9290-0451ca39d8ef"}},"metadata":{}},{"output_type":"execute_result","execution_count":9,"data":{"text/plain":"[]"},"metadata":{}}],"execution_count":7,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"}},"id":"9801ab37-0d80-4b00-b8ef-735bd8b5af83"},{"cell_type":"code","source":["run_fab_command(f\"export {workspace_name}.workspace/SM_H7_fraud_analysis.SemanticModel -o /lakehouse/default/Files -f\")"],"outputs":[{"output_type":"display_data","data":{"application/vnd.jupyter.statement-meta+json":{"session_id":"0aefe494-ece2-4c2c-8c6b-6d79bd622ac8","normalized_state":"finished","queued_time":"2026-01-29T09:37:47.130961Z","session_start_time":null,"execution_start_time":"2026-01-29T09:37:47.1318883Z","execution_finish_time":"2026-01-29T09:38:15.5400208Z","parent_msg_id":"7c40c51e-9fca-4e95-ab8a-318222f17f69"}},"metadata":{}},{"output_type":"stream","name":"stderr","text":["! Item definition is exported without its sensitivity label and its data\r\n"]},{"output_type":"stream","name":"stdout","text":["* 'SM_H7_fraud_analysis.SemanticModel' exported\r\n"]}],"execution_count":9,"metadata":{"microsoft":{"language":"python","language_group":"jupyter_python"}},"id":"0479f3ed-faea-4de6-b953-8289b0b27d90"}],"metadata":{"kernel_info":{"name":"jupyter","jupyter_kernel_name":"python3.11"},"kernelspec":{"name":"jupyter","display_name":"Jupyter"},"language_info":{"name":"python"},"microsoft":{"language":"python","language_group":"jupyter_python","ms_spell_check":{"ms_spell_check_language":"en"}},"nteract":{"version":"nteract-front-end@1.0.0"},"spark_compute":{"compute_id":"/trident/default","session_options":{"conf":{"spark.synapse.nbs.session.timeout":"1200000"}}},"dependencies":{"lakehouse":{"known_lakehouses":[{"id":"585d2c9f-6412-495f-a11a-f38880b79605"}],"default_lakehouse":"585d2c9f-6412-495f-a11a-f38880b79605","default_lakehouse_name":"LH_Esri","default_lakehouse_workspace_id":"bbf151a7-8c98-4648-a480-de2e83caf306"}}},"nbformat":4,"nbformat_minor":5} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment