semantic-link-labs 0.12.4__py3-none-any.whl → 0.12.5__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.

Potentially problematic release.


This version of semantic-link-labs might be problematic. Click here for more details.

@@ -1,209 +0,0 @@
1
- import pandas as pd
2
- from sempy_labs._helper_functions import (
3
- _is_valid_uuid,
4
- _base_api,
5
- _update_dataframe_datatypes,
6
- _create_dataframe,
7
- )
8
- import sempy_labs._icons as icons
9
- from uuid import UUID
10
- from sempy._utils._log import log
11
-
12
-
13
- @log
14
- def list_deployment_pipelines() -> pd.DataFrame:
15
- """
16
- Shows a list of deployment pipelines the user can access.
17
-
18
- This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipelines <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipelines>`_.
19
-
20
- Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
21
-
22
- Returns
23
- -------
24
- pandas.DataFrame
25
- A pandas dataframe showing a list of deployment pipelines the user can access.
26
- """
27
-
28
- columns = {
29
- "Deployment Pipeline Id": "string",
30
- "Deployment Pipeline Name": "string",
31
- "Description": "string",
32
- }
33
- df = _create_dataframe(columns=columns)
34
-
35
- responses = _base_api(
36
- request="/v1/deploymentPipelines",
37
- status_codes=200,
38
- uses_pagination=True,
39
- client="fabric_sp",
40
- )
41
-
42
- rows = []
43
- for r in responses:
44
- for v in r.get("value", []):
45
- rows.append(
46
- {
47
- "Deployment Pipeline Id": v.get("id"),
48
- "Deployment Pipeline Name": v.get("displayName"),
49
- "Description": v.get("description"),
50
- }
51
- )
52
-
53
- if rows:
54
- df = pd.DataFrame(rows, columns=columns.keys())
55
-
56
- return df
57
-
58
-
59
- @log
60
- def list_deployment_pipeline_stages(deployment_pipeline: str | UUID) -> pd.DataFrame:
61
- """
62
- Shows the specified deployment pipeline stages.
63
-
64
- This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipeline Stages <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipeline-stages>`_.
65
-
66
- Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
67
-
68
- Parameters
69
- ----------
70
- deployment_pipeline : str | uuid.UUID
71
- The deployment pipeline name or ID.
72
-
73
- Returns
74
- -------
75
- pandas.DataFrame
76
- A pandas dataframe showing the specified deployment pipeline stages.
77
- """
78
-
79
- from sempy_labs._helper_functions import resolve_deployment_pipeline_id
80
-
81
- columns = {
82
- "Deployment Pipeline Stage Id": "string",
83
- "Deployment Pipeline Stage Name": "string",
84
- "Order": "int",
85
- "Description": "string",
86
- "Workspace Id": "string",
87
- "Workspace Name": "string",
88
- "Public": "bool",
89
- }
90
- df = _create_dataframe(columns=columns)
91
-
92
- deployment_pipeline_id = resolve_deployment_pipeline_id(
93
- deployment_pipeline=deployment_pipeline
94
- )
95
-
96
- responses = _base_api(
97
- request=f"/v1/deploymentPipelines/{deployment_pipeline_id}/stages",
98
- status_codes=200,
99
- uses_pagination=True,
100
- client="fabric_sp",
101
- )
102
-
103
- rows = []
104
- for r in responses:
105
- for v in r.get("value", []):
106
- rows.append(
107
- {
108
- "Deployment Pipeline Stage Id": v.get("id"),
109
- "Deployment Pipeline Stage Name": v.get("displayName"),
110
- "Description": v.get("description"),
111
- "Order": v.get("order"),
112
- "Workspace Id": v.get("workspaceId"),
113
- "Workspace Name": v.get("workspaceName"),
114
- "Public": v.get("isPublic"),
115
- }
116
- )
117
- if rows:
118
- df = pd.DataFrame(rows, columns=list(columns.keys()))
119
- _update_dataframe_datatypes(df, columns)
120
-
121
- return df
122
-
123
-
124
- @log
125
- def list_deployment_pipeline_stage_items(
126
- deployment_pipeline: str | UUID,
127
- stage: str | UUID,
128
- ) -> pd.DataFrame:
129
- """
130
- Shows the supported items from the workspace assigned to the specified stage of the specified deployment pipeline.
131
-
132
- This is a wrapper function for the following API: `Deployment Pipelines - List Deployment Pipeline Stage Items <https://learn.microsoft.com/rest/api/fabric/core/deployment-pipelines/list-deployment-pipeline-stage-items>`_.
133
-
134
- Service Principal Authentication is supported (see `here <https://github.com/microsoft/semantic-link-labs/blob/main/notebooks/Service%20Principal.ipynb>`_ for examples).
135
-
136
- Parameters
137
- ----------
138
- deployment_pipeline : str | uuid.UUID
139
- The deployment pipeline name or ID.
140
- stage : str | uuid.UUID
141
- The deployment pipeline stage name or ID.
142
-
143
- Returns
144
- -------
145
- pandas.DataFrame
146
- A pandas dataframe showing the supported items from the workspace assigned to the specified stage of the specified deployment pipeline.
147
- """
148
-
149
- from sempy_labs._helper_functions import resolve_deployment_pipeline_id
150
-
151
- columns = {
152
- "Deployment Pipeline Stage Item Id": "string",
153
- "Deployment Pipeline Stage Item Name": "string",
154
- "Item Type": "string",
155
- "Source Item Id": "string",
156
- "Target Item Id": "string",
157
- "Last Deployment Time": "string",
158
- }
159
- df = _create_dataframe(columns=columns)
160
-
161
- deployment_pipeline_id = resolve_deployment_pipeline_id(
162
- deployment_pipeline=deployment_pipeline
163
- )
164
-
165
- def resolve_deployment_pipeline_stage_id(
166
- deployment_pipeline_id: UUID, stage: str | UUID
167
- ):
168
-
169
- dfPS = list_deployment_pipeline_stages(
170
- deployment_pipeline=deployment_pipeline_id
171
- )
172
-
173
- if _is_valid_uuid(stage):
174
- dfPS_filt = dfPS[dfPS["Deployment Pipeline Stage Id"] == stage]
175
- else:
176
- dfPS_filt = dfPS[dfPS["Deployment Pipeline Stage Name"] == stage]
177
- if dfPS.empty:
178
- raise ValueError(
179
- f"{icons.red_dot} The '{stage}' stage does not exist within the '{deployment_pipeline}' deployment pipeline."
180
- )
181
- return dfPS_filt["Deployment Pipeline Stage Id"].iloc[0]
182
-
183
- stage_id = resolve_deployment_pipeline_stage_id(deployment_pipeline_id, stage)
184
-
185
- responses = _base_api(
186
- request=f"/v1/deploymentPipelines/{deployment_pipeline_id}/stages/{stage_id}/items",
187
- status_codes=200,
188
- uses_pagination=True,
189
- client="fabric_sp",
190
- )
191
-
192
- rows = []
193
- for r in responses:
194
- for v in r.get("value", []):
195
- rows.append(
196
- {
197
- "Deployment Pipeline Stage Item Id": v.get("itemId"),
198
- "Deployment Pipeline Stage Item Name": v.get("itemDisplayName"),
199
- "Item Type": v.get("itemType"),
200
- "Source Item Id": v.get("sourceItemId"),
201
- "Target Item Id": v.get("targetItemId"),
202
- "Last Deployment Time": v.get("lastDeploymentTime"),
203
- }
204
- )
205
-
206
- if rows:
207
- df = pd.DataFrame(rows, columns=list(columns.keys()))
208
-
209
- return df