ygg 0.1.57__py3-none-any.whl → 0.1.64__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 (46) hide show
  1. {ygg-0.1.57.dist-info → ygg-0.1.64.dist-info}/METADATA +2 -2
  2. ygg-0.1.64.dist-info/RECORD +74 -0
  3. yggdrasil/ai/__init__.py +2 -0
  4. yggdrasil/ai/session.py +87 -0
  5. yggdrasil/ai/sql_session.py +310 -0
  6. yggdrasil/databricks/__init__.py +0 -3
  7. yggdrasil/databricks/compute/cluster.py +68 -113
  8. yggdrasil/databricks/compute/command_execution.py +674 -0
  9. yggdrasil/databricks/compute/exceptions.py +19 -0
  10. yggdrasil/databricks/compute/execution_context.py +491 -282
  11. yggdrasil/databricks/compute/remote.py +4 -14
  12. yggdrasil/databricks/exceptions.py +10 -0
  13. yggdrasil/databricks/sql/__init__.py +0 -4
  14. yggdrasil/databricks/sql/engine.py +178 -178
  15. yggdrasil/databricks/sql/exceptions.py +9 -1
  16. yggdrasil/databricks/sql/statement_result.py +108 -120
  17. yggdrasil/databricks/sql/warehouse.py +339 -92
  18. yggdrasil/databricks/workspaces/io.py +185 -40
  19. yggdrasil/databricks/workspaces/path.py +114 -100
  20. yggdrasil/databricks/workspaces/workspace.py +210 -61
  21. yggdrasil/exceptions.py +7 -0
  22. yggdrasil/libs/databrickslib.py +22 -18
  23. yggdrasil/libs/extensions/spark_extensions.py +1 -1
  24. yggdrasil/libs/pandaslib.py +15 -6
  25. yggdrasil/libs/polarslib.py +49 -13
  26. yggdrasil/pyutils/__init__.py +1 -2
  27. yggdrasil/pyutils/callable_serde.py +12 -19
  28. yggdrasil/pyutils/exceptions.py +16 -0
  29. yggdrasil/pyutils/modules.py +6 -7
  30. yggdrasil/pyutils/python_env.py +16 -21
  31. yggdrasil/pyutils/waiting_config.py +171 -0
  32. yggdrasil/requests/msal.py +9 -96
  33. yggdrasil/types/cast/arrow_cast.py +3 -0
  34. yggdrasil/types/cast/pandas_cast.py +157 -169
  35. yggdrasil/types/cast/polars_cast.py +11 -43
  36. yggdrasil/types/dummy_class.py +81 -0
  37. yggdrasil/types/file_format.py +6 -2
  38. yggdrasil/types/python_defaults.py +92 -76
  39. yggdrasil/version.py +1 -1
  40. ygg-0.1.57.dist-info/RECORD +0 -66
  41. yggdrasil/databricks/ai/loki.py +0 -53
  42. {ygg-0.1.57.dist-info → ygg-0.1.64.dist-info}/WHEEL +0 -0
  43. {ygg-0.1.57.dist-info → ygg-0.1.64.dist-info}/entry_points.txt +0 -0
  44. {ygg-0.1.57.dist-info → ygg-0.1.64.dist-info}/licenses/LICENSE +0 -0
  45. {ygg-0.1.57.dist-info → ygg-0.1.64.dist-info}/top_level.txt +0 -0
  46. /yggdrasil/{databricks/ai/__init__.py → pyutils/mimetypes.py} +0 -0
@@ -18,84 +18,96 @@ __all__ = [
18
18
  "default_arrow_array"
19
19
  ]
20
20
 
21
+ DEFAULT_MAPS_INITIALIZED = False
21
22
 
22
23
  _NONE_TYPE = type(None)
