ygg 0.1.53__tar.gz → 0.1.54__tar.gz

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 (72) hide show
  1. {ygg-0.1.53 → ygg-0.1.54}/PKG-INFO +1 -1
  2. {ygg-0.1.53 → ygg-0.1.54}/pyproject.toml +1 -1
  3. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/PKG-INFO +1 -1
  4. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/SOURCES.txt +2 -0
  5. ygg-0.1.54/src/yggdrasil/databricks/ai/__init__.py +0 -0
  6. ygg-0.1.54/src/yggdrasil/databricks/ai/loki.py +53 -0
  7. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/io.py +11 -6
  8. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/workspace.py +13 -2
  9. ygg-0.1.54/src/yggdrasil/version.py +1 -0
  10. ygg-0.1.53/src/yggdrasil/version.py +0 -1
  11. {ygg-0.1.53 → ygg-0.1.54}/LICENSE +0 -0
  12. {ygg-0.1.53 → ygg-0.1.54}/README.md +0 -0
  13. {ygg-0.1.53 → ygg-0.1.54}/setup.cfg +0 -0
  14. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/dependency_links.txt +0 -0
  15. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/entry_points.txt +0 -0
  16. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/requires.txt +0 -0
  17. {ygg-0.1.53 → ygg-0.1.54}/src/ygg.egg-info/top_level.txt +0 -0
  18. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/__init__.py +0 -0
  19. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/__init__.py +0 -0
  20. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/compute/__init__.py +0 -0
  21. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/compute/cluster.py +0 -0
  22. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/compute/execution_context.py +0 -0
  23. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/compute/remote.py +0 -0
  24. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/jobs/__init__.py +0 -0
  25. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/jobs/config.py +0 -0
  26. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/__init__.py +0 -0
  27. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/engine.py +0 -0
  28. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/exceptions.py +0 -0
  29. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/statement_result.py +0 -0
  30. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/types.py +0 -0
  31. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/sql/warehouse.py +0 -0
  32. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/__init__.py +0 -0
  33. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/filesytem.py +0 -0
  34. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/path.py +0 -0
  35. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/path_kind.py +0 -0
  36. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/volumes_path.py +0 -0
  37. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/dataclasses/__init__.py +0 -0
  38. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/dataclasses/dataclass.py +0 -0
  39. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/__init__.py +0 -0
  40. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/databrickslib.py +0 -0
  41. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/extensions/__init__.py +0 -0
  42. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/extensions/polars_extensions.py +0 -0
  43. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/extensions/spark_extensions.py +0 -0
  44. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/pandaslib.py +0 -0
  45. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/polarslib.py +0 -0
  46. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/libs/sparklib.py +0 -0
  47. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/__init__.py +0 -0
  48. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/callable_serde.py +0 -0
  49. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/equality.py +0 -0
  50. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/exceptions.py +0 -0
  51. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/expiring_dict.py +0 -0
  52. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/modules.py +0 -0
  53. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/parallel.py +0 -0
  54. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/python_env.py +0 -0
  55. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/pyutils/retry.py +0 -0
  56. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/requests/__init__.py +0 -0
  57. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/requests/msal.py +0 -0
  58. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/requests/session.py +0 -0
  59. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/__init__.py +0 -0
  60. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/__init__.py +0 -0
  61. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/arrow_cast.py +0 -0
  62. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/cast_options.py +0 -0
  63. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/pandas_cast.py +0 -0
  64. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/polars_cast.py +0 -0
  65. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/polars_pandas_cast.py +0 -0
  66. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/registry.py +0 -0
  67. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_cast.py +0 -0
  68. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_pandas_cast.py +0 -0
  69. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_polars_cast.py +0 -0
  70. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/file_format.py +0 -0
  71. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/python_arrow.py +0 -0
  72. {ygg-0.1.53 → ygg-0.1.54}/src/yggdrasil/types/python_defaults.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ygg
3
- Version: 0.1.53
3
+ Version: 0.1.54
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
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "ygg"
8
- version = "0.1.53"
8
+ version = "0.1.54"
9
9
  description = "Type-friendly utilities for moving data between Python objects, Arrow, Polars, Pandas, Spark, and Databricks"
