msfabricpysdkcore 0.0.13__py3-none-any.whl → 0.1.1__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.
Files changed (43) hide show
  1. msfabricpysdkcore/admin_item.py +18 -44
  2. msfabricpysdkcore/admin_workspace.py +13 -60
  3. msfabricpysdkcore/adminapi.py +398 -475
  4. msfabricpysdkcore/client.py +115 -1
  5. msfabricpysdkcore/coreapi.py +2566 -821
  6. msfabricpysdkcore/deployment_pipeline.py +34 -146
  7. msfabricpysdkcore/domain.py +20 -219
  8. msfabricpysdkcore/environment.py +13 -172
  9. msfabricpysdkcore/item.py +55 -331
  10. msfabricpysdkcore/job_instance.py +8 -22
  11. msfabricpysdkcore/lakehouse.py +9 -118
  12. msfabricpysdkcore/long_running_operation.py +7 -37
  13. msfabricpysdkcore/onelakeshortcut.py +7 -21
  14. msfabricpysdkcore/otheritems.py +66 -91
  15. msfabricpysdkcore/spark_custom_pool.py +7 -47
  16. msfabricpysdkcore/tests/test_admin_apis.py +1 -1
  17. msfabricpysdkcore/tests/test_datapipelines.py +14 -17
  18. msfabricpysdkcore/tests/test_deployment_pipeline.py +3 -3
  19. msfabricpysdkcore/tests/test_domains.py +4 -3
  20. msfabricpysdkcore/tests/test_environments.py +51 -2
  21. msfabricpysdkcore/tests/test_evenhouses.py +48 -0
  22. msfabricpysdkcore/tests/test_evenstreams.py +1 -1
  23. msfabricpysdkcore/tests/test_items.py +80 -0
  24. msfabricpysdkcore/tests/test_kql_queryset.py +50 -0
  25. msfabricpysdkcore/tests/test_kqldatabases.py +1 -1
  26. msfabricpysdkcore/tests/test_lakehouse.py +86 -0
  27. msfabricpysdkcore/tests/test_ml_experiments.py +48 -0
  28. msfabricpysdkcore/tests/test_ml_models.py +48 -0
  29. msfabricpysdkcore/tests/test_notebooks.py +58 -0
  30. msfabricpysdkcore/tests/test_other_items.py +46 -0
  31. msfabricpysdkcore/tests/test_reports.py +53 -0
  32. msfabricpysdkcore/tests/test_semantic_model.py +51 -0
  33. msfabricpysdkcore/tests/test_spark.py +7 -5
  34. msfabricpysdkcore/tests/test_sparkjobdefinition.py +1 -1
  35. msfabricpysdkcore/tests/test_warehouses.py +51 -0
  36. msfabricpysdkcore/tests/test_workspaces_capacities.py +7 -4
  37. msfabricpysdkcore/workspace.py +397 -1163
  38. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.1.dist-info}/METADATA +9 -8
  39. msfabricpysdkcore-0.1.1.dist-info/RECORD +52 -0
  40. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.1.dist-info}/WHEEL +1 -1
  41. msfabricpysdkcore-0.0.13.dist-info/RECORD +0 -41
  42. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.1.dist-info}/LICENSE +0 -0
  43. {msfabricpysdkcore-0.0.13.dist-info → msfabricpysdkcore-0.1.1.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,4 @@
1
- import json
2
- import requests
3
- from time import sleep
4
-
5
1
  from msfabricpysdkcore.item import Item
6
- from msfabricpysdkcore.long_running_operation import check_long_running_operation
7
2
 
8
3
  class Environment(Item):
9
4
  """Class to represent a item in Microsoft Fabric"""
@@ -11,48 +6,19 @@ class Environment(Item):
11
6
  def __init__(self, id, display_name, type, workspace_id, auth, properties = None, definition=None, description=""):
12
7
  super().__init__(id, display_name, type, workspace_id, auth, properties, definition, description)
13
8
 
14
- def from_dict(item_dict, auth):
9
+ def from_dict(item_dict, core_client):
15
10
  return Environment(id=item_dict['id'], display_name=item_dict['displayName'], type=item_dict['type'], workspace_id=item_dict['workspaceId'],
16
11
  properties=item_dict.get('properties', None),
17
12
  definition=item_dict.get('definition', None), description=item_dict.get('description', ""),
18
- auth=auth)
13
+ auth=core_client)
19
14
 
