ygg 0.1.52__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.
- {ygg-0.1.52 → ygg-0.1.54}/PKG-INFO +1 -1
- {ygg-0.1.52 → ygg-0.1.54}/pyproject.toml +1 -1
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/PKG-INFO +1 -1
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/SOURCES.txt +2 -0
- ygg-0.1.54/src/yggdrasil/databricks/ai/__init__.py +0 -0
- ygg-0.1.54/src/yggdrasil/databricks/ai/loki.py +53 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/io.py +12 -7
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/workspace.py +13 -2
- ygg-0.1.54/src/yggdrasil/version.py +1 -0
- ygg-0.1.52/src/yggdrasil/version.py +0 -1
- {ygg-0.1.52 → ygg-0.1.54}/LICENSE +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/README.md +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/setup.cfg +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/dependency_links.txt +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/entry_points.txt +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/requires.txt +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/ygg.egg-info/top_level.txt +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/compute/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/compute/cluster.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/compute/execution_context.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/compute/remote.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/jobs/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/jobs/config.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/engine.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/exceptions.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/statement_result.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/types.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/sql/warehouse.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/filesytem.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/path.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/path_kind.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/databricks/workspaces/volumes_path.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/dataclasses/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/dataclasses/dataclass.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/databrickslib.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/extensions/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/extensions/polars_extensions.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/extensions/spark_extensions.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/pandaslib.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/polarslib.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/libs/sparklib.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/callable_serde.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/equality.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/exceptions.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/expiring_dict.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/modules.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/parallel.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/python_env.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/pyutils/retry.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/requests/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/requests/msal.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/requests/session.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/__init__.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/arrow_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/cast_options.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/pandas_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/polars_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/polars_pandas_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/registry.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_pandas_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/cast/spark_polars_cast.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/file_format.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/python_arrow.py +0 -0
- {ygg-0.1.52 → ygg-0.1.54}/src/yggdrasil/types/python_defaults.py +0 -0
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "ygg"
|
|
8
|
-
version = "0.1.
|
|
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" }
|
|
@@ -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
|
+
)
|
|
@@ -4,15 +4,16 @@ import base64
|
|
|
4
4
|
import io
|
|
5
5
|
import time
|
|
6
6
|
from abc import ABC, abstractmethod
|
|
7
|
+
from threading import Thread
|
|
7
8
|
from typing import TYPE_CHECKING, Optional, IO, AnyStr, Union
|
|
8
9
|
|
|
9
10
|
import pyarrow as pa
|
|
10
11
|
import pyarrow.csv as pcsv
|
|
11
12
|
import pyarrow.parquet as pq
|
|
12
|
-
from Lib.threading import Thread
|
|
13
13
|
from pyarrow.dataset import (
|
|
14
14
|
FileFormat,
|
|
15
|
-
ParquetFileFormat,
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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.
|
|
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.52"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|