semantic-link-labs 0.12.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- semantic_link_labs-0.12.8.dist-info/METADATA +354 -0
- semantic_link_labs-0.12.8.dist-info/RECORD +243 -0
- semantic_link_labs-0.12.8.dist-info/WHEEL +5 -0
- semantic_link_labs-0.12.8.dist-info/licenses/LICENSE +21 -0
- semantic_link_labs-0.12.8.dist-info/top_level.txt +1 -0
- sempy_labs/__init__.py +606 -0
- sempy_labs/_a_lib_info.py +2 -0
- sempy_labs/_ai.py +437 -0
- sempy_labs/_authentication.py +264 -0
- sempy_labs/_bpa_translation/_model/_translations_am-ET.po +869 -0
- sempy_labs/_bpa_translation/_model/_translations_ar-AE.po +908 -0
- sempy_labs/_bpa_translation/_model/_translations_bg-BG.po +968 -0
- sempy_labs/_bpa_translation/_model/_translations_ca-ES.po +963 -0
- sempy_labs/_bpa_translation/_model/_translations_cs-CZ.po +943 -0
- sempy_labs/_bpa_translation/_model/_translations_da-DK.po +945 -0
- sempy_labs/_bpa_translation/_model/_translations_de-DE.po +988 -0
- sempy_labs/_bpa_translation/_model/_translations_el-GR.po +993 -0
- sempy_labs/_bpa_translation/_model/_translations_es-ES.po +971 -0
- sempy_labs/_bpa_translation/_model/_translations_fa-IR.po +933 -0
- sempy_labs/_bpa_translation/_model/_translations_fi-FI.po +942 -0
- sempy_labs/_bpa_translation/_model/_translations_fr-FR.po +994 -0
- sempy_labs/_bpa_translation/_model/_translations_ga-IE.po +967 -0
- sempy_labs/_bpa_translation/_model/_translations_he-IL.po +902 -0
- sempy_labs/_bpa_translation/_model/_translations_hi-IN.po +944 -0
- sempy_labs/_bpa_translation/_model/_translations_hu-HU.po +963 -0
- sempy_labs/_bpa_translation/_model/_translations_id-ID.po +946 -0
- sempy_labs/_bpa_translation/_model/_translations_is-IS.po +939 -0
- sempy_labs/_bpa_translation/_model/_translations_it-IT.po +986 -0
- sempy_labs/_bpa_translation/_model/_translations_ja-JP.po +846 -0
- sempy_labs/_bpa_translation/_model/_translations_ko-KR.po +839 -0
- sempy_labs/_bpa_translation/_model/_translations_mt-MT.po +967 -0
- sempy_labs/_bpa_translation/_model/_translations_nl-NL.po +978 -0
- sempy_labs/_bpa_translation/_model/_translations_pl-PL.po +962 -0
- sempy_labs/_bpa_translation/_model/_translations_pt-BR.po +962 -0
- sempy_labs/_bpa_translation/_model/_translations_pt-PT.po +957 -0
- sempy_labs/_bpa_translation/_model/_translations_ro-RO.po +968 -0
- sempy_labs/_bpa_translation/_model/_translations_ru-RU.po +964 -0
- sempy_labs/_bpa_translation/_model/_translations_sk-SK.po +952 -0
- sempy_labs/_bpa_translation/_model/_translations_sl-SL.po +950 -0
- sempy_labs/_bpa_translation/_model/_translations_sv-SE.po +942 -0
- sempy_labs/_bpa_translation/_model/_translations_ta-IN.po +976 -0
- sempy_labs/_bpa_translation/_model/_translations_te-IN.po +947 -0
- sempy_labs/_bpa_translation/_model/_translations_th-TH.po +924 -0
- sempy_labs/_bpa_translation/_model/_translations_tr-TR.po +953 -0
- sempy_labs/_bpa_translation/_model/_translations_uk-UA.po +961 -0
- sempy_labs/_bpa_translation/_model/_translations_zh-CN.po +804 -0
- sempy_labs/_bpa_translation/_model/_translations_zu-ZA.po +969 -0
- sempy_labs/_capacities.py +1198 -0
- sempy_labs/_capacity_migration.py +660 -0
- sempy_labs/_clear_cache.py +351 -0
- sempy_labs/_connections.py +610 -0
- sempy_labs/_dashboards.py +69 -0
- sempy_labs/_data_access_security.py +98 -0
- sempy_labs/_data_pipelines.py +162 -0
- sempy_labs/_dataflows.py +668 -0
- sempy_labs/_dax.py +501 -0
- sempy_labs/_daxformatter.py +80 -0
- sempy_labs/_delta_analyzer.py +467 -0
- sempy_labs/_delta_analyzer_history.py +301 -0
- sempy_labs/_dictionary_diffs.py +221 -0
- sempy_labs/_documentation.py +147 -0
- sempy_labs/_domains.py +51 -0
- sempy_labs/_eventhouses.py +182 -0
- sempy_labs/_external_data_shares.py +230 -0
- sempy_labs/_gateways.py +521 -0
- sempy_labs/_generate_semantic_model.py +521 -0
- sempy_labs/_get_connection_string.py +84 -0
- sempy_labs/_git.py +543 -0
- sempy_labs/_graphQL.py +90 -0
- sempy_labs/_helper_functions.py +2833 -0
- sempy_labs/_icons.py +149 -0
- sempy_labs/_job_scheduler.py +609 -0
- sempy_labs/_kql_databases.py +149 -0
- sempy_labs/_kql_querysets.py +124 -0
- sempy_labs/_kusto.py +137 -0
- sempy_labs/_labels.py +124 -0
- sempy_labs/_list_functions.py +1720 -0
- sempy_labs/_managed_private_endpoints.py +253 -0
- sempy_labs/_mirrored_databases.py +416 -0
- sempy_labs/_mirrored_warehouses.py +60 -0
- sempy_labs/_ml_experiments.py +113 -0
- sempy_labs/_model_auto_build.py +140 -0
- sempy_labs/_model_bpa.py +557 -0
- sempy_labs/_model_bpa_bulk.py +378 -0
- sempy_labs/_model_bpa_rules.py +859 -0
- sempy_labs/_model_dependencies.py +343 -0
- sempy_labs/_mounted_data_factories.py +123 -0
- sempy_labs/_notebooks.py +441 -0
- sempy_labs/_one_lake_integration.py +151 -0
- sempy_labs/_onelake.py +131 -0
- sempy_labs/_query_scale_out.py +433 -0
- sempy_labs/_refresh_semantic_model.py +435 -0
- sempy_labs/_semantic_models.py +468 -0
- sempy_labs/_spark.py +455 -0
- sempy_labs/_sql.py +241 -0
- sempy_labs/_sql_audit_settings.py +207 -0
- sempy_labs/_sql_endpoints.py +214 -0
- sempy_labs/_tags.py +201 -0
- sempy_labs/_translations.py +43 -0
- sempy_labs/_user_delegation_key.py +44 -0
- sempy_labs/_utils.py +79 -0
- sempy_labs/_vertipaq.py +1021 -0
- sempy_labs/_vpax.py +388 -0
- sempy_labs/_warehouses.py +234 -0
- sempy_labs/_workloads.py +140 -0
- sempy_labs/_workspace_identity.py +72 -0
- sempy_labs/_workspaces.py +595 -0
- sempy_labs/admin/__init__.py +170 -0
- sempy_labs/admin/_activities.py +167 -0
- sempy_labs/admin/_apps.py +145 -0
- sempy_labs/admin/_artifacts.py +65 -0
- sempy_labs/admin/_basic_functions.py +463 -0
- sempy_labs/admin/_capacities.py +508 -0
- sempy_labs/admin/_dataflows.py +45 -0
- sempy_labs/admin/_datasets.py +186 -0
- sempy_labs/admin/_domains.py +522 -0
- sempy_labs/admin/_external_data_share.py +100 -0
- sempy_labs/admin/_git.py +72 -0
- sempy_labs/admin/_items.py +265 -0
- sempy_labs/admin/_labels.py +211 -0
- sempy_labs/admin/_reports.py +241 -0
- sempy_labs/admin/_scanner.py +118 -0
- sempy_labs/admin/_shared.py +82 -0
- sempy_labs/admin/_sharing_links.py +110 -0
- sempy_labs/admin/_tags.py +131 -0
- sempy_labs/admin/_tenant.py +503 -0
- sempy_labs/admin/_tenant_keys.py +89 -0
- sempy_labs/admin/_users.py +140 -0
- sempy_labs/admin/_workspaces.py +236 -0
- sempy_labs/deployment_pipeline/__init__.py +23 -0
- sempy_labs/deployment_pipeline/_items.py +580 -0
- sempy_labs/directlake/__init__.py +57 -0
- sempy_labs/directlake/_autosync.py +58 -0
- sempy_labs/directlake/_directlake_schema_compare.py +120 -0
- sempy_labs/directlake/_directlake_schema_sync.py +161 -0
- sempy_labs/directlake/_dl_helper.py +274 -0
- sempy_labs/directlake/_generate_shared_expression.py +94 -0
- sempy_labs/directlake/_get_directlake_lakehouse.py +62 -0
- sempy_labs/directlake/_get_shared_expression.py +34 -0
- sempy_labs/directlake/_guardrails.py +96 -0
- sempy_labs/directlake/_list_directlake_model_calc_tables.py +70 -0
- sempy_labs/directlake/_show_unsupported_directlake_objects.py +90 -0
- sempy_labs/directlake/_update_directlake_model_lakehouse_connection.py +239 -0
- sempy_labs/directlake/_update_directlake_partition_entity.py +259 -0
- sempy_labs/directlake/_warm_cache.py +236 -0
- sempy_labs/dotnet_lib/dotnet.runtime.config.json +10 -0
- sempy_labs/environment/__init__.py +23 -0
- sempy_labs/environment/_items.py +212 -0
- sempy_labs/environment/_pubstage.py +223 -0
- sempy_labs/eventstream/__init__.py +37 -0
- sempy_labs/eventstream/_items.py +263 -0
- sempy_labs/eventstream/_topology.py +652 -0
- sempy_labs/graph/__init__.py +59 -0
- sempy_labs/graph/_groups.py +651 -0
- sempy_labs/graph/_sensitivity_labels.py +120 -0
- sempy_labs/graph/_teams.py +125 -0
- sempy_labs/graph/_user_licenses.py +96 -0
- sempy_labs/graph/_users.py +516 -0
- sempy_labs/graph_model/__init__.py +15 -0
- sempy_labs/graph_model/_background_jobs.py +63 -0
- sempy_labs/graph_model/_items.py +149 -0
- sempy_labs/lakehouse/__init__.py +67 -0
- sempy_labs/lakehouse/_blobs.py +247 -0
- sempy_labs/lakehouse/_get_lakehouse_columns.py +102 -0
- sempy_labs/lakehouse/_get_lakehouse_tables.py +274 -0
- sempy_labs/lakehouse/_helper.py +250 -0
- sempy_labs/lakehouse/_lakehouse.py +351 -0
- sempy_labs/lakehouse/_livy_sessions.py +143 -0
- sempy_labs/lakehouse/_materialized_lake_views.py +157 -0
- sempy_labs/lakehouse/_partitioning.py +165 -0
- sempy_labs/lakehouse/_schemas.py +217 -0
- sempy_labs/lakehouse/_shortcuts.py +440 -0
- sempy_labs/migration/__init__.py +35 -0
- sempy_labs/migration/_create_pqt_file.py +238 -0
- sempy_labs/migration/_direct_lake_to_import.py +105 -0
- sempy_labs/migration/_migrate_calctables_to_lakehouse.py +398 -0
- sempy_labs/migration/_migrate_calctables_to_semantic_model.py +148 -0
- sempy_labs/migration/_migrate_model_objects_to_semantic_model.py +533 -0
- sempy_labs/migration/_migrate_tables_columns_to_semantic_model.py +172 -0
- sempy_labs/migration/_migration_validation.py +71 -0
- sempy_labs/migration/_refresh_calc_tables.py +131 -0
- sempy_labs/mirrored_azure_databricks_catalog/__init__.py +15 -0
- sempy_labs/mirrored_azure_databricks_catalog/_discover.py +213 -0
- sempy_labs/mirrored_azure_databricks_catalog/_refresh_catalog_metadata.py +45 -0
- sempy_labs/ml_model/__init__.py +23 -0
- sempy_labs/ml_model/_functions.py +427 -0
- sempy_labs/report/_BPAReportTemplate.json +232 -0
- sempy_labs/report/__init__.py +55 -0
- sempy_labs/report/_bpareporttemplate/.pbi/localSettings.json +9 -0
- sempy_labs/report/_bpareporttemplate/.platform +11 -0
- sempy_labs/report/_bpareporttemplate/StaticResources/SharedResources/BaseThemes/CY24SU06.json +710 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/page.json +11 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/1b08bce3bebabb0a27a8/visual.json +191 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/2f22ddb70c301693c165/visual.json +438 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/3b1182230aa6c600b43a/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/58577ba6380c69891500/visual.json +576 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/a2a8fa5028b3b776c96c/visual.json +207 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/adfd47ef30652707b987/visual.json +506 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/b6a80ee459e716e170b1/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/01d72098bda5055bd500/visuals/ce3130a721c020cc3d81/visual.json +513 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/page.json +8 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/92735ae19b31712208ad/visuals/66e60dfb526437cd78d1/visual.json +112 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/page.json +11 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/07deb8bce824e1be37d7/visual.json +513 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0b1c68838818b32ad03b/visual.json +352 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0c171de9d2683d10b930/visual.json +37 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/0efa01be0510e40a645e/visual.json +542 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/6bf2f0eb830ab53cc668/visual.json +221 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/88d8141cb8500b60030c/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/a753273590beed656a03/visual.json +576 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/c597da16dc7e63222a82/visuals/b8fdc82cddd61ac447bc/visual.json +127 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/page.json +9 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/d37dce724a0ccc30044b/visuals/ce8532a7e25020271077/visual.json +38 -0
- sempy_labs/report/_bpareporttemplate/definition/pages/pages.json +10 -0
- sempy_labs/report/_bpareporttemplate/definition/report.json +176 -0
- sempy_labs/report/_bpareporttemplate/definition/version.json +4 -0
- sempy_labs/report/_bpareporttemplate/definition.pbir +14 -0
- sempy_labs/report/_download_report.py +76 -0
- sempy_labs/report/_export_report.py +257 -0
- sempy_labs/report/_generate_report.py +427 -0
- sempy_labs/report/_paginated.py +76 -0
- sempy_labs/report/_report_bpa.py +354 -0
- sempy_labs/report/_report_bpa_rules.py +115 -0
- sempy_labs/report/_report_functions.py +581 -0
- sempy_labs/report/_report_helper.py +227 -0
- sempy_labs/report/_report_list_functions.py +110 -0
- sempy_labs/report/_report_rebind.py +149 -0
- sempy_labs/report/_reportwrapper.py +3100 -0
- sempy_labs/report/_save_report.py +147 -0
- sempy_labs/snowflake_database/__init__.py +10 -0
- sempy_labs/snowflake_database/_items.py +105 -0
- sempy_labs/sql_database/__init__.py +21 -0
- sempy_labs/sql_database/_items.py +201 -0
- sempy_labs/sql_database/_mirroring.py +79 -0
- sempy_labs/theme/__init__.py +12 -0
- sempy_labs/theme/_org_themes.py +129 -0
- sempy_labs/tom/__init__.py +3 -0
- sempy_labs/tom/_model.py +5977 -0
- sempy_labs/variable_library/__init__.py +19 -0
- sempy_labs/variable_library/_functions.py +403 -0
- sempy_labs/warehouse/__init__.py +28 -0
- sempy_labs/warehouse/_items.py +234 -0
- sempy_labs/warehouse/_restore_points.py +309 -0
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from typing import Any, Optional, List
|
|
3
|
+
from sempy_labs._helper_functions import (
|
|
4
|
+
_update_dataframe_datatypes,
|
|
5
|
+
resolve_item_id,
|
|
6
|
+
resolve_item_name_and_id,
|
|
7
|
+
resolve_workspace_id,
|
|
8
|
+
_base_api,
|
|
9
|
+
delete_item,
|
|
10
|
+
_create_dataframe,
|
|
11
|
+
create_item,
|
|
12
|
+
resolve_workspace_name_and_id,
|
|
13
|
+
)
|
|
14
|
+
from uuid import UUID
|
|
15
|
+
from sempy._utils._log import log
|
|
16
|
+
import sempy_labs._icons as icons
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@log
|
|
20
|
+
def list_ml_models(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
|
|
21
|
+
"""
|
|
22
|
+
Shows the ML models within a workspace.
|
|
23
|
+
|
|
24
|
+
This is a wrapper function for the following API: `Items - List ML Models <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/list-ml-models>`_.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
workspace : str | uuid.UUID, default=None
|
|
29
|
+
The Fabric workspace name or ID.
|
|
30
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
31
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
pandas.DataFrame
|
|
36
|
+
A pandas dataframe showing the ML models within a workspace.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
columns = {
|
|
40
|
+
"ML Model Name": "string",
|
|
41
|
+
"ML Model Id": "string",
|
|
42
|
+
"Description": "string",
|
|
43
|
+
}
|
|
44
|
+
df = _create_dataframe(columns=columns)
|
|
45
|
+
|
|
46
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
47
|
+
|
|
48
|
+
responses = _base_api(
|
|
49
|
+
request=f"/v1/workspaces/{workspace_id}/mlModels",
|
|
50
|
+
status_codes=200,
|
|
51
|
+
uses_pagination=True,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
rows = []
|
|
55
|
+
for r in responses:
|
|
56
|
+
for v in r.get("value", []):
|
|
57
|
+
model_id = v.get("id")
|
|
58
|
+
modelName = v.get("displayName")
|
|
59
|
+
desc = v.get("description")
|
|
60
|
+
|
|
61
|
+
rows.append(
|
|
62
|
+
{
|
|
63
|
+
"ML Model Name": modelName,
|
|
64
|
+
"ML Model Id": model_id,
|
|
65
|
+
"Description": desc,
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if rows:
|
|
70
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
71
|
+
|
|
72
|
+
return df
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@log
|
|
76
|
+
def create_ml_model(
|
|
77
|
+
name: str, description: Optional[str] = None, workspace: Optional[str | UUID] = None
|
|
78
|
+
):
|
|
79
|
+
"""
|
|
80
|
+
Creates a Fabric ML model.
|
|
81
|
+
|
|
82
|
+
This is a wrapper function for the following API: `Items - Create ML Model <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/create-ml-model>`_.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
name: str
|
|
87
|
+
Name of the ML model.
|
|
88
|
+
description : str, default=None
|
|
89
|
+
A description of the ML model.
|
|
90
|
+
workspace : str | uuid.UUID, default=None
|
|
91
|
+
The Fabric workspace name or ID.
|
|
92
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
93
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
create_item(name=name, description=description, type="MLModel", workspace=workspace)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@log
|
|
100
|
+
def delete_ml_model(ml_model: str | UUID, workspace: Optional[str | UUID] = None):
|
|
101
|
+
"""
|
|
102
|
+
Deletes a Fabric ML model.
|
|
103
|
+
|
|
104
|
+
This is a wrapper function for the following API: `Items - Delete ML Model <https://learn.microsoft.com/rest/api/fabric/mlmodel/items/delete-ml-model>`_.
|
|
105
|
+
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
ml_model: str | uuid.UUID
|
|
109
|
+
Name or ID of the ML model.
|
|
110
|
+
workspace : str | uuid.UUID, default=None
|
|
111
|
+
The Fabric workspace name or ID.
|
|
112
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
113
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
114
|
+
"""
|
|
115
|
+
|
|
116
|
+
delete_item(item=ml_model, type="MLModel", workspace=workspace)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@log
|
|
120
|
+
def activate_ml_model_endpoint_version(
|
|
121
|
+
ml_model: str | UUID, name: str, workspace: Optional[str | UUID] = None
|
|
122
|
+
):
|
|
123
|
+
"""
|
|
124
|
+
Activates the specified model version endpoint.
|
|
125
|
+
|
|
126
|
+
This is a wrapper function for the following API: `Endpoint - Activate ML Model Endpoint Version <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/activate-ml-model-endpoint-version>`_.
|
|
127
|
+
|
|
128
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
ml_model: str | uuid.UUID
|
|
133
|
+
Name or ID of the ML model.
|
|
134
|
+
name: str
|
|
135
|
+
The ML model version name.
|
|
136
|
+
workspace : str | uuid.UUID, default=None
|
|
137
|
+
The Fabric workspace name or ID.
|
|
138
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
139
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
143
|
+
(model_name, model_id) = resolve_item_name_and_id(
|
|
144
|
+
item=ml_model, type="MLModel", workspace=workspace
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
_base_api(
|
|
148
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/versions/{name}/activate",
|
|
149
|
+
method="post",
|
|
150
|
+
client="fabric_sp",
|
|
151
|
+
lro_return_status_code=True,
|
|
152
|
+
status_codes=[200, 202],
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
print(
|
|
156
|
+
f"{icons.green_dot} The {model_name} model version {name} has been activated in the {workspace_name} workspace."
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
@log
|
|
161
|
+
def deactivate_ml_model_endpoint_version(
|
|
162
|
+
ml_model: str | UUID, name: str, workspace: Optional[str | UUID] = None
|
|
163
|
+
):
|
|
164
|
+
"""
|
|
165
|
+
Deactivates the specified model version endpoint.
|
|
166
|
+
|
|
167
|
+
This is a wrapper function for the following API: `Endpoint - Deactivate ML Model Endpoint Version <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/deactivate-ml-model-endpoint-version>`_.
|
|
168
|
+
|
|
169
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
170
|
+
|
|
171
|
+
Parameters
|
|
172
|
+
----------
|
|
173
|
+
ml_model: str | uuid.UUID
|
|
174
|
+
Name or ID of the ML model.
|
|
175
|
+
name: str
|
|
176
|
+
The ML model version name.
|
|
177
|
+
workspace : str | uuid.UUID, default=None
|
|
178
|
+
The Fabric workspace name or ID.
|
|
179
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
180
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
184
|
+
(model_name, model_id) = resolve_item_name_and_id(
|
|
185
|
+
item=ml_model, type="MLModel", workspace=workspace
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
_base_api(
|
|
189
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/versions/{name}/deactivate",
|
|
190
|
+
method="post",
|
|
191
|
+
client="fabric_sp",
|
|
192
|
+
lro_return_status_code=True,
|
|
193
|
+
status_codes=[200, 202],
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
print(
|
|
197
|
+
f"{icons.green_dot} The {model_name} model version {name} has been deactivated in the {workspace_name} workspace."
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
@log
|
|
202
|
+
def deactivate_all_ml_model_endpoint_versions(
|
|
203
|
+
ml_model: str | UUID, workspace: Optional[str | UUID] = None
|
|
204
|
+
):
|
|
205
|
+
"""
|
|
206
|
+
Deactivates the specified machine learning model and its version's endpoints.
|
|
207
|
+
|
|
208
|
+
This is a wrapper function for the following API: `Endpoint - Deactivate All ML Model Endpoint Versions <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/deactivate-all-ml-model-endpoint-versions>`_.
|
|
209
|
+
|
|
210
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
ml_model: str | uuid.UUID
|
|
215
|
+
Name or ID of the ML model.
|
|
216
|
+
workspace : str | uuid.UUID, default=None
|
|
217
|
+
The Fabric workspace name or ID.
|
|
218
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
219
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)
|
|
223
|
+
(model_name, model_id) = resolve_item_name_and_id(
|
|
224
|
+
item=ml_model, type="MLModel", workspace=workspace
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
_base_api(
|
|
228
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/versions/deactivateAll",
|
|
229
|
+
method="post",
|
|
230
|
+
client="fabric_sp",
|
|
231
|
+
lro_return_status_code=True,
|
|
232
|
+
status_codes=[200, 202],
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
print(
|
|
236
|
+
f"{icons.green_dot} All endpoint versions of the {model_name} model within the {workspace_name} workspace have been deactivated."
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@log
|
|
241
|
+
def list_ml_model_endpoint_versions(
|
|
242
|
+
ml_model: str | UUID, workspace: Optional[str | UUID] = None
|
|
243
|
+
) -> pd.DataFrame:
|
|
244
|
+
"""
|
|
245
|
+
Lists all machine learning model endpoint versions.
|
|
246
|
+
|
|
247
|
+
This is a wrapper function for the following API: `Endpoint - List ML Model Endpoint Versions <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/list-ml-model-endpoint-versions>`_.
|
|
248
|
+
|
|
249
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
250
|
+
|
|
251
|
+
Parameters
|
|
252
|
+
----------
|
|
253
|
+
ml_model: str | uuid.UUID
|
|
254
|
+
Name or ID of the ML model.
|
|
255
|
+
workspace : str | uuid.UUID, default=None
|
|
256
|
+
The Fabric workspace name or ID.
|
|
257
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
258
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
259
|
+
|
|
260
|
+
Returns
|
|
261
|
+
-------
|
|
262
|
+
pandas.DataFrame
|
|
263
|
+
A pandas dataframe showing the ML model endpoint versions within a workspace.
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
267
|
+
model_id = resolve_item_id(item=ml_model, type="MLModel", workspace=workspace)
|
|
268
|
+
|
|
269
|
+
columns = {
|
|
270
|
+
"Version Name": "string",
|
|
271
|
+
"Status": "string",
|
|
272
|
+
"Type": "string",
|
|
273
|
+
"Name": "string",
|
|
274
|
+
"Required": "bool",
|
|
275
|
+
"Scale Rule": "string",
|
|
276
|
+
}
|
|
277
|
+
df = _create_dataframe(columns=columns)
|
|
278
|
+
|
|
279
|
+
responses = _base_api(
|
|
280
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/versions",
|
|
281
|
+
client="fabric_sp",
|
|
282
|
+
uses_pagination=True,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
rows = []
|
|
286
|
+
for r in responses:
|
|
287
|
+
for version in r.get("value", []):
|
|
288
|
+
base = {
|
|
289
|
+
"Version Name": version.get("versionName"),
|
|
290
|
+
"Status": version.get("status"),
|
|
291
|
+
"Scale Rule": version.get("scaleRule"),
|
|
292
|
+
}
|
|
293
|
+
for sig_type in ["inputSignature", "outputSignature"]:
|
|
294
|
+
for entry in version.get(sig_type, []):
|
|
295
|
+
rows.append(
|
|
296
|
+
{
|
|
297
|
+
**base,
|
|
298
|
+
"Signature Type": (
|
|
299
|
+
"Input" if sig_type == "inputSignature" else "Output"
|
|
300
|
+
),
|
|
301
|
+
"Name": entry.get("name"),
|
|
302
|
+
"Type": entry.get("type"),
|
|
303
|
+
"Required": entry.get("required"),
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
# Handle versions with no signatures
|
|
307
|
+
if "inputSignature" not in version and "outputSignature" not in version:
|
|
308
|
+
rows.append(base)
|
|
309
|
+
|
|
310
|
+
if rows:
|
|
311
|
+
df = pd.DataFrame(rows, columns=list(columns.keys()))
|
|
312
|
+
_update_dataframe_datatypes(dataframe=df, column_map=columns)
|
|
313
|
+
|
|
314
|
+
return df
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
@log
|
|
318
|
+
def score_ml_model_endpoint(
|
|
319
|
+
ml_model: str | UUID,
|
|
320
|
+
inputs: List[List[Any]],
|
|
321
|
+
orientation: str = "values",
|
|
322
|
+
workspace: Optional[str | UUID] = None,
|
|
323
|
+
) -> dict:
|
|
324
|
+
"""
|
|
325
|
+
Scores input data using the default version of the endpoint and returns results.
|
|
326
|
+
|
|
327
|
+
This is a wrapper function for the following API: `Endpoint - Score ML Model Endpoint <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/score-ml-model-endpoint>`_.
|
|
328
|
+
|
|
329
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
330
|
+
|
|
331
|
+
Parameters
|
|
332
|
+
----------
|
|
333
|
+
ml_model: str | uuid.UUID
|
|
334
|
+
Name or ID of the ML model.
|
|
335
|
+
inputs: List[List[Any]]
|
|
336
|
+
Machine learning inputs to score in the form of Pandas dataset arrays that can include strings, numbers, integers and booleans.
|
|
337
|
+
orientation: str, default='values'
|
|
338
|
+
`Orientation <https://learn.microsoft.com/en-us/rest/api/fabric/mlmodel/endpoint/score-ml-model-endpoint?tabs=HTTP#orientation>`_ of the input data.
|
|
339
|
+
workspace : str | uuid.UUID, default=None
|
|
340
|
+
The Fabric workspace name or ID.
|
|
341
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
342
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
343
|
+
"""
|
|
344
|
+
|
|
345
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
346
|
+
model_id = resolve_item_id(item=ml_model, type="MLModel", workspace=workspace)
|
|
347
|
+
|
|
348
|
+
orientation = _validate_orientation(orientation)
|
|
349
|
+
payload = {
|
|
350
|
+
"formatType": "dataframe",
|
|
351
|
+
"orientation": orientation,
|
|
352
|
+
"inputs": inputs,
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
result = _base_api(
|
|
356
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/score",
|
|
357
|
+
method="post",
|
|
358
|
+
client="fabric_sp",
|
|
359
|
+
payload=payload,
|
|
360
|
+
lro_return_json=True,
|
|
361
|
+
status_codes=[200, 202],
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
return result
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
@log
|
|
368
|
+
def score_ml_model_endpoint_version(
|
|
369
|
+
ml_model: str | UUID,
|
|
370
|
+
name: str,
|
|
371
|
+
inputs: List[List[Any]],
|
|
372
|
+
orientation: str = "values",
|
|
373
|
+
workspace: Optional[str | UUID] = None,
|
|
374
|
+
) -> dict:
|
|
375
|
+
"""
|
|
376
|
+
Scores input data using the default version of the endpoint and returns results.
|
|
377
|
+
|
|
378
|
+
This is a wrapper function for the following API: `Endpoint - Score ML Model Endpoint Version <https://learn.microsoft.com/rest/api/fabric/mlmodel/endpoint/score-ml-model-endpoint-version>`_.
|
|
379
|
+
|
|
380
|
+
Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
|
|
381
|
+
|
|
382
|
+
Parameters
|
|
383
|
+
----------
|
|
384
|
+
ml_model: str | uuid.UUID
|
|
385
|
+
Name or ID of the ML model.
|
|
386
|
+
name: str
|
|
387
|
+
The ML model version name.
|
|
388
|
+
inputs: List[List[Any]]
|
|
389
|
+
Machine learning inputs to score in the form of Pandas dataset arrays that can include strings, numbers, integers and booleans.
|
|
390
|
+
orientation: str, default='values'
|
|
391
|
+
`Orientation <https://learn.microsoft.com/en-us/rest/api/fabric/mlmodel/endpoint/score-ml-model-endpoint?tabs=HTTP#orientation>`_ of the input data.
|
|
392
|
+
workspace : str | uuid.UUID, default=None
|
|
393
|
+
The Fabric workspace name or ID.
|
|
394
|
+
Defaults to None which resolves to the workspace of the attached lakehouse
|
|
395
|
+
or if no lakehouse attached, resolves to the workspace of the notebook.
|
|
396
|
+
"""
|
|
397
|
+
|
|
398
|
+
workspace_id = resolve_workspace_id(workspace)
|
|
399
|
+
model_id = resolve_item_id(item=ml_model, type="MLModel", workspace=workspace)
|
|
400
|
+
|
|
401
|
+
orientation = _validate_orientation(orientation)
|
|
402
|
+
payload = {
|
|
403
|
+
"formatType": "dataframe",
|
|
404
|
+
"orientation": orientation,
|
|
405
|
+
"inputs": inputs,
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
result = _base_api(
|
|
409
|
+
request=f"/v1/workspaces/{workspace_id}/mlmodels/{model_id}/endpoint/versions/{name}/score",
|
|
410
|
+
method="post",
|
|
411
|
+
client="fabric_sp",
|
|
412
|
+
payload=payload,
|
|
413
|
+
lro_return_json=True,
|
|
414
|
+
status_codes=[200, 202],
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
return result
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def _validate_orientation(orientation: str):
|
|
421
|
+
|
|
422
|
+
orientation = orientation.lower()
|
|
423
|
+
if orientation not in ["split", "values", "record", "index", "table"]:
|
|
424
|
+
raise ValueError(
|
|
425
|
+
f"Invalid orientation '{orientation}'. Must be one of 'split', 'values', 'record', 'index', or 'table'."
|
|
426
|
+
)
|
|
427
|
+
return orientation
|