ygg 0.1.64__py3-none-any.whl → 0.1.66__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ygg
3
- Version: 0.1.64
3
+ Version: 0.1.66
4
4
  Summary: Type-friendly utilities for moving data between Python objects, Arrow, Polars, Pandas, Spark, and Databricks
5
5
  Author: Yggdrasil contributors
6
6
  License: Apache License
@@ -1,7 +1,7 @@
1
- ygg-0.1.64.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
1
+ ygg-0.1.66.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
2
2
  yggdrasil/__init__.py,sha256=4-ghPak2S6zfMqmnlxW2GCgPb5s79znpKa2hGEGXcE4,24
3
3
  yggdrasil/exceptions.py,sha256=NEpbDFn-8ZRsLiEgJicCwrTHNMWAGtdrTJzosfAeVJo,82
4
- yggdrasil/version.py,sha256=4MIEvUQSlMm4HeF033QtQTWKTLCJXVFMfXEyriOrkl4,22
4
+ yggdrasil/version.py,sha256=y19u6jx_RZZOmyZU6XLMb8UCSG1X0auTRRU67so04sc,22
5
5
  yggdrasil/ai/__init__.py,sha256=YEOVsyuvEOvPaZT8XN9xNysS_WOpHTbKgXgnA8up7x0,52
6
6
  yggdrasil/ai/session.py,sha256=10ATAnw8FOCpfIg9sNR4meki_MRckUzKZ9Uft4IXwLA,2515
7
7
  yggdrasil/ai/sql_session.py,sha256=n92tQjHUBIey6c3EJProiEEwfAtQm07Dtmei4WXzeG0,10812
@@ -16,11 +16,11 @@ yggdrasil/databricks/compute/remote.py,sha256=sF99i7GXZcC0GiNgO9VO0I26rFbrtnDhK9
16
16
  yggdrasil/databricks/jobs/__init__.py,sha256=snxGSJb0M5I39v0y3IR-uEeSlZR248cQ_4DJ1sYs-h8,154
17
17
  yggdrasil/databricks/jobs/config.py,sha256=9LGeHD04hbfy0xt8_6oobC4moKJh4_DTjZiK4Q2Tqjk,11557
18
18
  yggdrasil/databricks/sql/__init__.py,sha256=PetgRp1jEj5K3TgN09FwNUVjVN8YYuGq0cDIOTqsbns,144
19
- yggdrasil/databricks/sql/engine.py,sha256=nFWeegs91CtjCLzxgZsJwOlAXNVI1v_lfecuFVfKFFY,49979
19
+ yggdrasil/databricks/sql/engine.py,sha256=hFPQSoliXBXuAMJDC1UZd3Sr1xSKAHg9X_DqE2EVinc,50015
20
20
  yggdrasil/databricks/sql/exceptions.py,sha256=srMR3Y9LQm45rkyxfyCgpgcoGtRRvGKWBEoUHf4kxsg,1762
21
- yggdrasil/databricks/sql/statement_result.py,sha256=01DzFX1bGDIGHj0OW2ngfVVJ1w1KHlZEfAI934E35CU,15549
21
+ yggdrasil/databricks/sql/statement_result.py,sha256=5Q7qZ2IOfFgJmaXrJ4dJgGMR6CnlFb9a0VXMr6j85fU,15601
22
22
  yggdrasil/databricks/sql/types.py,sha256=5G-BM9_eOsRKEMzeDTWUsWW5g4Idvs-czVCpOCrMhdA,6412
23
- yggdrasil/databricks/sql/warehouse.py,sha256=6rZAQ98avExuhllT-pKrjbIS3RFBMCC2RBVzXouNFo4,18976
23
+ yggdrasil/databricks/sql/warehouse.py,sha256=gDdBvThnCLQ0KjgTWz5k__YQz-K4pDgPp3U5hp6Y3R8,21349
24
24
  yggdrasil/databricks/workspaces/__init__.py,sha256=dv2zotoFVhNFlTCdRq6gwf5bEzeZkOZszoNZMs0k59g,114
25
25
  yggdrasil/databricks/workspaces/filesytem.py,sha256=Z8JXU7_XUEbw9fpTQT1avRQKi-IAP2KemXBMPkUoY4w,9805
26
26
  yggdrasil/databricks/workspaces/io.py,sha256=RdgN5lmEYNF5phPRkRMCVHbUl-t3ZUGkKbzgYSTKpII,37420