20
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/sparkcompute
21
15
  def get_published_settings(self):
22
16
  """Get the published settings of the environment"""
23
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/sparkcompute"
24
-
25
- for _ in range(10):
26
- response = requests.get(url=url, headers=self.auth.get_headers())
27
- if response.status_code == 429:
28
- print("Too many requests, waiting 10 seconds")
29
- sleep(10)
30
- continue
31
- if response.status_code not in (200, 429):
32
- raise Exception(f"Error getting published settings: {response.status_code}, {response.text}")
33
- break
34
-
35
- resp_json = json.loads(response.text)
36
- return resp_json
17
+ return self.core_client.get_published_settings(self.workspace_id, self.id)
37
18
 
38
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/sparkcompute
39
-
40
19
  def get_staging_settings(self):
41
20
  """Get the staging settings of the environment"""
42
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/sparkcompute"
43
-
44
- for _ in range(10):
45
- response = requests.get(url=url, headers=self.auth.get_headers())
46
- if response.status_code == 429:
47
- print("Too many requests, waiting 10 seconds")
48
- sleep(10)
49
- continue
50
- if response.status_code not in (200, 429):
51
- raise Exception(f"Error getting staging settings: {response.status_code}, {response.text}")
52
- break
53
-
54
- resp_json = json.loads(response.text)
55
- return resp_json
21
+ return self.core_client.get_staging_settings(self.workspace_id, self.id)
56
22
 
57
23
 
58
24
  def update_staging_settings(self,
@@ -60,151 +26,26 @@ class Environment(Item):
60
26
  executor_cores = None, executor_memory = None, instance_pool = None,
61
27
  runtime_version = None, spark_properties = None):
62
28
  """Update the staging settings of the environment"""
63
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/sparkcompute"
64
- body = {}
65
- if driver_cores is not None:
66
- body['driverCores'] = driver_cores
67
- if driver_memory is not None:
68
- body['driverMemory'] = driver_memory
69
- if dynamic_executor_allocation is not None:
70
- body['dynamicExecutorAllocation'] = dynamic_executor_allocation
71
- if executor_cores is not None:
72
- body['executorCores'] = executor_cores
73
- if executor_memory is not None:
74
- body['executorMemory'] = executor_memory
75
- if instance_pool is not None:
76
- body['instancePool'] = instance_pool
77
- if runtime_version is not None:
78
- body['runtimeVersion'] = runtime_version
79
- if spark_properties is not None:
80
- body['sparkProperties'] = spark_properties
81
-
82
-
83
- for _ in range(10):
84
- response = requests.patch(url=url, headers=self.auth.get_headers(), json=body)
85
- if response.status_code == 429:
86
- print("Too many requests, waiting 10 seconds")
87
- sleep(10)
88
- continue
89
- if response.status_code not in (200, 429):
90
- raise Exception(f"Error updating staging settings: {response.status_code}, {response.text}")
91
- break
92
-
93
- return json.loads(response.text)
94
-
95
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/libraries
29
+ return self.core_client.update_staging_settings(self.workspace_id, self.id, driver_cores, driver_memory,
30
+ dynamic_executor_allocation, executor_cores, executor_memory,
31
+ instance_pool, runtime_version, spark_properties)
96
32
 
97
33
  def get_published_libraries(self):
98
34
  """Get the published libraries of the environment"""
99
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/libraries"
100
-
101
- for _ in range(10):
102
- response = requests.get(url=url, headers=self.auth.get_headers())
103
- if response.status_code == 429:
104
- print("Too many requests, waiting 10 seconds")
105
- sleep(10)
106
- continue
107
- if response.status_code not in (200, 429):
108
- raise Exception(f"Error getting published libraries: {response.status_code}, {response.text}")
109
- break
110
-
111
- resp_json = json.loads(response.text)
112
- return resp_json
35
+ return self.core_client.get_published_libraries(self.workspace_id, self.id)
113
36
 
