chalkpy 2.97.1__py3-none-any.whl → 2.97.3__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.
- chalk/_gen/chalk/server/v1/named_query_pb2.py +12 -12
- chalk/_gen/chalk/server/v1/named_query_pb2.pyi +4 -2
- chalk/_version.py +1 -1
- chalk/client/client.py +32 -1
- chalk/client/client_async.py +1 -1
- chalk/client/client_grpc.py +53 -0
- chalk/client/client_impl.py +113 -39
- chalk/client/models.py +50 -1
- chalk/features/feature_set_decorator.py +4 -1
- {chalkpy-2.97.1.dist-info → chalkpy-2.97.3.dist-info}/METADATA +1 -1
- {chalkpy-2.97.1.dist-info → chalkpy-2.97.3.dist-info}/RECORD +14 -14
- {chalkpy-2.97.1.dist-info → chalkpy-2.97.3.dist-info}/WHEEL +0 -0
- {chalkpy-2.97.1.dist-info → chalkpy-2.97.3.dist-info}/entry_points.txt +0 -0
- {chalkpy-2.97.1.dist-info → chalkpy-2.97.3.dist-info}/top_level.txt +0 -0
|
@@ -18,7 +18,7 @@ from chalk._gen.chalk.graph.v1 import graph_pb2 as chalk_dot_graph_dot_v1_dot_gr
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
|
|
21
|
-
b'\n!chalk/server/v1/named_query.proto\x12\x0f\x63halk.server.v1\x1a\x1f\x63halk/auth/v1/permissions.proto\x1a\x1a\x63halk/graph/v1/graph.proto"@\n\x19GetAllNamedQueriesRequest\x12#\n\rdeployment_id\x18\x01 \x01(\tR\x0c\x64\x65ploymentId"
|
|
21
|
+
b'\n!chalk/server/v1/named_query.proto\x12\x0f\x63halk.server.v1\x1a\x1f\x63halk/auth/v1/permissions.proto\x1a\x1a\x63halk/graph/v1/graph.proto"@\n\x19GetAllNamedQueriesRequest\x12#\n\rdeployment_id\x18\x01 \x01(\tR\x0c\x64\x65ploymentId"l\n\x1aGetNamedQueryByNameRequest\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12(\n\rquery_version\x18\x02 \x01(\tH\x00R\x0cqueryVersion\x88\x01\x01\x42\x10\n\x0e_query_version"^\n\x1bGetNamedQueryByNameResponse\x12?\n\rnamed_queries\x18\x01 \x03(\x0b\x32\x1a.chalk.graph.v1.NamedQueryR\x0cnamedQueries"]\n\x1aGetAllNamedQueriesResponse\x12?\n\rnamed_queries\x18\x01 \x03(\x0b\x32\x1a.chalk.graph.v1.NamedQueryR\x0cnamedQueries"+\n)GetAllNamedQueriesActiveDeploymentRequest"m\n*GetAllNamedQueriesActiveDeploymentResponse\x12?\n\rnamed_queries\x18\x01 \x03(\x0b\x32\x1a.chalk.graph.v1.NamedQueryR\x0cnamedQueries2\xac\x03\n\x11NamedQueryService\x12u\n\x12GetAllNamedQueries\x12*.chalk.server.v1.GetAllNamedQueriesRequest\x1a+.chalk.server.v1.GetAllNamedQueriesResponse"\x06\x90\x02\x01\x80}\x0b\x12\xa5\x01\n"GetAllNamedQueriesActiveDeployment\x12:.chalk.server.v1.GetAllNamedQueriesActiveDeploymentRequest\x1a;.chalk.server.v1.GetAllNamedQueriesActiveDeploymentResponse"\x06\x90\x02\x01\x80}\x0b\x12x\n\x13GetNamedQueryByName\x12+.chalk.server.v1.GetNamedQueryByNameRequest\x1a,.chalk.server.v1.GetNamedQueryByNameResponse"\x06\x90\x02\x01\x80}\x0b\x42\x98\x01\n\x13\x63om.chalk.server.v1B\x0fNamedQueryProtoP\x01Z\x12server/v1;serverv1\xa2\x02\x03\x43SX\xaa\x02\x0f\x43halk.Server.V1\xca\x02\x0f\x43halk\\Server\\V1\xe2\x02\x1b\x43halk\\Server\\V1\\GPBMetadata\xea\x02\x11\x43halk::Server::V1b\x06proto3'
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
_globals = globals()
|
|
@@ -40,15 +40,15 @@ if _descriptor._USE_C_DESCRIPTORS == False:
|
|
|
40
40
|
_globals["_GETALLNAMEDQUERIESREQUEST"]._serialized_start = 115
|
|
41
41
|
_globals["_GETALLNAMEDQUERIESREQUEST"]._serialized_end = 179
|
|
42
42
|
_globals["_GETNAMEDQUERYBYNAMEREQUEST"]._serialized_start = 181
|
|
43
|
-
_globals["_GETNAMEDQUERYBYNAMEREQUEST"]._serialized_end =
|
|
44
|
-
_globals["_GETNAMEDQUERYBYNAMERESPONSE"]._serialized_start =
|
|
45
|
-
_globals["_GETNAMEDQUERYBYNAMERESPONSE"]._serialized_end =
|
|
46
|
-
_globals["_GETALLNAMEDQUERIESRESPONSE"]._serialized_start =
|
|
47
|
-
_globals["_GETALLNAMEDQUERIESRESPONSE"]._serialized_end =
|
|
48
|
-
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTREQUEST"]._serialized_start =
|
|
49
|
-
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTREQUEST"]._serialized_end =
|
|
50
|
-
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTRESPONSE"]._serialized_start =
|
|
51
|
-
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTRESPONSE"]._serialized_end =
|
|
52
|
-
_globals["_NAMEDQUERYSERVICE"]._serialized_start =
|
|
53
|
-
_globals["_NAMEDQUERYSERVICE"]._serialized_end =
|
|
43
|
+
_globals["_GETNAMEDQUERYBYNAMEREQUEST"]._serialized_end = 289
|
|
44
|
+
_globals["_GETNAMEDQUERYBYNAMERESPONSE"]._serialized_start = 291
|
|
45
|
+
_globals["_GETNAMEDQUERYBYNAMERESPONSE"]._serialized_end = 385
|
|
46
|
+
_globals["_GETALLNAMEDQUERIESRESPONSE"]._serialized_start = 387
|
|
47
|
+
_globals["_GETALLNAMEDQUERIESRESPONSE"]._serialized_end = 480
|
|
48
|
+
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTREQUEST"]._serialized_start = 482
|
|
49
|
+
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTREQUEST"]._serialized_end = 525
|
|
50
|
+
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTRESPONSE"]._serialized_start = 527
|
|
51
|
+
_globals["_GETALLNAMEDQUERIESACTIVEDEPLOYMENTRESPONSE"]._serialized_end = 636
|
|
52
|
+
_globals["_NAMEDQUERYSERVICE"]._serialized_start = 639
|
|
53
|
+
_globals["_NAMEDQUERYSERVICE"]._serialized_end = 1067
|
|
54
54
|
# @@protoc_insertion_point(module_scope)
|
|
@@ -20,10 +20,12 @@ class GetAllNamedQueriesRequest(_message.Message):
|
|
|
20
20
|
def __init__(self, deployment_id: _Optional[str] = ...) -> None: ...
|
|
21
21
|
|
|
22
22
|
class GetNamedQueryByNameRequest(_message.Message):
|
|
23
|
-
__slots__ = ("name",)
|
|
23
|
+
__slots__ = ("name", "query_version")
|
|
24
24
|
NAME_FIELD_NUMBER: _ClassVar[int]
|
|
25
|
+
QUERY_VERSION_FIELD_NUMBER: _ClassVar[int]
|
|
25
26
|
name: str
|
|
26
|
-
|
|
27
|
+
query_version: str
|
|
28
|
+
def __init__(self, name: _Optional[str] = ..., query_version: _Optional[str] = ...) -> None: ...
|
|
27
29
|
|
|
28
30
|
class GetNamedQueryByNameResponse(_message.Message):
|
|
29
31
|
__slots__ = ("named_queries",)
|
chalk/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.97.
|
|
1
|
+
__version__ = "2.97.3"
|
chalk/client/client.py
CHANGED
|
@@ -33,6 +33,7 @@ from chalk.client.models import (
|
|
|
33
33
|
GetRegisteredModelResponse,
|
|
34
34
|
GetRegisteredModelVersionResponse,
|
|
35
35
|
ManualTriggerScheduledQueryResponse,
|
|
36
|
+
NamedQueryMetadata,
|
|
36
37
|
OfflineQueryDeadlineOptions,
|
|
37
38
|
OfflineQueryInputUri,
|
|
38
39
|
OnlineQuery,
|
|
@@ -527,7 +528,7 @@ class ChalkClient:
|
|
|
527
528
|
explain: bool = False,
|
|
528
529
|
num_input_rows: Optional[int] = None,
|
|
529
530
|
headers: Mapping[str, str] | None = None,
|
|
530
|
-
planner_options: Mapping[str,
|
|
531
|
+
planner_options: Mapping[str, Any] | None = None,
|
|
531
532
|
) -> PlanQueryResponse:
|
|
532
533
|
"""Plan a query without executing it.
|
|
533
534
|
|
|
@@ -1169,6 +1170,36 @@ class ChalkClient:
|
|
|
1169
1170
|
"""
|
|
1170
1171
|
...
|
|
1171
1172
|
|
|
1173
|
+
def get_named_query_metadata(
|
|
1174
|
+
self,
|
|
1175
|
+
name: str,
|
|
1176
|
+
query_version: str | None = None,
|
|
1177
|
+
) -> List[NamedQueryMetadata]:
|
|
1178
|
+
"""
|
|
1179
|
+
Get the metadata associated with named queries.
|
|
1180
|
+
|
|
1181
|
+
Parameters
|
|
1182
|
+
----------
|
|
1183
|
+
name
|
|
1184
|
+
The name of the named query.
|
|
1185
|
+
query_version
|
|
1186
|
+
The query version of the named query. Returns all versions of the named query by default.
|
|
1187
|
+
|
|
1188
|
+
Returns
|
|
1189
|
+
-------
|
|
1190
|
+
list[ScheduledQueryRun]
|
|
1191
|
+
A response message containing the list of metadata of named queries.
|
|
1192
|
+
|
|
1193
|
+
Examples
|
|
1194
|
+
--------
|
|
1195
|
+
>>> from chalk.client import ChalkClient
|
|
1196
|
+
>>> ChalkClient().get_named_query_metadata(
|
|
1197
|
+
... name="my_named_query",
|
|
1198
|
+
... query_version="1.1.0",
|
|
1199
|
+
... )
|
|
1200
|
+
"""
|
|
1201
|
+
...
|
|
1202
|
+
|
|
1172
1203
|
def prompt_evaluation(
|
|
1173
1204
|
self,
|
|
1174
1205
|
prompts: list[Prompt | str],
|
chalk/client/client_async.py
CHANGED
|
@@ -487,7 +487,7 @@ class AsyncChalkClient:
|
|
|
487
487
|
explain: bool = False,
|
|
488
488
|
num_input_rows: Optional[int] = None,
|
|
489
489
|
headers: Mapping[str, str] | None = None,
|
|
490
|
-
planner_options: Mapping[str,
|
|
490
|
+
planner_options: Mapping[str, Any] | None = None,
|
|
491
491
|
) -> PlanQueryResponse:
|
|
492
492
|
"""Plan a query without executing it.
|
|
493
493
|
|
chalk/client/client_grpc.py
CHANGED
|
@@ -74,6 +74,8 @@ from chalk._gen.chalk.server.v1.model_registry_pb2 import (
|
|
|
74
74
|
GetModelVersionResponse,
|
|
75
75
|
)
|
|
76
76
|
from chalk._gen.chalk.server.v1.model_registry_pb2_grpc import ModelRegistryServiceStub
|
|
77
|
+
from chalk._gen.chalk.server.v1.named_query_pb2 import GetNamedQueryByNameRequest
|
|
78
|
+
from chalk._gen.chalk.server.v1.named_query_pb2_grpc import NamedQueryServiceStub
|
|
77
79
|
from chalk._gen.chalk.server.v1.offline_queries_pb2_grpc import OfflineQueryMetadataServiceStub
|
|
78
80
|
from chalk._gen.chalk.server.v1.scheduled_query_pb2_grpc import ScheduledQueryServiceStub
|
|
79
81
|
from chalk._gen.chalk.server.v1.scheduled_query_run_pb2 import GetScheduledQueryRunsRequest
|
|
@@ -102,6 +104,7 @@ from chalk.client.models import (
|
|
|
102
104
|
from chalk.client.models import ManualTriggerScheduledQueryResponse as ManualTriggerScheduledQueryResponseDataclass
|
|
103
105
|
from chalk.client.models import (
|
|
104
106
|
ModelUploadUrlResponse,
|
|
107
|
+
NamedQueryMetadata,
|
|
105
108
|
OnlineQuery,
|
|
106
109
|
OnlineQueryResponse,
|
|
107
110
|
RegisterModelArtifactResponse,
|
|
@@ -310,6 +313,14 @@ class StubProvider:
|
|
|
310
313
|
)
|
|
311
314
|
return ScheduledQueryServiceStub(self._server_channel)
|
|
312
315
|
|
|
316
|
+
@cached_property
|
|
317
|
+
def named_query_stub(self) -> NamedQueryServiceStub:
|
|
318
|
+
if self._server_channel is None:
|
|
319
|
+
raise ValueError(
|
|
320
|
+
"The GRPC engine service is not available. If you would like to set up a GRPC service, please contact Chalk."
|
|
321
|
+
)
|
|
322
|
+
return NamedQueryServiceStub(self._server_channel)
|
|
323
|
+
|
|
313
324
|
@cached_property
|
|
314
325
|
def sql_stub(self) -> SqlServiceStub:
|
|
315
326
|
if self._engine_channel is None:
|
|
@@ -568,6 +579,9 @@ class StubRefresher:
|
|
|
568
579
|
def call_scheduled_query_run_stub(self, fn: Callable[[ScheduledQueryServiceStub], T]) -> T:
|
|
569
580
|
return self._retry_callable(fn, lambda: self._stub.scheduled_query_run_stub)
|
|
570
581
|
|
|
582
|
+
def call_get_named_query_metadata(self, fn: Callable[[NamedQueryServiceStub], T]) -> T:
|
|
583
|
+
return self._retry_callable(fn, lambda: self._stub.named_query_stub)
|
|
584
|
+
|
|
571
585
|
def call_sql_stub(self, fn: Callable[[SqlServiceStub], T]) -> T:
|
|
572
586
|
return self._retry_callable(fn, lambda: self._stub.sql_stub)
|
|
573
587
|
|
|
@@ -1376,6 +1390,45 @@ class ChalkGRPCClient:
|
|
|
1376
1390
|
)
|
|
1377
1391
|
return [ScheduledQueryRun.from_proto(run) for run in proto_resp.runs]
|
|
1378
1392
|
|
|
1393
|
+
def get_named_query_metadata(
|
|
1394
|
+
self,
|
|
1395
|
+
name: str,
|
|
1396
|
+
query_version: str | None = None,
|
|
1397
|
+
) -> List[NamedQueryMetadata]:
|
|
1398
|
+
"""
|
|
1399
|
+
Get the metadata associated with named queries.
|
|
1400
|
+
|
|
1401
|
+
Parameters
|
|
1402
|
+
----------
|
|
1403
|
+
name
|
|
1404
|
+
The name of the named query.
|
|
1405
|
+
query_version
|
|
1406
|
+
The query version of the named query. Returns all versions of the named query by default.
|
|
1407
|
+
|
|
1408
|
+
Returns
|
|
1409
|
+
-------
|
|
1410
|
+
list[ScheduledQueryRun]
|
|
1411
|
+
A response message containing the list of metadata of named queries.
|
|
1412
|
+
|
|
1413
|
+
Examples
|
|
1414
|
+
--------
|
|
1415
|
+
>>> from chalk.client import ChalkClient
|
|
1416
|
+
>>> ChalkClient().get_named_query_metadata(
|
|
1417
|
+
... name="my_named_query",
|
|
1418
|
+
... query_version="1.1.0",
|
|
1419
|
+
... )
|
|
1420
|
+
"""
|
|
1421
|
+
proto_resp = self._stub_refresher.call_get_named_query_metadata(
|
|
1422
|
+
lambda x: x.GetNamedQueryByName(
|
|
1423
|
+
request=GetNamedQueryByNameRequest(
|
|
1424
|
+
name=name,
|
|
1425
|
+
query_version=query_version,
|
|
1426
|
+
)
|
|
1427
|
+
)
|
|
1428
|
+
)
|
|
1429
|
+
|
|
1430
|
+
return [NamedQueryMetadata.from_proto(nq) for nq in proto_resp.named_queries]
|
|
1431
|
+
|
|
1379
1432
|
def get_graph(self, deployment: DeploymentId | None = None) -> Graph:
|
|
1380
1433
|
"""Get the graph for a given deployment.
|
|
1381
1434
|
|
chalk/client/client_impl.py
CHANGED
|
@@ -102,6 +102,7 @@ from chalk.client.models import (
|
|
|
102
102
|
ManualTriggerScheduledQueryResponse,
|
|
103
103
|
MultiUploadFeaturesRequest,
|
|
104
104
|
MultiUploadFeaturesResponse,
|
|
105
|
+
NamedQueryMetadata,
|
|
105
106
|
OfflineQueryContext,
|
|
106
107
|
OfflineQueryDeadlineOptions,
|
|
107
108
|
OfflineQueryInput,
|
|
@@ -1032,6 +1033,10 @@ class ChalkAPIClientImpl(ChalkClient):
|
|
|
1032
1033
|
self._branch: str | None = branch
|
|
1033
1034
|
self._skip_token_cache: bool = _skip_cache
|
|
1034
1035
|
self._api_server: str | None = api_server
|
|
1036
|
+
self._env_id_to_engine_url_map: Mapping[str, str] | None = None
|
|
1037
|
+
self._env_id_to_env_name_map: Mapping[str, str] | None = None
|
|
1038
|
+
self._env_name_to_env_id_map: Mapping[str, str] | None = None
|
|
1039
|
+
self._access_token: str | None = None
|
|
1035
1040
|
|
|
1036
1041
|
self._default_headers = {
|
|
1037
1042
|
"Accept": "application/json",
|
|
@@ -1042,7 +1047,7 @@ class ChalkAPIClientImpl(ChalkClient):
|
|
|
1042
1047
|
if additional_headers:
|
|
1043
1048
|
self._default_headers.update(additional_headers)
|
|
1044
1049
|
|
|
1045
|
-
self._primary_environment = environment
|
|
1050
|
+
self._primary_environment: EnvironmentId | None = environment
|
|
1046
1051
|
|
|
1047
1052
|
self.__class__.latest_client = self
|
|
1048
1053
|
if notebook.is_notebook():
|
|
@@ -1115,11 +1120,16 @@ class ChalkAPIClientImpl(ChalkClient):
|
|
|
1115
1120
|
creds = ExchangeCredentialsResponse(**response_json)
|
|
1116
1121
|
except ValidationError:
|
|
1117
1122
|
raise HTTPError(response=resp)
|
|
1123
|
+
self._access_token = creds.access_token
|
|
1118
1124
|
self._default_headers["Authorization"] = f"Bearer {creds.access_token}"
|
|
1119
1125
|
# FIXME: We should NOT be using the X-Chalk-Client-Id for anything, as it is NOT authenticated
|
|
1120
1126
|
self._default_headers["X-Chalk-Client-Id"] = self._client_id
|
|
1121
1127
|
if self._primary_environment is None:
|
|
1122
1128
|
self._primary_environment = creds.primary_environment
|
|
1129
|
+
self._env_id_to_engine_url_map = creds.engines
|
|
1130
|
+
self._env_id_to_env_name_map = creds.environment_id_to_name
|
|
1131
|
+
if self._env_id_to_env_name_map is not None:
|
|
1132
|
+
self._env_name_to_env_id_map = {v: k for k, v in self._env_id_to_env_name_map.items()}
|
|
1123
1133
|
|
|
1124
1134
|
def _get_headers(
|
|
1125
1135
|
self,
|
|
@@ -1382,6 +1392,48 @@ https://docs.chalk.ai/docs/debugging-queries#resolver-replay
|
|
|
1382
1392
|
method=method, headers=headers, url=url, json=json_body, data=data, timeout=timeout_value
|
|
1383
1393
|
)
|
|
1384
1394
|
|
|
1395
|
+
def _get_engine_host(self, environment_override: Optional[str]) -> str | None:
|
|
1396
|
+
"""
|
|
1397
|
+
Returns the host to use for data-plane requests to the engine. May fall back to
|
|
1398
|
+
the metadata plane api server host if no engine host can be determined.
|
|
1399
|
+
:param environment_override: Optional user-provided environment name or id.
|
|
1400
|
+
:return: Host for direct engine (data-plane) requests
|
|
1401
|
+
"""
|
|
1402
|
+
|
|
1403
|
+
# always respect user-provided query_server override
|
|
1404
|
+
if self._query_server is not None:
|
|
1405
|
+
return self._query_server
|
|
1406
|
+
|
|
1407
|
+
# if we have no environment information, we likely have not done creds exchange yet.
|
|
1408
|
+
# there's no way to determine an engine host here, so just fall back to api server
|
|
1409
|
+
env_id_or_name: str | None = environment_override or self._primary_environment
|
|
1410
|
+
if env_id_or_name is None:
|
|
1411
|
+
return self._api_server
|
|
1412
|
+
|
|
1413
|
+
# get the correct engine url given a valid env id or env name
|
|
1414
|
+
if self._env_id_to_engine_url_map is not None:
|
|
1415
|
+
if env_id_or_name in self._env_id_to_engine_url_map:
|
|
1416
|
+
return self._env_id_to_engine_url_map[env_id_or_name]
|
|
1417
|
+
elif self._env_name_to_env_id_map is not None and env_id_or_name in self._env_name_to_env_id_map:
|
|
1418
|
+
env_id = self._env_name_to_env_id_map[env_id_or_name]
|
|
1419
|
+
return self._env_id_to_engine_url_map.get(env_id, self._api_server)
|
|
1420
|
+
|
|
1421
|
+
# env name or id is invalid, or we failed to auth, so fall back to api server
|
|
1422
|
+
return self._api_server
|
|
1423
|
+
|
|
1424
|
+
def _get_request_host(self, metadata_request: bool, environment_override: Optional[str]) -> str | None:
|
|
1425
|
+
"""
|
|
1426
|
+
Returns the hostname to use for any requests made by the Chalk Client, whether they are
|
|
1427
|
+
metadata-plane-only requests or data-plane requests (to the engine).
|
|
1428
|
+
:param metadata_request: Is this a metadata-plane-only request? If so, we always use the API server.
|
|
1429
|
+
:param environment_override: Optional user-provided environment name or id.
|
|
1430
|
+
:return: Host to use for any request made by the Chalk Client
|
|
1431
|
+
"""
|
|
1432
|
+
if metadata_request:
|
|
1433
|
+
return self._api_server
|
|
1434
|
+
else:
|
|
1435
|
+
return self._get_engine_host(environment_override)
|
|
1436
|
+
|
|
1385
1437
|
def _request(
|
|
1386
1438
|
self,
|
|
1387
1439
|
method: str,
|
|
@@ -1398,25 +1450,20 @@ https://docs.chalk.ai/docs/debugging-queries#resolver-replay
|
|
|
1398
1450
|
timeout: float | None | ellipsis = ...,
|
|
1399
1451
|
connect_timeout: float | None | ellipsis = ...,
|
|
1400
1452
|
) -> T | requests.Response:
|
|
1453
|
+
# If we don't have an access token, we cannot make a request.
|
|
1454
|
+
# Always fetch an access token if we do not have one before making a request.
|
|
1455
|
+
# If we fetched an access token during this call and we get 401/403 on this request,
|
|
1456
|
+
# then do not retry the credential exchange again.
|
|
1401
1457
|
allow_credential_exchange: bool = True
|
|
1402
|
-
|
|
1403
|
-
if metadata_request or self._query_server is None:
|
|
1404
|
-
host = self._api_server
|
|
1405
|
-
else:
|
|
1406
|
-
host = self._query_server
|
|
1407
|
-
|
|
1408
|
-
if host is None:
|
|
1409
|
-
# We definitively need to exchange credentials to get a host
|
|
1458
|
+
if self._access_token is None:
|
|
1410
1459
|
self._exchange_credentials()
|
|
1411
1460
|
allow_credential_exchange = False
|
|
1412
1461
|
|
|
1413
|
-
|
|
1414
|
-
assert self._api_server is not None
|
|
1462
|
+
host = self._get_request_host(metadata_request, environment_override)
|
|
1415
1463
|
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
host = self._query_server
|
|
1464
|
+
# After exchanging credentials, the api server is never null, and the request host
|
|
1465
|
+
# helper function falls back to the api server if it cannot determine an engine url
|
|
1466
|
+
assert host is not None, "After credential exchange, the request host must be non-null"
|
|
1420
1467
|
|
|
1421
1468
|
r = self._do_request_inner(
|
|
1422
1469
|
method=method,
|
|
@@ -1437,14 +1484,11 @@ https://docs.chalk.ai/docs/debugging-queries#resolver-replay
|
|
|
1437
1484
|
# It is possible that credentials expired, or that we changed permissions since we last
|
|
1438
1485
|
# got a token. Exchange them and try again
|
|
1439
1486
|
self._exchange_credentials()
|
|
1487
|
+
host = self._get_request_host(metadata_request, environment_override)
|
|
1440
1488
|
|
|
1441
|
-
# After exchanging credentials, the api server is never null
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
if metadata_request or self._query_server is None:
|
|
1445
|
-
host = self._api_server
|
|
1446
|
-
else:
|
|
1447
|
-
host = self._query_server
|
|
1489
|
+
# After exchanging credentials, the api server is never null, and the request host
|
|
1490
|
+
# helper function falls back to the api server if it cannot determine an engine url
|
|
1491
|
+
assert host is not None, "After credential exchange, the request host must be non-null"
|
|
1448
1492
|
|
|
1449
1493
|
r = self._do_request_inner(
|
|
1450
1494
|
method=method,
|
|
@@ -2519,6 +2563,50 @@ https://docs.chalk.ai/cli/apply
|
|
|
2519
2563
|
limit=limit,
|
|
2520
2564
|
)
|
|
2521
2565
|
|
|
2566
|
+
def get_named_query_metadata(
|
|
2567
|
+
self,
|
|
2568
|
+
name: str,
|
|
2569
|
+
query_version: str | None = None,
|
|
2570
|
+
) -> List[NamedQueryMetadata]:
|
|
2571
|
+
"""
|
|
2572
|
+
Get the metadata associated with named queries.
|
|
2573
|
+
|
|
2574
|
+
Parameters
|
|
2575
|
+
----------
|
|
2576
|
+
name
|
|
2577
|
+
The name of the named query.
|
|
2578
|
+
query_version
|
|
2579
|
+
The query version of the named query. Returns all versions of the named query by default.
|
|
2580
|
+
|
|
2581
|
+
Returns
|
|
2582
|
+
-------
|
|
2583
|
+
list[ScheduledQueryRun]
|
|
2584
|
+
A response message containing the list of metadata of named queries.
|
|
2585
|
+
|
|
2586
|
+
Examples
|
|
2587
|
+
--------
|
|
2588
|
+
>>> from chalk.client import ChalkClient
|
|
2589
|
+
>>> ChalkClient().get_named_query_metadata(
|
|
2590
|
+
... name="my_named_query",
|
|
2591
|
+
... query_version="1.1.0",
|
|
2592
|
+
... )
|
|
2593
|
+
"""
|
|
2594
|
+
from chalk.client.client_grpc import ChalkGRPCClient
|
|
2595
|
+
|
|
2596
|
+
client_grpc = ChalkGRPCClient(
|
|
2597
|
+
client_id=self._client_id,
|
|
2598
|
+
client_secret=self._client_secret,
|
|
2599
|
+
environment=self._primary_environment,
|
|
2600
|
+
api_server=self._api_server,
|
|
2601
|
+
)
|
|
2602
|
+
|
|
2603
|
+
resp = client_grpc.get_named_query_metadata(
|
|
2604
|
+
name=name,
|
|
2605
|
+
query_version=query_version,
|
|
2606
|
+
)
|
|
2607
|
+
|
|
2608
|
+
return resp
|
|
2609
|
+
|
|
2522
2610
|
def prompt_evaluation(
|
|
2523
2611
|
self,
|
|
2524
2612
|
prompts: list[Prompt | str],
|
|
@@ -3942,9 +4030,8 @@ https://docs.chalk.ai/cli/apply
|
|
|
3942
4030
|
environment_override=context.environment,
|
|
3943
4031
|
preview_deployment_id=preview_deployment_id,
|
|
3944
4032
|
branch=branch,
|
|
3945
|
-
#
|
|
3946
|
-
|
|
3947
|
-
metadata_request=request.use_multiple_computers,
|
|
4033
|
+
# all offline query requests should be routed through api server
|
|
4034
|
+
metadata_request=True,
|
|
3948
4035
|
)
|
|
3949
4036
|
return response
|
|
3950
4037
|
|
|
@@ -4020,19 +4107,6 @@ https://docs.chalk.ai/cli/apply
|
|
|
4020
4107
|
branch=None,
|
|
4021
4108
|
)
|
|
4022
4109
|
|
|
4023
|
-
def _get_query_inputs(
|
|
4024
|
-
self, job_id: uuid.UUID, environment: Optional[EnvironmentId], branch: Optional[BranchId]
|
|
4025
|
-
) -> GetOfflineQueryJobResponse:
|
|
4026
|
-
return self._request(
|
|
4027
|
-
method="GET",
|
|
4028
|
-
uri=f"/v2/offline_query_inputs/{job_id}",
|
|
4029
|
-
response=GetOfflineQueryJobResponse,
|
|
4030
|
-
environment_override=environment,
|
|
4031
|
-
json=None,
|
|
4032
|
-
preview_deployment_id=None,
|
|
4033
|
-
branch=branch,
|
|
4034
|
-
)
|
|
4035
|
-
|
|
4036
4110
|
def _get_dataset_from_name_or_id(
|
|
4037
4111
|
self,
|
|
4038
4112
|
*,
|
|
@@ -4446,7 +4520,7 @@ https://docs.chalk.ai/cli/apply
|
|
|
4446
4520
|
explain: bool = False,
|
|
4447
4521
|
num_input_rows: Optional[int] = None,
|
|
4448
4522
|
headers: Mapping[str, str] | None = None,
|
|
4449
|
-
planner_options: Mapping[str,
|
|
4523
|
+
planner_options: Mapping[str, Any] | None = None,
|
|
4450
4524
|
) -> PlanQueryResponse:
|
|
4451
4525
|
encoded_inputs = encode_outputs(input).string_outputs
|
|
4452
4526
|
outputs = encode_outputs(output).string_outputs
|
chalk/client/models.py
CHANGED
|
@@ -454,6 +454,8 @@ class ExchangeCredentialsResponse(BaseModel):
|
|
|
454
454
|
api_server: str
|
|
455
455
|
primary_environment: Optional[str] = None
|
|
456
456
|
engines: Optional[Mapping[str, str]] = None
|
|
457
|
+
grpc_engines: Optional[Mapping[str, str]] = None
|
|
458
|
+
environment_id_to_name: Optional[Mapping[str, str]] = None
|
|
457
459
|
|
|
458
460
|
|
|
459
461
|
class OfflineQueryInput(BaseModel):
|
|
@@ -1053,6 +1055,53 @@ class CreateOfflineQueryJobResponse(BaseModel):
|
|
|
1053
1055
|
errors: Optional[List[ChalkError]] = None
|
|
1054
1056
|
|
|
1055
1057
|
|
|
1058
|
+
@dataclasses.dataclass
|
|
1059
|
+
class NamedQueryMetadata:
|
|
1060
|
+
"""Metadata for a named query returned from the API."""
|
|
1061
|
+
|
|
1062
|
+
name: str
|
|
1063
|
+
input: List[str]
|
|
1064
|
+
output: List[str]
|
|
1065
|
+
query_version: Optional[str] = None
|
|
1066
|
+
tags: Optional[List[str]] = None
|
|
1067
|
+
description: Optional[str] = None
|
|
1068
|
+
owner: Optional[str] = None
|
|
1069
|
+
meta: Optional[Dict[str, str]] = None
|
|
1070
|
+
staleness: Optional[Dict[str, timedelta]] = None
|
|
1071
|
+
planner_options: Optional[Dict[str, str]] = None
|
|
1072
|
+
additional_logged_features: Optional[List[str]] = None
|
|
1073
|
+
valid_plan_not_required: Optional[bool] = None
|
|
1074
|
+
|
|
1075
|
+
@staticmethod
|
|
1076
|
+
def from_proto(proto_nq: Any) -> "NamedQueryMetadata":
|
|
1077
|
+
"""Convert a proto NamedQuery to the dataclass version."""
|
|
1078
|
+
# Convert proto Duration to timedelta
|
|
1079
|
+
staleness = None
|
|
1080
|
+
if proto_nq.staleness:
|
|
1081
|
+
staleness = {
|
|
1082
|
+
k: timedelta(seconds=v.seconds, microseconds=v.nanos / 1000) for k, v in proto_nq.staleness.items()
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
return NamedQueryMetadata(
|
|
1086
|
+
name=proto_nq.name,
|
|
1087
|
+
query_version=proto_nq.query_version if proto_nq.HasField("query_version") else None,
|
|
1088
|
+
input=list(proto_nq.input),
|
|
1089
|
+
output=list(proto_nq.output),
|
|
1090
|
+
tags=list(proto_nq.tags) if proto_nq.tags else None,
|
|
1091
|
+
description=proto_nq.description if proto_nq.HasField("description") else None,
|
|
1092
|
+
owner=proto_nq.owner if proto_nq.HasField("owner") else None,
|
|
1093
|
+
meta=dict(proto_nq.meta) if proto_nq.meta else None,
|
|
1094
|
+
staleness=staleness,
|
|
1095
|
+
planner_options=dict(proto_nq.planner_options) if proto_nq.planner_options else None,
|
|
1096
|
+
additional_logged_features=list(proto_nq.additional_logged_features)
|
|
1097
|
+
if proto_nq.additional_logged_features
|
|
1098
|
+
else None,
|
|
1099
|
+
valid_plan_not_required=proto_nq.valid_plan_not_required
|
|
1100
|
+
if proto_nq.HasField("valid_plan_not_required")
|
|
1101
|
+
else None,
|
|
1102
|
+
)
|
|
1103
|
+
|
|
1104
|
+
|
|
1056
1105
|
class CreateBranchResponse(BaseModel):
|
|
1057
1106
|
branch_already_exists: bool
|
|
1058
1107
|
errors: Optional[List[ChalkError]] = None
|
|
@@ -1696,7 +1745,7 @@ class PlanQueryRequest(BaseModel):
|
|
|
1696
1745
|
explain: bool = False
|
|
1697
1746
|
store_plan_stages: bool = False
|
|
1698
1747
|
encoding_options: FeatureEncodingOptions = FeatureEncodingOptions()
|
|
1699
|
-
planner_options: Mapping[str,
|
|
1748
|
+
planner_options: Mapping[str, Any] | None = None
|
|
1700
1749
|
|
|
1701
1750
|
|
|
1702
1751
|
class FeatureSchema(BaseModel):
|
|
@@ -1330,12 +1330,15 @@ def _process_class(
|
|
|
1330
1330
|
error_builder=error_builder,
|
|
1331
1331
|
)
|
|
1332
1332
|
|
|
1333
|
-
# copy over expressions for default version
|
|
1333
|
+
# copy over expressions and metadata for default version
|
|
1334
1334
|
if i == f.version.default:
|
|
1335
1335
|
if f.underscore_expression is None and f_i.underscore_expression is not None:
|
|
1336
1336
|
f.underscore_expression = f_i.underscore_expression
|
|
1337
1337
|
if f.offline_underscore_expression is None and f_i.offline_underscore_expression is not None:
|
|
1338
1338
|
f.offline_underscore_expression = f_i.offline_underscore_expression
|
|
1339
|
+
# Copy description from the explicitly defined default version
|
|
1340
|
+
if f.description is None and f_i.description is not None:
|
|
1341
|
+
f.description = f_i.description
|
|
1339
1342
|
|
|
1340
1343
|
f.version.reference[i] = f_i
|
|
1341
1344
|
# The default feature already exists.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
chalk/__init__.py,sha256=vKsx9-cl5kImlVWGHVRYO6bweBm79NAzGs3l36u71wM,2657
|
|
2
|
-
chalk/_version.py,sha256=
|
|
2
|
+
chalk/_version.py,sha256=svi3Ka1WRt3F0YuX1rlhRU-HxbWCqSYRydLO9H7Qj_w,23
|
|
3
3
|
chalk/cli.py,sha256=ckqqfOI-A2mT23-rnZzDMmblYj-2x1VBX8ebHlIEn9A,5873
|
|
4
4
|
chalk/importer.py,sha256=m4lMn1lSYj_euDq8CS7LYTBnek9JOcjGJf9-82dJHbA,64441
|
|
5
5
|
chalk/prompts.py,sha256=2H9UomLAamdfRTNUdKs9i3VTpiossuyRhntqsAXUhhg,16117
|
|
@@ -468,8 +468,8 @@ chalk/_gen/chalk/server/v1/monitoring_pb2.py,sha256=6N-4AAGC7dZdyNVk2MPdXrK-OdNT
|
|
|
468
468
|
chalk/_gen/chalk/server/v1/monitoring_pb2.pyi,sha256=vE8FBZYxSVYTB0TmJrAA5vnjF4WYK8ga7DRYY4HzN44,18625
|
|
469
469
|
chalk/_gen/chalk/server/v1/monitoring_pb2_grpc.py,sha256=DX6HbDO1dy8eEuxVRKlYL_ymsTQIXoW1vWPeMee0UsQ,36169
|
|
470
470
|
chalk/_gen/chalk/server/v1/monitoring_pb2_grpc.pyi,sha256=LQj-vgn0FRUMMTzQ7Nk1U5t21wwiOCLzFeG2vkAaG5I,7984
|
|
471
|
-
chalk/_gen/chalk/server/v1/named_query_pb2.py,sha256=
|
|
472
|
-
chalk/_gen/chalk/server/v1/named_query_pb2.pyi,sha256=
|
|
471
|
+
chalk/_gen/chalk/server/v1/named_query_pb2.py,sha256=LiVui-Vk4uK4eeyw14eP2RD9YLBPCDLDcV9fkOUc3rY,4663
|
|
472
|
+
chalk/_gen/chalk/server/v1/named_query_pb2.pyi,sha256=vPer7Oc9XJwxvv0wb_6sjwJ98BKMnwKzCvjB-i8UUUk,2201
|
|
473
473
|
chalk/_gen/chalk/server/v1/named_query_pb2_grpc.py,sha256=YAm4u0fgfG94MvophF22rNh3tdrSE0z441vbfhmmBCo,6927
|
|
474
474
|
chalk/_gen/chalk/server/v1/named_query_pb2_grpc.pyi,sha256=ouNIAaMdMNcebvbTvaqYbL5gNU2mPcPQhp_fsCi_tHs,1779
|
|
475
475
|
chalk/_gen/chalk/server/v1/offline_queries_pb2.py,sha256=P5b14_zMkY9pYIjCTRk4_UPJGDXLiODroQ8PvhNUD-s,16582
|
|
@@ -612,14 +612,14 @@ chalk/_validation/validation.py,sha256=9cCMfZa9-1wxkXLme_ylmD5vIA1qExJD6aqbYvbmK
|
|
|
612
612
|
chalk/byte_transmit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
613
613
|
chalk/byte_transmit/model.py,sha256=LFX8pj9X_CWXeap7fDnMl9YmXsYTgq7jBAbEWkxoYoE,13048
|
|
614
614
|
chalk/client/__init__.py,sha256=wu3WQVzE5gRj6noQQDOdYJUgDaz_9QtbjXH4KuoIlXQ,1782
|
|
615
|
-
chalk/client/client.py,sha256=
|
|
616
|
-
chalk/client/client_async.py,sha256=
|
|
615
|
+
chalk/client/client.py,sha256=DcRJltVqWy_B3Qvbnjz3qOECT9TZ7KD0eovds2CNRIw,104746
|
|
616
|
+
chalk/client/client_async.py,sha256=YmuExumlDkenlGc8ROtmPjUE2m6nQUZisUDvJmwTRdk,51546
|
|
617
617
|
chalk/client/client_async_impl.py,sha256=ZphhgTB49JBWHCGXe-dI0wWWKc9zPcOczy02q_gFy50,6925
|
|
618
|
-
chalk/client/client_grpc.py,sha256=
|
|
619
|
-
chalk/client/client_impl.py,sha256=
|
|
618
|
+
chalk/client/client_grpc.py,sha256=z1WeFWjmKKCU8dK7fdvWEOsCUlBi-v_2-HijC2_oIVs,108854
|
|
619
|
+
chalk/client/client_impl.py,sha256=0z6f9LK4t39VNazfJ9c140Szq3R1TcZlPe_uQh20wFw,216225
|
|
620
620
|
chalk/client/dataset.py,sha256=LneWwaAOHCjtj7gaJjsSeVNruj-QJ51hjRi62zrFNVE,77561
|
|
621
621
|
chalk/client/exc.py,sha256=kZJ80YbSeSRDmTLTh240j_eRdJFZBa7IaDsNSRoDroU,4145
|
|
622
|
-
chalk/client/models.py,sha256=
|
|
622
|
+
chalk/client/models.py,sha256=ApXv28A44dNXUULKFkG5L6e48vDscZyFGenaXItxL94,67598
|
|
623
623
|
chalk/client/response.py,sha256=m8sQCOj7YVv3mZSZMIC1rIMzFMQ9rfMdBRLg5NRmOOE,53257
|
|
624
624
|
chalk/client/_internal_models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
625
625
|
chalk/client/_internal_models/check.py,sha256=3Xfo4Ws4rvwjeVg0-5-kejfRfRBJeqHmnRhW-WEz784,917
|
|
@@ -650,7 +650,7 @@ chalk/features/_vector.py,sha256=jtJmUTtCaUFru4Fw17PYWozl3pPEdIOCYAuZOqIaN3Y,720
|
|
|
650
650
|
chalk/features/feature_cache_strategy.py,sha256=bXV-tjHfPzUotMpZ3h_D9Xxq-V1CLj_UcVtGIGMpMkI,4942
|
|
651
651
|
chalk/features/feature_field.py,sha256=x-B8CIt086xMOjtfpRMGcmfysS6G2vA_whsLZgGQeqI,93759
|
|
652
652
|
chalk/features/feature_set.py,sha256=yNi0_J4CylAVkVp1Y67qV6i8vHMdE0p99DnyLPABPHI,12406
|
|
653
|
-
chalk/features/feature_set_decorator.py,sha256=
|
|
653
|
+
chalk/features/feature_set_decorator.py,sha256=v3KXgTLVtYvB0_Z-8--M_pnkGhwqBFeYU0ncpvMpUV0,65824
|
|
654
654
|
chalk/features/feature_time.py,sha256=iUk8NDelig81jP7QT3tguyzx5eOZ-YC84OVgJRRKVwo,1639
|
|
655
655
|
chalk/features/feature_wrapper.py,sha256=OolNWGGX67IAEMHCObFvOCpH5EmwjbMvMygRSBJJtu0,19259
|
|
656
656
|
chalk/features/filter.py,sha256=2ldMbqvXC-nJ0jc-OZ36qHtrej-Jkx4TNQ1W_NZodAs,11177
|
|
@@ -827,8 +827,8 @@ chalk/utils/tracing.py,sha256=NiiM-9dbuJhSCv6R1npR1uYNKWlkqTR6Ygm0Voi2NrY,13078
|
|
|
827
827
|
chalk/utils/weak_set_by_identity.py,sha256=VmikA_laYwFeOphCwXJIuyOIkrdlQe0bSzaXq7onoQw,953
|
|
828
828
|
chalk/utils/pydanticutil/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
829
829
|
chalk/utils/pydanticutil/pydantic_compat.py,sha256=O575lLYJ5GvZC4HMzR9yATxf9XwjC6NrDUXbNwZidlE,3031
|
|
830
|
-
chalkpy-2.97.
|
|
831
|
-
chalkpy-2.97.
|
|
832
|
-
chalkpy-2.97.
|
|
833
|
-
chalkpy-2.97.
|
|
834
|
-
chalkpy-2.97.
|
|
830
|
+
chalkpy-2.97.3.dist-info/METADATA,sha256=TX5qrwzj0rKzbqOTGjgFCyE1qyn78OZxG0sovL-ehCQ,27754
|
|
831
|
+
chalkpy-2.97.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
832
|
+
chalkpy-2.97.3.dist-info/entry_points.txt,sha256=Vg23sd8icwq-morJrljVFr-kQnMbm95rZfZj5wsZGis,42
|
|
833
|
+
chalkpy-2.97.3.dist-info/top_level.txt,sha256=1Q6_19IGYfNxSw50W8tYKEJ2t5HKQ3W9Wiw4ia5yg2c,6
|
|
834
|
+
chalkpy-2.97.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|