@@ -67,8 +67,8 @@ yggdrasil/types/cast/registry.py,sha256=OOqIfbIjPH-a3figvu-zTvEtUDTEWhe2xIl3cCA4
67
67
  yggdrasil/types/cast/spark_cast.py,sha256=_KAsl1DqmKMSfWxqhVE7gosjYdgiL1C5bDQv6eP3HtA,24926
68
68
  yggdrasil/types/cast/spark_pandas_cast.py,sha256=BuTiWrdCANZCdD_p2MAytqm74eq-rdRXd-LGojBRrfU,5023
69
69
  yggdrasil/types/cast/spark_polars_cast.py,sha256=btmZNHXn2NSt3fUuB4xg7coaE0RezIBdZD92H8NK0Jw,9073
70
- ygg-0.1.64.dist-info/METADATA,sha256=GXhjqjZQyvPanFP8JLjl3BvZU-pLZB_NM6pR2It7Q74,18506
71
- ygg-0.1.64.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
72
- ygg-0.1.64.dist-info/entry_points.txt,sha256=6q-vpWG3kvw2dhctQ0LALdatoeefkN855Ev02I1dKGY,70
73
- ygg-0.1.64.dist-info/top_level.txt,sha256=iBe9Kk4VIVbLpgv_p8OZUIfxgj4dgJ5wBg6vO3rigso,10
74
- ygg-0.1.64.dist-info/RECORD,,
70
+ ygg-0.1.66.dist-info/METADATA,sha256=GwVrDtjvLiqAqeGiopK2hv5zK3QJoCHuCZ5q1zgzssM,18506
71
+ ygg-0.1.66.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
72
+ ygg-0.1.66.dist-info/entry_points.txt,sha256=6q-vpWG3kvw2dhctQ0LALdatoeefkN855Ev02I1dKGY,70
73
+ ygg-0.1.66.dist-info/top_level.txt,sha256=iBe9Kk4VIVbLpgv_p8OZUIfxgj4dgJ5wBg6vO3rigso,10
74
+ ygg-0.1.66.dist-info/RECORD,,
@@ -186,7 +186,8 @@ class SQLEngine(WorkspaceService):
186
186
  self._warehouse = wh.find_warehouse(
187
187
  warehouse_id=warehouse_id,
188
188
  warehouse_name=warehouse_name,
189
- raise_error=False
189
+ raise_error=False,
190
+ find_starter=True
190
191
  )
191
192
 
192
193
  if self._warehouse is None:
@@ -305,14 +305,16 @@ class StatementResult:
305
305
  The current StatementResult instance.