114
- # GET https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
115
-
116
37
  def get_staging_libraries(self):
117
38
  """Get the staging libraries of the environment"""
118
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries"
119
-
120
- for _ in range(10):
121
- response = requests.get(url=url, headers=self.auth.get_headers())
122
- if response.status_code == 429:
123
- print("Too many requests, waiting 10 seconds")
124
- sleep(10)
125
- continue
126
- if response.status_code not in (200, 429):
127
- raise Exception(f"Error getting staging libraries: {response.status_code}, {response.text}")
128
- break
129
-
130
- resp_json = json.loads(response.text)
131
- return resp_json
39
+ return self.core_client.get_staging_libraries(self.workspace_id, self.id)
132
40
 
133
-
134
41
  def upload_staging_library(self, file_path):
135
- # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries
136
- raise NotImplementedError("Not implemented yet")
137
- # url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries"
138
- # with open(file_path, 'rb') as f:
139
- # files = {"upload_file.whl": f}
140
- # for _ in range(10):
141
- # response = requests.post(url=url, files=files, headers=self.auth.get_headers())
142
- # if response.status_code == 429:
143
- # print("Too many requests, waiting 10 seconds")
144
- # sleep(10)
145
- # continue
146
- # if response.status_code not in (200, 429):
147
- # raise Exception(f"Error uploading staging libraries: {response.status_code}, {response.text}")
148
- # break
149
-
150
- # return json.loads(response.text)
42
+ return self.core_client.upload_staging_library(self.workspace_id, self.id, file_path)
151
43
 
152
- # DELETE https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/libraries?libraryToDelete={libraryToDelete}
153
-
154
44
  def delete_staging_library(self, library_to_delete):
155
- """Delete a library from the staging libraries of the environment"""
156
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/libraries?libraryToDelete={library_to_delete}"
157
-
158
- for _ in range(10):
159
- response = requests.delete(url=url, headers=self.auth.get_headers())
160
- if response.status_code == 429:
161
- print("Too many requests, waiting 10 seconds")
162
- sleep(10)
163
- continue
164
- if response.status_code not in (200, 429):
165
- raise Exception(f"Error deleting staging libraries: {response.status_code}, {response.text}")
166
- break
167
-
168
- return response.text
45
+ return self.core_client.delete_staging_library(self.workspace_id, self.id, library_to_delete)
169
46
 
170
- # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/publish
171
-
172
47
  def publish_environment(self):
173
- """Publish the staging settings and libraries of the environment"""
174
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/publish"
175
-
176
- for _ in range(10):
177
- response = requests.post(url=url, headers=self.auth.get_headers())
178
- if response.status_code == 429:
179
- print("Too many requests, waiting 10 seconds")
180
- sleep(10)
181
- continue
182
- if response.status_code == 202:
183
- publish_info = check_long_running_operation(response.headers, self.auth)
184
- return publish_info
185
- if response.status_code not in (200, 429):
186
- raise Exception(f"Error publishing staging: {response.status_code}, {response.text}")
187
- break
188
-
189
- resp_dict = json.loads(response.text)
190
- return resp_dict
191
-
192
-
193
- # POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/environments/{environmentId}/staging/cancelPublish
48
+ return self.core_client.publish_environment(self.workspace_id, self.id)
194
49
 
195
50
  def cancel_publish(self):
196
- """Cancel the publishing of the staging settings and libraries of the environment"""
197
- url = f"https://api.fabric.microsoft.com/v1/workspaces/{self.workspace_id}/environments/{self.id}/staging/cancelPublish"
198
-
199
- for _ in range(10):
200
- response = requests.post(url=url, headers=self.auth.get_headers())
201
- if response.status_code == 429:
202
- print("Too many requests, waiting 10 seconds")
203
- sleep(10)
204
- continue
205
- if response.status_code not in (200, 429):
206
- raise Exception(f"Error canceling publishing: {response.status_code}, {response.text}")
207
- break
208
-
209
- resp_dict = json.loads(response.text)
210
- return resp_dict
51
+ return self.core_client.cancel_publish(self.workspace_id, self.id)