10
10
  readme = { file = "README.md", content-type = "text/markdown" }
11
11
  license = { file = "LICENSE" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ygg
3
- Version: 0.1.53
3
+ Version: 0.1.54
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
@@ -10,6 +10,8 @@ src/ygg.egg-info/top_level.txt
10
10
  src/yggdrasil/__init__.py
11
11
  src/yggdrasil/version.py
12
12
  src/yggdrasil/databricks/__init__.py
13
+ src/yggdrasil/databricks/ai/__init__.py
14
+ src/yggdrasil/databricks/ai/loki.py
13
15
  src/yggdrasil/databricks/compute/__init__.py
14
16
  src/yggdrasil/databricks/compute/cluster.py
15
17
  src/yggdrasil/databricks/compute/execution_context.py
File without changes
@@ -0,0 +1,53 @@
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
+ )
@@ -12,7 +12,8 @@ import pyarrow.csv as pcsv
12
12
  import pyarrow.parquet as pq
13
13
  from pyarrow.dataset import (
14
14
  FileFormat,
15
- ParquetFileFormat, CsvFileFormat,
15
+ ParquetFileFormat,
16
+ CsvFileFormat,
16
17
  )
17
18
 
18
19
  from .path_kind import DatabricksPathKind
@@ -71,10 +72,11 @@ class DatabricksIO(ABC, IO):
71
72
  self.close()
72
73
 
73
74
  def __del__(self):
74
- try:
75
- Thread(target=self.close).start()
76
- except BaseException:
77
- pass
75
+ if self._need_flush():
76
+ try:
77
+ Thread(target=self.close).start()
78
+ except BaseException:
79
+ pass
78
80
 
79
81
  def __next__(self):
80
82
  """Iterate over lines in the file."""
@@ -533,13 +535,16 @@ class DatabricksIO(ABC, IO):
533
535
 
534
536
  return size
535
537
 
538
+ def _need_flush(self):
539
+ return self._write_flag and self._buffer is not None
540
+
536
541
  def flush(self):
537
542
  """Flush buffered data to the remote path.
538
543
 
539
544
  Returns:
540
545
  None.
541
546
  """
542
- if self._write_flag and self._buffer is not None:
547
+ if self._need_flush():
543
548
  self.write_all_bytes(data=self._buffer.getvalue())
544
549
  self._write_flag = False
545
550
 
@@ -645,6 +645,7 @@ class Workspace:
645
645
 
646
646
  def clusters(
647
647
  self,
648
+ workspace: Optional["Workspace"] = None,
648
649
  cluster_id: Optional[str] = None,
649
650
  cluster_name: Optional[str] = None,
650
651
  ) -> "Cluster":
@@ -666,6 +667,16 @@ class Workspace:
666
667
  cluster_name=cluster_name,
667
668
  )
668
669
 
670
+ def loki(
671
+ self,
672
+ workspace: Optional["Workspace"] = None,
673
+ ):
674
+ from ..ai.loki import Loki
675
+
676
+ return Loki(
677
+ workspace=self,
678
+ )
679
+
669
680
  # ---------------------------------------------------------------------------
670
681
  # Workspace-bound base class
671
682
  # ---------------------------------------------------------------------------
@@ -717,13 +728,13 @@ class WorkspaceService(ABC):
717
728
  """
718
729
  return self.workspace.is_in_databricks_environment()
719
730
 
720
- def connect(self):
731
+ def connect(self, clone: bool = False):
721
732
  """Connect the underlying workspace.
722
733
 
723
734
  Returns:
724
735
  The current WorkspaceService instance.
725
736
  """
726
- self.workspace = self.workspace.connect()
737
+ self.workspace = self.workspace.connect(clone=clone)
727
738
  return self
728
739
 
729
740
  def dbfs_path(
@@ -0,0 +1 @@
1
+ __version__ = "0.1.54"
@@ -1 +0,0 @@
1
- __version__ = "0.1.53"
File without changes
File without changes
File without changes
File without changes
File without changes