306
306
  """
307
307
  wait = WaitingConfig.check_arg(wait)
308
- iteration, start = 0, time.time()
309
308
 
310
- if not self.done:
311
- wait.sleep(iteration=iteration, start=start)
312
- iteration += 1
309
+ if wait.timeout:
310
+ iteration, start = 0, time.time()
313
311
 
314
- if raise_error:
315
- self.raise_for_status()
312
+ if not self.done:
313
+ wait.sleep(iteration=iteration, start=start)
314
+ iteration += 1
315
+
316
+ if raise_error:
317
+ self.raise_for_status()
316
318
 
317
319
  return self
318
320
 
@@ -18,8 +18,9 @@ try:
18
18
  EndpointTags, EndpointTagPair, EndpointInfoWarehouseType,
19
19
  GetWarehouseResponse, GetWarehouseResponseWarehouseType,
20
20
  Disposition, Format,
21
- ExecuteStatementRequestOnWaitTimeout, StatementParameterListItem
22
- )
21
+ ExecuteStatementRequestOnWaitTimeout, StatementParameterListItem,
22
+ WarehouseAccessControlRequest, WarehousePermissionLevel
23
+ )
23
24
 
24
25
  _CREATE_ARG_NAMES = {_ for _ in inspect.signature(WarehousesAPI.create).parameters.keys()}
25
26
  _EDIT_ARG_NAMES = {_ for _ in inspect.signature(WarehousesAPI.edit).parameters.keys()}
@@ -36,6 +37,7 @@ except ImportError:
36
37
  Format = DatabricksDummyClass
37
38
  ExecuteStatementRequestOnWaitTimeout = DatabricksDummyClass
38
39
  StatementParameterListItem = DatabricksDummyClass
40
+ WarehouseAccessControlRequest = DatabricksDummyClass
39
41
 
40
42
 
41
43
  __all__ = [
@@ -242,6 +244,7 @@ class SQLWarehouse(WorkspaceService):
242
244
  warehouse_id: Optional[str] = None,
243
245
  warehouse_name: Optional[str] = None,
244
246
  raise_error: bool = True,
247
+ find_starter: bool = False
245
248
  ):
246
249
  if warehouse_id:
247
250
  if warehouse_id == self.warehouse_id:
@@ -288,10 +291,10 @@ class SQLWarehouse(WorkspaceService):
288
291
 
289
292
  return warehouse
290
293
 
291
- elif warehouse.warehouse_name == starter_warehouse:
294
+ elif warehouse.warehouse_name == starter_name:
292
295
  starter_warehouse = warehouse
293
296
 
294
- if starter_warehouse is not None:
297
+ if find_starter and starter_warehouse is not None:
295
298
  return starter_warehouse
296
299
 
297
300
  if raise_error:
@@ -401,6 +404,7 @@ class SQLWarehouse(WorkspaceService):
401
404
  warehouse_id=warehouse_id,
402
405
  warehouse_name=name,
403
406
  raise_error=False,
407
+ find_starter=False
404
408
  )
405
409
 
406
410
  if found is not None:
@@ -443,13 +447,17 @@ class SQLWarehouse(WorkspaceService):
443
447
 
444
448
  info = EndpointInfo(**update_details)
445
449
 
446
- return SQLWarehouse(
450
+ created = SQLWarehouse(
447
451
  workspace=self.workspace,
448
452
  warehouse_id=info.id,
449
453
  warehouse_name=info.name,
450
454
  _details=info
451
455
  )
452
456
 
457
+ created.update_permissions()
458
+
459
+ return created
460
+
453
461
  def update(
454
462
  self,
455
463
  wait: Optional[WaitingConfigArg] = None,
@@ -510,6 +518,76 @@ class SQLWarehouse(WorkspaceService):
510
518
 
511
519
  return self
512
520
 
521
+ def update_permissions(
522
+ self,
523
+ access_control_list: Optional[List[WarehouseAccessControlRequest]] = None,
524
+ wait: Optional[WaitingConfigArg] = None
525
+ ):
526
+ if self.warehouse_id:
527
+ client = self.warehouse_client()
528
+
529
+ access_control_list = self._check_access_control_list(
530
+ access_control_list=access_control_list
531
+ )
532
+
533
+ if access_control_list:
534
+ client.update_permissions(
535
+ warehouse_id=self.warehouse_id,
536
+ access_control_list=access_control_list
537
+ )
538
+
539
+ def default_access_control_list(self, for_all: bool):
540
+ if for_all:
541
+ base = [
542
+ WarehouseAccessControlRequest(
543
+ group_name="users",
544
+ permission_level=WarehousePermissionLevel.CAN_USE
545
+ )
546
+ ]
547
+ else:
548
+ base = []
549
+
550
+ groups = self.workspace.current_user.groups
551
+
552
+ if groups:
553
+ base.extend(
554
+ WarehouseAccessControlRequest(
555
+ group_name=group.display,
556
+ permission_level=WarehousePermissionLevel.CAN_MANAGE
557
+ )
558
+ for group in groups
559
+ if group.display != "users"
560
+ )
561
+
562
+ return base
563
+
564
+ def _check_access_control_list(
565
+ self,
566
+ access_control_list: Optional[List[WarehouseAccessControlRequest]] = None
567
+ ):
568
+ if access_control_list is None:
569
+ access_control_list = []
570
+
571
+ access_control_list.extend(self.default_access_control_list(
572
+ for_all=self.warehouse_name.startswith("yggdrasil") if self.warehouse_name else False
573
+ ))
574
+
575
+ return access_control_list
576
+
577
+ def delete(self):
578
+ if self.warehouse_id:
579
+ LOGGER.debug(
580
+ "Deleting %s",
581
+ self
582
+ )
583
+
584
+ self.warehouse_client().delete(id=self.warehouse_id)
585
+
586
+ LOGGER.info(
587
+ "Deleted %s",
588
+ self
589
+ )
590
+
513
591
  def execute(
514
592
  self,
515
593
  statement: Optional[str] = None,
@@ -599,4 +677,4 @@ class SQLWarehouse(WorkspaceService):
599
677
  execution
600
678
  )
601
679
 
602
- return execution.wait() if wait is not None else execution
680
+ return execution.wait(wait=wait)
yggdrasil/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.64"
1
+ __version__ = "0.1.66"
File without changes