23
- _PRIMITIVE_DEFAULTS = {
24
- str: "",
25
- int: 0,
26
- float: 0.0,
27
- bool: False,
28
- bytes: b"",
29
- }
30
-
31
- _SPECIAL_DEFAULTS = {
32
- datetime.datetime: lambda: datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc),
33
- datetime.date: lambda: datetime.date(1970, 1, 1),
34
- datetime.time: lambda: datetime.time(0, 0, 0, tzinfo=datetime.timezone.utc),
35
- datetime.timedelta: lambda: datetime.timedelta(0),
36
- uuid.UUID: lambda: uuid.UUID(int=0),
37
- decimal.Decimal: lambda: decimal.Decimal(0),
38
- }
39
-
40
- _ARROW_DEFAULTS = {
41
- pa.null(): pa.scalar(None, type=pa.null()),
42
-
43
- pa.bool_(): pa.scalar(False, type=pa.bool_()),
44
-
45
- pa.int8(): pa.scalar(0, type=pa.int8()),
46
- pa.int16(): pa.scalar(0, type=pa.int16()),
47
- pa.int32(): pa.scalar(0, type=pa.int32()),
48
- pa.int64(): pa.scalar(0, type=pa.int64()),
49
-
50
- pa.uint8(): pa.scalar(0, type=pa.uint8()),
51
- pa.uint16(): pa.scalar(0, type=pa.uint16()),
52
- pa.uint32(): pa.scalar(0, type=pa.uint32()),
53
- pa.uint64(): pa.scalar(0, type=pa.uint64()),
54
-
55
- # pa.float16(): pa.scalar(0.0, type=pa.float16()),
56
- pa.float32(): pa.scalar(0.0, type=pa.float32()),
57
- pa.float64(): pa.scalar(0.0, type=pa.float64()),
58
-
59
- pa.string(): pa.scalar("", type=pa.string()),
60
- pa.string_view(): pa.scalar("", type=pa.string_view()),
61
- pa.large_string(): pa.scalar("", type=pa.large_string()),
62
-
63
- pa.binary(): pa.scalar(b"", type=pa.binary()),
64
- pa.binary_view(): pa.scalar(b"", type=pa.binary_view()),
65
- pa.large_binary(): pa.scalar(b"", type=pa.large_binary()),
66
- }
67
-
68
-
69
- try:
70
- import polars
71
-
72
- polars = polars
73
-
74
- _POLARS_DEFAULTS = {
75
- polars.Null(): None,
76
- polars.Boolean(): False,
77
-
78
- polars.Binary(): b"",
79
-
80
- polars.Utf8(): "",
81
-
82
- polars.Int8(): 0,
83
- polars.Int16(): 0,
84
- polars.Int32(): 0,
85
- polars.Int64(): 0,
86
-
87
- polars.UInt8(): 0,
88
- polars.UInt16(): 0,
89
- polars.UInt32(): 0,
90
- polars.UInt64(): 0,
91
-
92
- polars.Float32(): 0.0,
93
- polars.Float64(): 0.0,
94
- }
95
- except ImportError:
96
- polars = None
97
-
98
- _POLARS_DEFAULTS = {}
24
+ _ARROW_DEFAULTS = {}
25
+ _POLARS_DEFAULTS = {}
26
+ _PRIMITIVE_DEFAULTS = {}
27
+ _SPECIAL_DEFAULTS = {}
28
+
29
+
30
+ def ensure_default_maps_initialized():
31
+ global DEFAULT_MAPS_INITIALIZED
32
+ global _PRIMITIVE_DEFAULTS
33
+ global _SPECIAL_DEFAULTS
34
+ global _ARROW_DEFAULTS
35
+ global _POLARS_DEFAULTS
36
+
37
+ if not DEFAULT_MAPS_INITIALIZED:
38
+ _PRIMITIVE_DEFAULTS = {
39
+ str: "",
40
+ int: 0,
41
+ float: 0.0,
42
+ bool: False,
43
+ bytes: b"",
44
+ }
45
+
46
+ _SPECIAL_DEFAULTS = {
47
+ datetime.datetime: lambda: datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc),
48
+ datetime.date: lambda: datetime.date(1970, 1, 1),
49
+ datetime.time: lambda: datetime.time(0, 0, 0, tzinfo=datetime.timezone.utc),
50
+ datetime.timedelta: lambda: datetime.timedelta(0),
51
+ uuid.UUID: lambda: uuid.UUID(int=0),
52
+ decimal.Decimal: lambda: decimal.Decimal(0),
53
+ }
54
+
55
+ _ARROW_DEFAULTS = {
56
+ pa.null(): pa.scalar(None, type=pa.null()),
57
+
58
+ pa.bool_(): pa.scalar(False, type=pa.bool_()),
59
+
60
+ pa.int8(): pa.scalar(0, type=pa.int8()),
61
+ pa.int16(): pa.scalar(0, type=pa.int16()),
62
+ pa.int32(): pa.scalar(0, type=pa.int32()),
63
+ pa.int64(): pa.scalar(0, type=pa.int64()),
64
+
65
+ pa.uint8(): pa.scalar(0, type=pa.uint8()),
66
+ pa.uint16(): pa.scalar(0, type=pa.uint16()),
67
+ pa.uint32(): pa.scalar(0, type=pa.uint32()),
68
+ pa.uint64(): pa.scalar(0, type=pa.uint64()),
69
+
70
+ # pa.float16(): pa.scalar(0.0, type=pa.float16()),
71
+ pa.float32(): pa.scalar(0.0, type=pa.float32()),
72
+ pa.float64(): pa.scalar(0.0, type=pa.float64()),
73
+
74
+ pa.string(): pa.scalar("", type=pa.string()),
75
+ pa.string_view(): pa.scalar("", type=pa.string_view()),
76
+ pa.large_string(): pa.scalar("", type=pa.large_string()),
77
+
78
+ pa.binary(): pa.scalar(b"", type=pa.binary()),
79
+ pa.binary_view(): pa.scalar(b"", type=pa.binary_view()),
80
+ pa.large_binary(): pa.scalar(b"", type=pa.large_binary()),
81
+ }
82
+
83
+ try:
84
+ import polars
85
+
86
+ _POLARS_DEFAULTS = {
87
+ polars.Null(): None,
88
+ polars.Boolean(): False,
89
+
90
+ polars.Binary(): b"",
91
+
92
+ polars.Utf8(): "",
93
+
94
+ polars.Int8(): 0,
95
+ polars.Int16(): 0,
96
+ polars.Int32(): 0,
97
+ polars.Int64(): 0,
98
+
99
+ polars.UInt8(): 0,
100
+ polars.UInt16(): 0,
101
+ polars.UInt32(): 0,
102
+ polars.UInt64(): 0,
103
+
104
+ polars.Float32(): 0.0,
105
+ polars.Float64(): 0.0,
106
+ }
107
+ except ImportError:
108
+ pass
109
+
110
+ DEFAULT_MAPS_INITIALIZED = True
99
111
 
