kumoai 2.13.0.dev202511131731__cp310-cp310-macosx_11_0_arm64.whl → 2.13.0.dev202511191731__cp310-cp310-macosx_11_0_arm64.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.
- kumoai/__init__.py +6 -9
- kumoai/_version.py +1 -1
- kumoai/client/client.py +9 -13
- kumoai/experimental/rfm/__init__.py +148 -7
- kumoai/experimental/rfm/local_graph_sampler.py +0 -2
- kumoai/experimental/rfm/rfm.py +11 -9
- kumoai/experimental/rfm/sagemaker.py +130 -0
- kumoai/spcs.py +1 -3
- {kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/METADATA +11 -2
- {kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/RECORD +13 -12
- {kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/WHEEL +0 -0
- {kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/licenses/LICENSE +0 -0
- {kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/top_level.txt +0 -0
kumoai/__init__.py
CHANGED
|
@@ -184,15 +184,12 @@ def init(
|
|
|
184
184
|
snowflake_credentials
|
|
185
185
|
) if not api_key and snowflake_credentials else None
|
|
186
186
|
client = KumoClient(url=url, api_key=api_key, spcs_token=spcs_token)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
else:
|
|
194
|
-
raise ValueError("Client authentication failed. Please check if you "
|
|
195
|
-
"have a valid API key.")
|
|
187
|
+
client.authenticate()
|
|
188
|
+
global_state._url = client._url
|
|
189
|
+
global_state._api_key = client._api_key
|
|
190
|
+
global_state._snowflake_credentials = snowflake_credentials
|
|
191
|
+
global_state._spcs_token = client._spcs_token
|
|
192
|
+
global_state._snowpark_session = snowpark_session
|
|
196
193
|
|
|
197
194
|
if not api_key and snowflake_credentials:
|
|
198
195
|
# Refresh token every 10 minutes (expires in 1 hour):
|
kumoai/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.13.0.
|
|
1
|
+
__version__ = '2.13.0.dev202511191731'
|
kumoai/client/client.py
CHANGED
|
@@ -20,7 +20,6 @@ if TYPE_CHECKING:
|
|
|
20
20
|
)
|
|
21
21
|
from kumoai.client.online import OnlineServingEndpointAPI
|
|
22
22
|
from kumoai.client.pquery import PQueryAPI
|
|
23
|
-
from kumoai.client.rfm import RFMAPI
|
|
24
23
|
from kumoai.client.source_table import SourceTableAPI
|
|
25
24
|
from kumoai.client.table import TableAPI
|
|
26
25
|
|
|
@@ -73,12 +72,15 @@ class KumoClient:
|
|
|
73
72
|
self._session.headers.update(
|
|
74
73
|
{'Authorization': f'Snowflake Token={self._spcs_token}'})
|
|
75
74
|
|
|
76
|
-
def authenticate(self) ->
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
def authenticate(self) -> None:
|
|
76
|
+
"""Raises an exception if authentication fails."""
|
|
77
|
+
try:
|
|
78
|
+
self._session.get(self._url + '/v1/connectors',
|
|
79
|
+
verify=self._verify_ssl).raise_for_status()
|
|
80
|
+
except Exception:
|
|
81
|
+
raise ValueError(
|
|
82
|
+
"Client authentication failed. Please check if you "
|
|
83
|
+
"have a valid API key/credentials.")
|
|
82
84
|
|
|
83
85
|
def set_spcs_token(self, spcs_token: str) -> None:
|
|
84
86
|
r"""Sets the SPCS token for the client and updates the session
|
|
@@ -163,12 +165,6 @@ class KumoClient:
|
|
|
163
165
|
from kumoai.client.online import OnlineServingEndpointAPI
|
|
164
166
|
return OnlineServingEndpointAPI(self)
|
|
165
167
|
|
|
166
|
-
@property
|
|
167
|
-
def rfm_api(self) -> 'RFMAPI':
|
|
168
|
-
r"""Returns the typed RFM API."""
|
|
169
|
-
from kumoai.client.rfm import RFMAPI
|
|
170
|
-
return RFMAPI(self)
|
|
171
|
-
|
|
172
168
|
def _request(self, endpoint: Endpoint, **kwargs: Any) -> requests.Response:
|
|
173
169
|
r"""Send a HTTP request to the specified endpoint."""
|
|
174
170
|
endpoint_str = endpoint.get_path()
|
|
@@ -31,14 +31,122 @@ Please create a feature request at 'https://github.com/kumo-ai/kumo-rfm'."""
|
|
|
31
31
|
|
|
32
32
|
raise RuntimeError(_msg) from e
|
|
33
33
|
|
|
34
|
-
from
|
|
34
|
+
from dataclasses import dataclass
|
|
35
|
+
from enum import Enum
|
|
36
|
+
import ipaddress
|
|
37
|
+
import logging
|
|
38
|
+
import re
|
|
39
|
+
import socket
|
|
40
|
+
import threading
|
|
41
|
+
from typing import Optional, Dict, Tuple
|
|
35
42
|
import os
|
|
43
|
+
from urllib.parse import urlparse
|
|
36
44
|
import kumoai
|
|
45
|
+
from kumoai.client.client import KumoClient
|
|
46
|
+
from .sagemaker import (KumoClient_SageMakerAdapter,
|
|
47
|
+
KumoClient_SageMakerProxy_Local)
|
|
37
48
|
from .local_table import LocalTable
|
|
38
49
|
from .local_graph import LocalGraph
|
|
39
50
|
from .rfm import ExplainConfig, Explanation, KumoRFM
|
|
40
51
|
from .authenticate import authenticate
|
|
41
52
|
|
|
53
|
+
logger = logging.getLogger('kumoai_rfm')
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _is_local_address(host: str | None) -> bool:
|
|
57
|
+
"""Return True if the hostname/IP refers to the local machine."""
|
|
58
|
+
if not host:
|
|
59
|
+
return False
|
|
60
|
+
try:
|
|
61
|
+
infos = socket.getaddrinfo(host, None)
|
|
62
|
+
for _, _, _, _, sockaddr in infos:
|
|
63
|
+
ip = sockaddr[0]
|
|
64
|
+
ip_obj = ipaddress.ip_address(ip)
|
|
65
|
+
if ip_obj.is_loopback or ip_obj.is_unspecified:
|
|
66
|
+
return True
|
|
67
|
+
return False
|
|
68
|
+
except Exception:
|
|
69
|
+
return False
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class InferenceBackend(str, Enum):
|
|
73
|
+
REST = "REST"
|
|
74
|
+
LOCAL_SAGEMAKER = "LOCAL_SAGEMAKER"
|
|
75
|
+
AWS_SAGEMAKER = "AWS_SAGEMAKER"
|
|
76
|
+
UNKNOWN = "UNKNOWN"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _detect_backend(
|
|
80
|
+
url: str) -> Tuple[InferenceBackend, Optional[str], Optional[str]]:
|
|
81
|
+
parsed = urlparse(url)
|
|
82
|
+
|
|
83
|
+
# Remote SageMaker
|
|
84
|
+
if ("runtime.sagemaker" in parsed.netloc
|
|
85
|
+
and parsed.path.endswith("/invocations")):
|
|
86
|
+
# Example: https://runtime.sagemaker.us-west-2.amazonaws.com/
|
|
87
|
+
# endpoints/Name/invocations
|
|
88
|
+
match = re.search(r"runtime\.sagemaker\.([a-z0-9-]+)\.amazonaws\.com",
|
|
89
|
+
parsed.netloc)
|
|
90
|
+
region = match.group(1) if match else None
|
|
91
|
+
m = re.search(r"/endpoints/([^/]+)/invocations", parsed.path)
|
|
92
|
+
endpoint_name = m.group(1) if m else None
|
|
93
|
+
return InferenceBackend.AWS_SAGEMAKER, region, endpoint_name
|
|
94
|
+
|
|
95
|
+
# Local SageMaker
|
|
96
|
+
if parsed.port == 8080 and parsed.path.endswith(
|
|
97
|
+
"/invocations") and _is_local_address(parsed.hostname):
|
|
98
|
+
return InferenceBackend.LOCAL_SAGEMAKER, None, None
|
|
99
|
+
|
|
100
|
+
# Default: regular REST
|
|
101
|
+
return InferenceBackend.REST, None, None
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@dataclass
|
|
105
|
+
class RfmGlobalState:
|
|
106
|
+
_url: str = '__url_not_provided__'
|
|
107
|
+
_backend: InferenceBackend = InferenceBackend.UNKNOWN
|
|
108
|
+
_region: Optional[str] = None
|
|
109
|
+
_endpoint_name: Optional[str] = None
|
|
110
|
+
_thread_local = threading.local()
|
|
111
|
+
|
|
112
|
+
# Thread-safe init-once.
|
|
113
|
+
_initialized: bool = False
|
|
114
|
+
_lock: threading.Lock = threading.Lock()
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def client(self) -> KumoClient:
|
|
118
|
+
if self._backend == InferenceBackend.REST:
|
|
119
|
+
return kumoai.global_state.client
|
|
120
|
+
|
|
121
|
+
if hasattr(self._thread_local, '_sagemaker'):
|
|
122
|
+
# Set the spcs token in the client to ensure it has the latest.
|
|
123
|
+
return self._thread_local._sagemaker
|
|
124
|
+
|
|
125
|
+
sagemaker_client: KumoClient
|
|
126
|
+
if self._backend == InferenceBackend.LOCAL_SAGEMAKER:
|
|
127
|
+
sagemaker_client = KumoClient_SageMakerProxy_Local(self._url)
|
|
128
|
+
else:
|
|
129
|
+
assert self._backend == InferenceBackend.AWS_SAGEMAKER
|
|
130
|
+
assert self._region
|
|
131
|
+
assert self._endpoint_name
|
|
132
|
+
sagemaker_client = KumoClient_SageMakerAdapter(
|
|
133
|
+
self._region, self._endpoint_name)
|
|
134
|
+
|
|
135
|
+
self._thread_local._sagemaker = sagemaker_client
|
|
136
|
+
return sagemaker_client
|
|
137
|
+
|
|
138
|
+
def reset(self) -> None: # For testing only.
|
|
139
|
+
with self._lock:
|
|
140
|
+
self._initialized = False
|
|
141
|
+
self._url = '__url_not_provided__'
|
|
142
|
+
self._backend = InferenceBackend.UNKNOWN
|
|
143
|
+
self._region = None
|
|
144
|
+
self._endpoint_name = None
|
|
145
|
+
self._thread_local = threading.local()
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
global_state = RfmGlobalState()
|
|
149
|
+
|
|
42
150
|
|
|
43
151
|
def init(
|
|
44
152
|
url: Optional[str] = None,
|
|
@@ -47,13 +155,46 @@ def init(
|
|
|
47
155
|
snowflake_application: Optional[str] = None,
|
|
48
156
|
log_level: str = "INFO",
|
|
49
157
|
) -> None:
|
|
50
|
-
|
|
51
|
-
|
|
158
|
+
with global_state._lock:
|
|
159
|
+
if global_state._initialized:
|
|
160
|
+
if url != global_state._url:
|
|
161
|
+
raise ValueError(
|
|
162
|
+
"Kumo RFM has already been initialized with a different "
|
|
163
|
+
"URL. Re-initialization with a different URL is not "
|
|
164
|
+
"supported.")
|
|
165
|
+
return
|
|
166
|
+
|
|
167
|
+
if url is None:
|
|
168
|
+
url = os.getenv("RFM_API_URL", "https://kumorfm.ai/api")
|
|
169
|
+
|
|
170
|
+
backend, region, endpoint_name = _detect_backend(url)
|
|
171
|
+
if backend == InferenceBackend.REST:
|
|
172
|
+
# Initialize kumoai.global_state
|
|
173
|
+
if (kumoai.global_state.initialized
|
|
174
|
+
and kumoai.global_state._url != url):
|
|
175
|
+
raise ValueError(
|
|
176
|
+
"Kumo AI SDK has already been initialized with different "
|
|
177
|
+
"API URL. Please restart Python interpreter and "
|
|
178
|
+
"initialize via kumoai.rfm.init()")
|
|
179
|
+
kumoai.init(url=url, api_key=api_key,
|
|
180
|
+
snowflake_credentials=snowflake_credentials,
|
|
181
|
+
snowflake_application=snowflake_application,
|
|
182
|
+
log_level=log_level)
|
|
183
|
+
elif backend == InferenceBackend.AWS_SAGEMAKER:
|
|
184
|
+
assert region
|
|
185
|
+
assert endpoint_name
|
|
186
|
+
KumoClient_SageMakerAdapter(region, endpoint_name).authenticate()
|
|
187
|
+
else:
|
|
188
|
+
assert backend == InferenceBackend.LOCAL_SAGEMAKER
|
|
189
|
+
KumoClient_SageMakerProxy_Local(url).authenticate()
|
|
52
190
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
191
|
+
global_state._url = url
|
|
192
|
+
global_state._backend = backend
|
|
193
|
+
global_state._region = region
|
|
194
|
+
global_state._endpoint_name = endpoint_name
|
|
195
|
+
global_state._initialized = True
|
|
196
|
+
logger.info("Kumo RFM initialized with backend: %s, url: %s", backend,
|
|
197
|
+
url)
|
|
57
198
|
|
|
58
199
|
|
|
59
200
|
__all__ = [
|
|
@@ -2,7 +2,6 @@ from typing import Dict, List, Optional, Tuple
|
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import pandas as pd
|
|
5
|
-
from kumoapi.model_plan import RunMode
|
|
6
5
|
from kumoapi.rfm.context import EdgeLayout, Link, Subgraph, Table
|
|
7
6
|
from kumoapi.typing import Stype
|
|
8
7
|
|
|
@@ -33,7 +32,6 @@ class LocalGraphSampler:
|
|
|
33
32
|
entity_table_names: Tuple[str, ...],
|
|
34
33
|
node: np.ndarray,
|
|
35
34
|
time: np.ndarray,
|
|
36
|
-
run_mode: RunMode,
|
|
37
35
|
num_neighbors: List[int],
|
|
38
36
|
exclude_cols_dict: Dict[str, List[str]],
|
|
39
37
|
) -> Subgraph:
|
kumoai/experimental/rfm/rfm.py
CHANGED
|
@@ -30,7 +30,7 @@ from kumoapi.rfm import (
|
|
|
30
30
|
)
|
|
31
31
|
from kumoapi.task import TaskType
|
|
32
32
|
|
|
33
|
-
from kumoai import
|
|
33
|
+
from kumoai.client.rfm import RFMAPI
|
|
34
34
|
from kumoai.exceptions import HTTPException
|
|
35
35
|
from kumoai.experimental.rfm import LocalGraph
|
|
36
36
|
from kumoai.experimental.rfm.local_graph_sampler import LocalGraphSampler
|
|
@@ -141,9 +141,9 @@ class KumoRFM:
|
|
|
141
141
|
|
|
142
142
|
rfm = KumoRFM(graph)
|
|
143
143
|
|
|
144
|
-
query = ("PREDICT COUNT(
|
|
145
|
-
"FOR users.user_id=
|
|
146
|
-
result = rfm.
|
|
144
|
+
query = ("PREDICT COUNT(orders.*, 0, 30, days)>0 "
|
|
145
|
+
"FOR users.user_id=1")
|
|
146
|
+
result = rfm.predict(query)
|
|
147
147
|
|
|
148
148
|
print(result) # user_id COUNT(transactions.*, 0, 30, days) > 0
|
|
149
149
|
# 1 0.85
|
|
@@ -174,6 +174,8 @@ class KumoRFM:
|
|
|
174
174
|
|
|
175
175
|
self._batch_size: Optional[int | Literal['max']] = None
|
|
176
176
|
self.num_retries: int = 0
|
|
177
|
+
from kumoai.experimental.rfm import global_state
|
|
178
|
+
self._api_client = RFMAPI(global_state.client)
|
|
177
179
|
|
|
178
180
|
def __repr__(self) -> str:
|
|
179
181
|
return f'{self.__class__.__name__}()'
|
|
@@ -420,14 +422,14 @@ class KumoRFM:
|
|
|
420
422
|
for attempt in range(self.num_retries + 1):
|
|
421
423
|
try:
|
|
422
424
|
if explain_config is not None:
|
|
423
|
-
resp =
|
|
425
|
+
resp = self._api_client.explain(
|
|
424
426
|
request=_bytes,
|
|
425
427
|
skip_summary=explain_config.skip_summary,
|
|
426
428
|
)
|
|
427
429
|
summary = resp.summary
|
|
428
430
|
details = resp.details
|
|
429
431
|
else:
|
|
430
|
-
resp =
|
|
432
|
+
resp = self._api_client.predict(_bytes)
|
|
431
433
|
df = pd.DataFrame(**resp.prediction)
|
|
432
434
|
|
|
433
435
|
# Cast 'ENTITY' to correct data type:
|
|
@@ -633,7 +635,7 @@ class KumoRFM:
|
|
|
633
635
|
raise ValueError(_SIZE_LIMIT_MSG.format(stats=stats_msg))
|
|
634
636
|
|
|
635
637
|
try:
|
|
636
|
-
resp =
|
|
638
|
+
resp = self._api_client.evaluate(request_bytes)
|
|
637
639
|
except HTTPException as e:
|
|
638
640
|
try:
|
|
639
641
|
msg = json.loads(e.detail)['detail']
|
|
@@ -731,7 +733,8 @@ class KumoRFM:
|
|
|
731
733
|
graph_definition=self._graph_def,
|
|
732
734
|
)
|
|
733
735
|
|
|
734
|
-
resp =
|
|
736
|
+
resp = self._api_client.parse_query(request)
|
|
737
|
+
|
|
735
738
|
# TODO Expose validation warnings.
|
|
736
739
|
|
|
737
740
|
if len(resp.validation_response.warnings) > 0:
|
|
@@ -1035,7 +1038,6 @@ class KumoRFM:
|
|
|
1035
1038
|
train_time.astype('datetime64[ns]').astype(int).to_numpy(),
|
|
1036
1039
|
test_time.astype('datetime64[ns]').astype(int).to_numpy(),
|
|
1037
1040
|
]),
|
|
1038
|
-
run_mode=run_mode,
|
|
1039
1041
|
num_neighbors=num_neighbors,
|
|
1040
1042
|
exclude_cols_dict=exclude_cols_dict,
|
|
1041
1043
|
)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import json
|
|
3
|
+
from typing import Any, Dict, List, Tuple
|
|
4
|
+
|
|
5
|
+
import boto3
|
|
6
|
+
import requests
|
|
7
|
+
from mypy_boto3_sagemaker_runtime.client import SageMakerRuntimeClient
|
|
8
|
+
from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointOutputTypeDef
|
|
9
|
+
|
|
10
|
+
from kumoai.client import KumoClient
|
|
11
|
+
from kumoai.client.endpoints import Endpoint, HTTPMethod
|
|
12
|
+
from kumoai.exceptions import HTTPException
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SageMakerResponseAdapter(requests.Response):
|
|
16
|
+
def __init__(self, sm_response: InvokeEndpointOutputTypeDef):
|
|
17
|
+
super().__init__()
|
|
18
|
+
# Read the body bytes
|
|
19
|
+
self._content = sm_response['Body'].read()
|
|
20
|
+
self.status_code = 200
|
|
21
|
+
self.headers['Content-Type'] = sm_response.get('ContentType',
|
|
22
|
+
'application/json')
|
|
23
|
+
# Optionally, you can store original sm_response for debugging
|
|
24
|
+
self.sm_response = sm_response
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def text(self) -> str:
|
|
28
|
+
assert isinstance(self._content, bytes)
|
|
29
|
+
return self._content.decode('utf-8')
|
|
30
|
+
|
|
31
|
+
def json(self, **kwargs) -> dict[str, Any]: # type: ignore
|
|
32
|
+
return json.loads(self.text, **kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class KumoClient_SageMakerAdapter(KumoClient):
|
|
36
|
+
def __init__(self, region: str, endpoint_name: str):
|
|
37
|
+
self._client: SageMakerRuntimeClient = boto3.client(
|
|
38
|
+
service_name="sagemaker-runtime", region_name=region)
|
|
39
|
+
self._endpoint_name = endpoint_name
|
|
40
|
+
|
|
41
|
+
# Recording buffers.
|
|
42
|
+
self._recording_active = False
|
|
43
|
+
self._recorded_reqs: List[Dict[str, Any]] = []
|
|
44
|
+
self._recorded_resps: List[Dict[str, Any]] = []
|
|
45
|
+
|
|
46
|
+
def authenticate(self) -> None:
|
|
47
|
+
# TODO(siyang): call /ping to verify?
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
def _request(self, endpoint: Endpoint, **kwargs: Any) -> requests.Response:
|
|
51
|
+
assert endpoint.method == HTTPMethod.POST
|
|
52
|
+
if 'json' in kwargs:
|
|
53
|
+
payload = json.dumps(kwargs.pop('json'))
|
|
54
|
+
elif 'data' in kwargs:
|
|
55
|
+
raw_payload = kwargs.pop('data')
|
|
56
|
+
assert isinstance(raw_payload, bytes)
|
|
57
|
+
payload = base64.b64encode(raw_payload).decode()
|
|
58
|
+
else:
|
|
59
|
+
raise HTTPException(400, 'Unable to send data to KumoRFM.')
|
|
60
|
+
|
|
61
|
+
request = {
|
|
62
|
+
'method': endpoint.get_path().rsplit('/')[-1],
|
|
63
|
+
'payload': payload,
|
|
64
|
+
}
|
|
65
|
+
response: InvokeEndpointOutputTypeDef = self._client.invoke_endpoint(
|
|
66
|
+
EndpointName=self._endpoint_name,
|
|
67
|
+
ContentType="application/json",
|
|
68
|
+
Body=json.dumps(request),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
adapted_response = SageMakerResponseAdapter(response)
|
|
72
|
+
|
|
73
|
+
# If validation is active, store input/output
|
|
74
|
+
if self._recording_active:
|
|
75
|
+
self._recorded_reqs.append(request)
|
|
76
|
+
self._recorded_resps.append(adapted_response.json())
|
|
77
|
+
|
|
78
|
+
return adapted_response
|
|
79
|
+
|
|
80
|
+
def start_recording(self) -> None:
|
|
81
|
+
"""Start recording requests/responses to/from sagemaker endpoint."""
|
|
82
|
+
assert not self._recording_active
|
|
83
|
+
self._recording_active = True
|
|
84
|
+
self._recorded_reqs.clear()
|
|
85
|
+
self._recorded_resps.clear()
|
|
86
|
+
|
|
87
|
+
def end_recording(self) -> List[Tuple[Dict[str, Any], Dict[str, Any]]]:
|
|
88
|
+
"""Stop recording and return recorded requests/responses."""
|
|
89
|
+
assert self._recording_active
|
|
90
|
+
self._recording_active = False
|
|
91
|
+
recorded = list(zip(self._recorded_reqs, self._recorded_resps))
|
|
92
|
+
self._recorded_reqs.clear()
|
|
93
|
+
self._recorded_resps.clear()
|
|
94
|
+
return recorded
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class KumoClient_SageMakerProxy_Local(KumoClient):
|
|
98
|
+
def __init__(self, url: str):
|
|
99
|
+
self._client = KumoClient(url, api_key=None)
|
|
100
|
+
self._client._api_url = self._client._url
|
|
101
|
+
self._endpoint = Endpoint('/invocations', HTTPMethod.POST)
|
|
102
|
+
|
|
103
|
+
def authenticate(self) -> None:
|
|
104
|
+
try:
|
|
105
|
+
self._client._session.get(
|
|
106
|
+
self._url + '/ping',
|
|
107
|
+
verify=self._verify_ssl).raise_for_status()
|
|
108
|
+
except Exception:
|
|
109
|
+
raise ValueError(
|
|
110
|
+
"Client authentication failed. Please check if you "
|
|
111
|
+
"have a valid API key/credentials.")
|
|
112
|
+
|
|
113
|
+
def _request(self, endpoint: Endpoint, **kwargs: Any) -> requests.Response:
|
|
114
|
+
assert endpoint.method == HTTPMethod.POST
|
|
115
|
+
if 'json' in kwargs:
|
|
116
|
+
payload = json.dumps(kwargs.pop('json'))
|
|
117
|
+
elif 'data' in kwargs:
|
|
118
|
+
raw_payload = kwargs.pop('data')
|
|
119
|
+
assert isinstance(raw_payload, bytes)
|
|
120
|
+
payload = base64.b64encode(raw_payload).decode()
|
|
121
|
+
else:
|
|
122
|
+
raise HTTPException(400, 'Unable to send data to KumoRFM.')
|
|
123
|
+
return self._client._request(
|
|
124
|
+
self._endpoint,
|
|
125
|
+
json={
|
|
126
|
+
'method': endpoint.get_path().rsplit('/')[-1],
|
|
127
|
+
'payload': payload,
|
|
128
|
+
},
|
|
129
|
+
**kwargs,
|
|
130
|
+
)
|
kumoai/spcs.py
CHANGED
|
@@ -54,9 +54,7 @@ def _refresh_spcs_token() -> None:
|
|
|
54
54
|
api_key=global_state._api_key,
|
|
55
55
|
spcs_token=spcs_token,
|
|
56
56
|
)
|
|
57
|
-
|
|
58
|
-
raise ValueError("Client authentication failed. Please check if you "
|
|
59
|
-
"have a valid API key.")
|
|
57
|
+
client.authenticate()
|
|
60
58
|
|
|
61
59
|
# Update state:
|
|
62
60
|
global_state.set_spcs_token(spcs_token)
|
{kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kumoai
|
|
3
|
-
Version: 2.13.0.
|
|
3
|
+
Version: 2.13.0.dev202511191731
|
|
4
4
|
Summary: AI on the Modern Data Stack
|
|
5
5
|
Author-email: "Kumo.AI" <hello@kumo.ai>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -23,11 +23,13 @@ Requires-Dist: requests>=2.28.2
|
|
|
23
23
|
Requires-Dist: urllib3
|
|
24
24
|
Requires-Dist: plotly
|
|
25
25
|
Requires-Dist: typing_extensions>=4.5.0
|
|
26
|
-
Requires-Dist: kumo-api==0.
|
|
26
|
+
Requires-Dist: kumo-api==0.46.0
|
|
27
27
|
Requires-Dist: tqdm>=4.66.0
|
|
28
28
|
Requires-Dist: aiohttp>=3.10.0
|
|
29
29
|
Requires-Dist: pydantic>=1.10.21
|
|
30
30
|
Requires-Dist: rich>=9.0.0
|
|
31
|
+
Requires-Dist: mypy-boto3-sagemaker-runtime
|
|
32
|
+
Requires-Dist: boto3
|
|
31
33
|
Provides-Extra: doc
|
|
32
34
|
Requires-Dist: sphinx; extra == "doc"
|
|
33
35
|
Requires-Dist: sphinx-book-theme; extra == "doc"
|
|
@@ -38,6 +40,13 @@ Provides-Extra: test
|
|
|
38
40
|
Requires-Dist: pytest; extra == "test"
|
|
39
41
|
Requires-Dist: pytest-mock; extra == "test"
|
|
40
42
|
Requires-Dist: requests-mock; extra == "test"
|
|
43
|
+
Provides-Extra: test-sagemaker
|
|
44
|
+
Requires-Dist: sagemaker; extra == "test-sagemaker"
|
|
45
|
+
Requires-Dist: pandas==2.1.4; extra == "test-sagemaker"
|
|
46
|
+
Requires-Dist: pyarrow==12.0.1; extra == "test-sagemaker"
|
|
47
|
+
Provides-Extra: sagemaker
|
|
48
|
+
Requires-Dist: boto3<2.0,>=1.30.0; extra == "sagemaker"
|
|
49
|
+
Requires-Dist: mypy-boto3-sagemaker-runtime<2.0,>=1.34.0; extra == "sagemaker"
|
|
41
50
|
Dynamic: license-file
|
|
42
51
|
Dynamic: requires-dist
|
|
43
52
|
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
kumoai/_logging.py,sha256=U2_5ROdyk92P4xO4H2WJV8EC7dr6YxmmnM-b7QX9M7I,886
|
|
2
2
|
kumoai/mixin.py,sha256=MP413xzuCqWhxAPUHmloLA3j4ZyF1tEtfi516b_hOXQ,812
|
|
3
|
-
kumoai/_version.py,sha256=
|
|
4
|
-
kumoai/__init__.py,sha256=
|
|
3
|
+
kumoai/_version.py,sha256=DQMe1_l3GF0z-d0Z7gv1y4f2nJER6406wlXsARrcwqs,39
|
|
4
|
+
kumoai/__init__.py,sha256=L3yOOtpSdwe3PYQlJBLkiQd3Ypp8iB5ChXkzprk3Si4,10546
|
|
5
5
|
kumoai/formatting.py,sha256=jA_rLDCGKZI8WWCha-vtuLenVKTZvli99Tqpurz1H84,953
|
|
6
6
|
kumoai/futures.py,sha256=oJFIfdCM_3nWIqQteBKYMY4fPhoYlYWE_JA2o6tx-ng,3737
|
|
7
7
|
kumoai/jobs.py,sha256=NrdLEFNo7oeCYSy-kj2nAvCFrz9BZ_xrhkqHFHk5ksY,2496
|
|
8
8
|
kumoai/exceptions.py,sha256=b-_sdbAKOg50uaJZ65GmBLdTo4HANdjl8_R0sJpwaN0,833
|
|
9
9
|
kumoai/kumolib.cpython-310-darwin.so,sha256=fiuDOY8RgGyYRvHhavN6_q2MxGynnwSHiFn2HWGnhSQ,232544
|
|
10
10
|
kumoai/databricks.py,sha256=e6E4lOFvZHXFwh4CO1kXU1zzDU3AapLQYMxjiHPC-HQ,476
|
|
11
|
-
kumoai/spcs.py,sha256=
|
|
11
|
+
kumoai/spcs.py,sha256=N31d7rLa-bgYh8e2J4YzX1ScxGLqiVXrqJnCl1y4Mts,4139
|
|
12
12
|
kumoai/_singleton.py,sha256=UTwrbDkoZSGB8ZelorvprPDDv9uZkUi1q_SrmsyngpQ,836
|
|
13
13
|
kumoai/experimental/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
kumoai/experimental/rfm/local_graph_sampler.py,sha256=
|
|
14
|
+
kumoai/experimental/rfm/local_graph_sampler.py,sha256=5DbhL9h0usFKSJfnx7HjLMPcG54qwJ48M2tmONqxXyY,6672
|
|
15
15
|
kumoai/experimental/rfm/local_graph.py,sha256=2iJDlsGVzqCe1bD_puXWlhwGkn7YnQyJ4p4C-fwCZNE,30076
|
|
16
16
|
kumoai/experimental/rfm/local_pquery_driver.py,sha256=aO7Jfwx9gxGKYvpqxZx1LLWdI1MhuZQOPtAITxoOQO0,26162
|
|
17
|
-
kumoai/experimental/rfm/__init__.py,sha256=
|
|
17
|
+
kumoai/experimental/rfm/__init__.py,sha256=wKfMKTxfuJNH1GCWGZ7-288HXil0tsCuXqg-BAFctZE,6812
|
|
18
18
|
kumoai/experimental/rfm/utils.py,sha256=3IiBvT_aLBkkcJh3H11_50yt_XlEzHR0cm9Kprrtl8k,11123
|
|
19
|
+
kumoai/experimental/rfm/sagemaker.py,sha256=e0rRQ28WcgAk_ALqUyU20d193c8_68rCkSengZIHu3Y,4823
|
|
19
20
|
kumoai/experimental/rfm/local_table.py,sha256=r8xZ33Mjs6JD8ud6h23tZ99Dag2DvZ4h6tWjmGrKQg4,19605
|
|
20
|
-
kumoai/experimental/rfm/rfm.py,sha256=
|
|
21
|
+
kumoai/experimental/rfm/rfm.py,sha256=8SvGWfMuRYJgiz5OTplu7m47mDrHAjQ2mRZtRASnSCk,48136
|
|
21
22
|
kumoai/experimental/rfm/local_graph_store.py,sha256=8BqonuaMftAAsjgZpB369i5AeNd1PkisMbbEqc0cKBo,13847
|
|
22
23
|
kumoai/experimental/rfm/authenticate.py,sha256=FiuHMvP7V3zBZUlHMDMbNLhc-UgDZgz4hjVSTuQ7DRw,18888
|
|
23
24
|
kumoai/experimental/rfm/pquery/__init__.py,sha256=X0O3EIq5SMfBEE-ii5Cq6iDhR3s3XMXB52Cx5htoePw,152
|
|
@@ -73,7 +74,7 @@ kumoai/pquery/predictive_query.py,sha256=oUqwdOWLLkPM-G4PhpUk_6mwSJGBtaD3t37Wp5O
|
|
|
73
74
|
kumoai/pquery/prediction_table.py,sha256=QPDH22X1UB0NIufY7qGuV2XW7brG3Pv--FbjNezzM2g,10776
|
|
74
75
|
kumoai/pquery/training_table.py,sha256=elmPDZx11kPiC_dkOhJcBUGtHKgL32GCBvZ9k6U0pMg,15809
|
|
75
76
|
kumoai/client/pquery.py,sha256=R2hc-M8vPoyIDH0ywLwFVxCznVAqpZz3w2HszjdNW-o,6891
|
|
76
|
-
kumoai/client/client.py,sha256=
|
|
77
|
+
kumoai/client/client.py,sha256=Jda8V9yiu3LbhxlcgRWPeYi7eF6jzCKcq8-B_vEd1ik,8514
|
|
77
78
|
kumoai/client/graph.py,sha256=zvLEDExLT_RVbUMHqVl0m6tO6s2gXmYSoWmPF6YMlnA,3831
|
|
78
79
|
kumoai/client/online.py,sha256=pkBBh_DEC3GAnPcNw6bopNRlGe7EUbIFe7_seQqZRaw,2720
|
|
79
80
|
kumoai/client/source_table.py,sha256=VCsCcM7KYcnjGP7HLTb-AOSEGEVsJTWjk8bMg1JdgPU,2101
|
|
@@ -91,8 +92,8 @@ kumoai/trainer/baseline_trainer.py,sha256=LlfViNOmswNv4c6zJJLsyv0pC2mM2WKMGYx06o
|
|
|
91
92
|
kumoai/trainer/__init__.py,sha256=zUdFl-f-sBWmm2x8R-rdVzPBeU2FaMzUY5mkcgoTa1k,939
|
|
92
93
|
kumoai/trainer/online_serving.py,sha256=9cddb5paeZaCgbUeceQdAOxysCtV5XP-KcsgFz_XR5w,9566
|
|
93
94
|
kumoai/trainer/trainer.py,sha256=hBXO7gwpo3t59zKFTeIkK65B8QRmWCwO33sbDuEAPlY,20133
|
|
94
|
-
kumoai-2.13.0.
|
|
95
|
-
kumoai-2.13.0.
|
|
96
|
-
kumoai-2.13.0.
|
|
97
|
-
kumoai-2.13.0.
|
|
98
|
-
kumoai-2.13.0.
|
|
95
|
+
kumoai-2.13.0.dev202511191731.dist-info/RECORD,,
|
|
96
|
+
kumoai-2.13.0.dev202511191731.dist-info/WHEEL,sha256=11kMdE9gzbsaQG30fRcsAYxBLEVRsqJo098Y5iL60Xo,136
|
|
97
|
+
kumoai-2.13.0.dev202511191731.dist-info/top_level.txt,sha256=YjU6UcmomoDx30vEXLsOU784ED7VztQOsFApk1SFwvs,7
|
|
98
|
+
kumoai-2.13.0.dev202511191731.dist-info/METADATA,sha256=CMJObe3toL1kXWv7kpgS-yQ9q6egpKJmPWJPHph05Gc,2475
|
|
99
|
+
kumoai-2.13.0.dev202511191731.dist-info/licenses/LICENSE,sha256=TbWlyqRmhq9PEzCaTI0H0nWLQCCOywQM8wYH8MbjfLo,1102
|
|
File without changes
|
{kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{kumoai-2.13.0.dev202511131731.dist-info → kumoai-2.13.0.dev202511191731.dist-info}/top_level.txt
RENAMED
|
File without changes
|