100
112
  def _is_optional(hint) -> bool:
101
113
  """Return True when the type hint is Optional.
@@ -199,6 +211,8 @@ def default_arrow_scalar(
199
211
  Returns:
200
212
  Arrow scalar default.
201
213
  """
214
+ ensure_default_maps_initialized()
215
+
202
216
  if nullable:
203
217
  return pa.scalar(None, type=dtype)
204
218
 
@@ -307,6 +321,8 @@ def default_python_scalar(hint: Any):
307
321
  if _is_optional(hint):
308
322
  return None
309
323
 
324
+ ensure_default_maps_initialized()
325
+
310
326
  if hint in _PRIMITIVE_DEFAULTS:
311
327
  return _PRIMITIVE_DEFAULTS[hint]
312
328
 
yggdrasil/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.57"
1
+ __version__ = "0.1.64"
@@ -1,66 +0,0 @@
1
- ygg-0.1.57.dist-info/licenses/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
2
- yggdrasil/__init__.py,sha256=4-ghPak2S6zfMqmnlxW2GCgPb5s79znpKa2hGEGXcE4,24
3
- yggdrasil/version.py,sha256=mM67BdyYZ17u9xAi4WRzFQM2e6yfmX4MPd36R3L920M,22
4
- yggdrasil/databricks/__init__.py,sha256=skctY2c8W-hI81upx9F_PWRe5ishL3hrdiTuizgDjdw,152
5
- yggdrasil/databricks/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- yggdrasil/databricks/ai/loki.py,sha256=1AhMOquMTsZZGYw5cGoXn-QQhdBRMXM9ZRPEUAv4Y3k,1216
7
- yggdrasil/databricks/compute/__init__.py,sha256=NvdzmaJSNYY1uJthv1hHdBuNu3bD_-Z65DWnaJt9yXg,289
8
- yggdrasil/databricks/compute/cluster.py,sha256=YomLfvB0oxbgl6WDgBRxI1UXsxwlEbR6gq3FUbPHscY,44199
9
- yggdrasil/databricks/compute/execution_context.py,sha256=jIV6uru2NeX3O5lg-3KEqmXtLxxq45CFgkBQgQIIOHQ,23327
10
- yggdrasil/databricks/compute/remote.py,sha256=yicEhyQypssRa2ByscO36s3cBkEgORFsRME9aaq91Pc,3045
11
- yggdrasil/databricks/jobs/__init__.py,sha256=snxGSJb0M5I39v0y3IR-uEeSlZR248cQ_4DJ1sYs-h8,154
12
- yggdrasil/databricks/jobs/config.py,sha256=9LGeHD04hbfy0xt8_6oobC4moKJh4_DTjZiK4Q2Tqjk,11557
13
- yggdrasil/databricks/sql/__init__.py,sha256=Vp_1cFaX1l-JGzCknvkbiB8CBFX2fQbBNntIeVn3lEg,231
14
- yggdrasil/databricks/sql/engine.py,sha256=UzahfAFruv8jFLjfIeoLPDSvuGCkhRHCap9l42mrtps,50850
15
- yggdrasil/databricks/sql/exceptions.py,sha256=jHHcCc0Fv-rOKz5o_CyrR37QYIdeGZ2Hg4swfdYe7M0,1501
16
- yggdrasil/databricks/sql/statement_result.py,sha256=GZyVhhrUK5opNo-8HGqsMx0Rp9fa_0zqvn8McSHPQ8U,16310
17
- yggdrasil/databricks/sql/types.py,sha256=5G-BM9_eOsRKEMzeDTWUsWW5g4Idvs-czVCpOCrMhdA,6412
18
- yggdrasil/databricks/sql/warehouse.py,sha256=1J0dyQLJb-OS1_1xU1eAVZ4CoL2-FhFeowKSvU3RzFc,9773
19
- yggdrasil/databricks/workspaces/__init__.py,sha256=dv2zotoFVhNFlTCdRq6gwf5bEzeZkOZszoNZMs0k59g,114
20
- yggdrasil/databricks/workspaces/filesytem.py,sha256=Z8JXU7_XUEbw9fpTQT1avRQKi-IAP2KemXBMPkUoY4w,9805
21
- yggdrasil/databricks/workspaces/io.py,sha256=hErGeSKJ9XpSUvlYAAckh_8IKQQmGeDOqbdl2rh9Fbs,33240
22
- yggdrasil/databricks/workspaces/path.py,sha256=KkvLFHrps3UFr4ogYdESbJHEMfQBcWfWfXjlrv_7rTU,55180
23
- yggdrasil/databricks/workspaces/path_kind.py,sha256=rhWe1ky7uPD0du0bZSv2S4fK4C5zWd7zAF3UeS2iiPU,283
24
- yggdrasil/databricks/workspaces/volumes_path.py,sha256=s8CA33cG3jpMVJy5MILLlkEBcFg_qInDCF2jozLj1Fg,2431
25
- yggdrasil/databricks/workspaces/workspace.py,sha256=Tl1pYzTGNpjsPmHCJ62HoJvdzHGiZb43vQxrI3Sk7js,25233
26
- yggdrasil/dataclasses/__init__.py,sha256=_RkhfF3KC1eSORby1dzvBXQ0-UGG3u6wyUQWX2jq1Pc,108
27
- yggdrasil/dataclasses/dataclass.py,sha256=LxrCjwvmBnb8yRI_N-c31RHHxB4XoJPixmKg9iBIuaI,1148
28
- yggdrasil/libs/__init__.py,sha256=zdC9OU0Xy36CLY9mg2drxN6S7isPR8aTLzJA6xVIeLE,91
29
- yggdrasil/libs/databrickslib.py,sha256=vD6APmTkRsxeBemm-l84aG_1Vkeo2v_smeBM3Xh32OU,1095
30
- yggdrasil/libs/pandaslib.py,sha256=GoUjh9dxZAFLe9hs8-6RliLD3jsH_BexYW1w-8BZzb0,618
31
- yggdrasil/libs/polarslib.py,sha256=hnL8x6ygsyIoiJyIUMaeoji3fRzab4lBiHcMqa29C_Q,618
32
- yggdrasil/libs/sparklib.py,sha256=FQ3W1iz2EIpQreorOiQuFt15rdhq2QhGEAWp8Zrbl9A,10177
33
- yggdrasil/libs/extensions/__init__.py,sha256=mcXW5Li3Cbprbs4Ci-b5A0Ju0wmLcfvEiFusTx6xNjU,117
34
- yggdrasil/libs/extensions/polars_extensions.py,sha256=RTkGi8llhPJjX7x9egix7-yXWo2X24zIAPSKXV37SSA,12397
35
- yggdrasil/libs/extensions/spark_extensions.py,sha256=E64n-3SFTDgMuXwWitX6vOYP9ln2lpGKb0htoBLEZgc,16745
36
- yggdrasil/pyutils/__init__.py,sha256=tl-LapAc71TV7RMgf2ftKwrzr8iiLOGHeJgA3RvO93w,293
37
- yggdrasil/pyutils/callable_serde.py,sha256=1XckmFO-ThP0MedxgXwB71u9jWUuhM1btOzW9gJ8w9g,23117
38
- yggdrasil/pyutils/equality.py,sha256=Xyf8D1dLUCm3spDEir8Zyj7O4US_fBJwEylJCfJ9slI,3080
39
- yggdrasil/pyutils/exceptions.py,sha256=ssKNm-rjhavHUOZmGA7_1Gq9tSHDrb2EFI-cnBuWgng,3388
40
- yggdrasil/pyutils/expiring_dict.py,sha256=pr2u25LGwPVbLfsLptiHGovUtYRRo0AMjaJtCtJl7nQ,8477
41
- yggdrasil/pyutils/modules.py,sha256=B7IP99YqUMW6-DIESFzBx8-09V1d0a8qrIJUDFhhL2g,11424
42
- yggdrasil/pyutils/parallel.py,sha256=ubuq2m9dJzWYUyKCga4Y_9bpaeMYUrleYxdp49CHr44,6781
43
- yggdrasil/pyutils/python_env.py,sha256=Gh5geFK9ABpyWEfyegGUfIJUoPxKwcH0pqLBiMrW9Rw,51103
44
- yggdrasil/pyutils/retry.py,sha256=gXBtn1DdmIYIUmGKOUr8-SUT7MOu97LykN2YR4uocgc,11917
45
- yggdrasil/requests/__init__.py,sha256=dMesyzq97_DmI765x0TwaDPEfsxFtgGNgchk8LvEN-o,103
46
- yggdrasil/requests/msal.py,sha256=s2GCyzbgFdgdlJ1JqMrZ4qYVbmoG46-ZOTcaVQhZ-sQ,9220
47
- yggdrasil/requests/session.py,sha256=SLnrgHY0Lby7ZxclRFUjHdfM8euN_8bSQEWl7TkJY2U,1461
48
- yggdrasil/types/__init__.py,sha256=CrLiDeYNM9fO975sE5ufeVKcy7Ca702IsaG2Pk8T3YU,139
49
- yggdrasil/types/file_format.py,sha256=yqAadZ5z6CrctsQO0ZmEY7eGXLbhBUnvvNOwkPSk0GU,133
50
- yggdrasil/types/python_arrow.py,sha256=mOhyecAxa5u8JWsyTO26OMOWimHHgwLKWlkNSAyIVas,25636
51
- yggdrasil/types/python_defaults.py,sha256=GO3hZBZcwRHs9qiXes75y8l5X00kZHTfEC7el_x73uw,10184
52
- yggdrasil/types/cast/__init__.py,sha256=Oft3pTs2bRM5hT7YqJAuOKTYYk-SACLaMOXUVdafy_I,311
53
- yggdrasil/types/cast/arrow_cast.py,sha256=_OMYc4t5GlgE4ztlWaCoK8Jnba09rgDbmHVP-QXhOL0,41523
54
- yggdrasil/types/cast/cast_options.py,sha256=nDaEvCCs7TBamhTWyDrYf3LVaBWzioIP2Q5_LXrChF4,15532
55
- yggdrasil/types/cast/pandas_cast.py,sha256=I3xu0sZ59ZbK3NDcQ2dslzdeKzhpFV5zR02ZEixd5hI,8713
56
- yggdrasil/types/cast/polars_cast.py,sha256=RILcbfL4o1XDMp5H-06c0BMrDal5pehOT7ACiItDB6E,28791
57
- yggdrasil/types/cast/polars_pandas_cast.py,sha256=CS0P7teVv15IdX5g7v40RfkH1VMg6b-HM0V_gOfacm8,5071
58
- yggdrasil/types/cast/registry.py,sha256=OOqIfbIjPH-a3figvu-zTvEtUDTEWhe2xIl3cCA4PRM,20941
59
- yggdrasil/types/cast/spark_cast.py,sha256=_KAsl1DqmKMSfWxqhVE7gosjYdgiL1C5bDQv6eP3HtA,24926
60
- yggdrasil/types/cast/spark_pandas_cast.py,sha256=BuTiWrdCANZCdD_p2MAytqm74eq-rdRXd-LGojBRrfU,5023
61
- yggdrasil/types/cast/spark_polars_cast.py,sha256=btmZNHXn2NSt3fUuB4xg7coaE0RezIBdZD92H8NK0Jw,9073
62
- ygg-0.1.57.dist-info/METADATA,sha256=0VEcri5fh3BUYJxxhQ_icTZfhkry6KgEhbKQEEDrKJ4,18528
63
- ygg-0.1.57.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
64
- ygg-0.1.57.dist-info/entry_points.txt,sha256=6q-vpWG3kvw2dhctQ0LALdatoeefkN855Ev02I1dKGY,70
65
- ygg-0.1.57.dist-info/top_level.txt,sha256=iBe9Kk4VIVbLpgv_p8OZUIfxgj4dgJ5wBg6vO3rigso,10
66
- ygg-0.1.57.dist-info/RECORD,,
@@ -1,53 +0,0 @@
1
- from typing import Optional
2
- from dataclasses import field, dataclass
3
-
4
- from ..workspaces.workspace import WorkspaceService
5
-
6
- try:
7
- from openai import OpenAI
8
-
9
- def make_openai_client(
10
- api_key: str,
11
- base_url: str
12
- ):
13
- return OpenAI(
14
- api_key=api_key,
15
- base_url=base_url
16
- )
17
- except ImportError:
18
- class OpenAI:
19
- pass
20
-
21
- def make_openai_client(
22
- api_key: str,
23
- base_url: str
24
- ):
25
- from openai import OpenAI
26
-
27
- return OpenAI(
28
- api_key=api_key,
29
- base_url=base_url
30
- )
31
-
32
- __all__ = [
33
- "Loki"
34
- ]
35
-
36
-
37
- @dataclass
38
- class Loki(WorkspaceService):
39
- model: str = "databricks-gemini-2-5-flash"
40
-
41
- _openai_client: Optional[OpenAI] = field(repr=False, hash=False, default=None)
42
-
43
- @property
44
- def openai_client(self):
45
- if self._openai_client is None:
46
- self._openai_client = self.make_openai_client()
47
- return self._openai_client
48
-
49
- def make_openai_client(self):
50
- return make_openai_client(
51
- api_key=self.workspace.current_token(),
52
- base_url=self.workspace.host + "/serving-endpoints"
53
- )
File without changes