arize 8.0.0a22__py3-none-any.whl → 8.0.0b0__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.
- arize/__init__.py +28 -19
- arize/_exporter/client.py +56 -37
- arize/_exporter/parsers/tracing_data_parser.py +41 -30
- arize/_exporter/validation.py +3 -3
- arize/_flight/client.py +207 -76
- arize/_generated/api_client/__init__.py +30 -6
- arize/_generated/api_client/api/__init__.py +1 -0
- arize/_generated/api_client/api/datasets_api.py +864 -190
- arize/_generated/api_client/api/experiments_api.py +167 -131
- arize/_generated/api_client/api/projects_api.py +1197 -0
- arize/_generated/api_client/api_client.py +2 -2
- arize/_generated/api_client/configuration.py +42 -34
- arize/_generated/api_client/exceptions.py +2 -2
- arize/_generated/api_client/models/__init__.py +15 -4
- arize/_generated/api_client/models/dataset.py +10 -10
- arize/_generated/api_client/models/dataset_example.py +111 -0
- arize/_generated/api_client/models/dataset_example_update.py +100 -0
- arize/_generated/api_client/models/dataset_version.py +13 -13
- arize/_generated/api_client/models/datasets_create_request.py +16 -8
- arize/_generated/api_client/models/datasets_examples_insert_request.py +100 -0
- arize/_generated/api_client/models/datasets_examples_list200_response.py +106 -0
- arize/_generated/api_client/models/datasets_examples_update_request.py +102 -0
- arize/_generated/api_client/models/datasets_list200_response.py +10 -4
- arize/_generated/api_client/models/experiment.py +14 -16
- arize/_generated/api_client/models/experiment_run.py +108 -0
- arize/_generated/api_client/models/experiment_run_create.py +102 -0
- arize/_generated/api_client/models/experiments_create_request.py +16 -10
- arize/_generated/api_client/models/experiments_list200_response.py +10 -4
- arize/_generated/api_client/models/experiments_runs_list200_response.py +19 -5
- arize/_generated/api_client/models/{error.py → pagination_metadata.py} +13 -11
- arize/_generated/api_client/models/primitive_value.py +172 -0
- arize/_generated/api_client/models/problem.py +100 -0
- arize/_generated/api_client/models/project.py +99 -0
- arize/_generated/api_client/models/{datasets_list_examples200_response.py → projects_create_request.py} +13 -11
- arize/_generated/api_client/models/projects_list200_response.py +106 -0
- arize/_generated/api_client/rest.py +2 -2
- arize/_generated/api_client/test/test_dataset.py +4 -2
- arize/_generated/api_client/test/test_dataset_example.py +56 -0
- arize/_generated/api_client/test/test_dataset_example_update.py +52 -0
- arize/_generated/api_client/test/test_dataset_version.py +7 -2
- arize/_generated/api_client/test/test_datasets_api.py +27 -13
- arize/_generated/api_client/test/test_datasets_create_request.py +8 -4
- arize/_generated/api_client/test/{test_datasets_list_examples200_response.py → test_datasets_examples_insert_request.py} +19 -15
- arize/_generated/api_client/test/test_datasets_examples_list200_response.py +66 -0
- arize/_generated/api_client/test/test_datasets_examples_update_request.py +61 -0
- arize/_generated/api_client/test/test_datasets_list200_response.py +9 -3
- arize/_generated/api_client/test/test_experiment.py +2 -4
- arize/_generated/api_client/test/test_experiment_run.py +56 -0
- arize/_generated/api_client/test/test_experiment_run_create.py +54 -0
- arize/_generated/api_client/test/test_experiments_api.py +6 -6
- arize/_generated/api_client/test/test_experiments_create_request.py +9 -6
- arize/_generated/api_client/test/test_experiments_list200_response.py +9 -5
- arize/_generated/api_client/test/test_experiments_runs_list200_response.py +15 -5
- arize/_generated/api_client/test/test_pagination_metadata.py +53 -0
- arize/_generated/api_client/test/{test_error.py → test_primitive_value.py} +13 -14
- arize/_generated/api_client/test/test_problem.py +57 -0
- arize/_generated/api_client/test/test_project.py +58 -0
- arize/_generated/api_client/test/test_projects_api.py +59 -0
- arize/_generated/api_client/test/test_projects_create_request.py +54 -0
- arize/_generated/api_client/test/test_projects_list200_response.py +70 -0
- arize/_generated/api_client_README.md +43 -29
- arize/_generated/protocol/flight/flight_pb2.py +400 -0
- arize/_lazy.py +27 -19
- arize/client.py +181 -58
- arize/config.py +324 -116
- arize/constants/__init__.py +1 -0
- arize/constants/config.py +11 -4
- arize/constants/ml.py +6 -4
- arize/constants/openinference.py +2 -0
- arize/constants/pyarrow.py +2 -0
- arize/constants/spans.py +3 -1
- arize/datasets/__init__.py +1 -0
- arize/datasets/client.py +304 -84
- arize/datasets/errors.py +32 -2
- arize/datasets/validation.py +18 -8
- arize/embeddings/__init__.py +2 -0
- arize/embeddings/auto_generator.py +23 -19
- arize/embeddings/base_generators.py +89 -36
- arize/embeddings/constants.py +2 -0
- arize/embeddings/cv_generators.py +26 -4
- arize/embeddings/errors.py +27 -5
- arize/embeddings/nlp_generators.py +43 -18
- arize/embeddings/tabular_generators.py +46 -31
- arize/embeddings/usecases.py +12 -2
- arize/exceptions/__init__.py +1 -0
- arize/exceptions/auth.py +11 -1
- arize/exceptions/base.py +29 -4
- arize/exceptions/models.py +21 -2
- arize/exceptions/parameters.py +31 -0
- arize/exceptions/spaces.py +12 -1
- arize/exceptions/types.py +86 -7
- arize/exceptions/values.py +220 -20
- arize/experiments/__init__.py +13 -0
- arize/experiments/client.py +394 -285
- arize/experiments/evaluators/__init__.py +1 -0
- arize/experiments/evaluators/base.py +74 -41
- arize/experiments/evaluators/exceptions.py +6 -3
- arize/experiments/evaluators/executors.py +121 -73
- arize/experiments/evaluators/rate_limiters.py +106 -57
- arize/experiments/evaluators/types.py +34 -7
- arize/experiments/evaluators/utils.py +65 -27
- arize/experiments/functions.py +103 -101
- arize/experiments/tracing.py +52 -44
- arize/experiments/types.py +56 -31
- arize/logging.py +54 -22
- arize/ml/__init__.py +1 -0
- arize/ml/batch_validation/__init__.py +1 -0
- arize/{models → ml}/batch_validation/errors.py +545 -67
- arize/{models → ml}/batch_validation/validator.py +344 -303
- arize/ml/bounded_executor.py +47 -0
- arize/{models → ml}/casting.py +118 -108
- arize/{models → ml}/client.py +339 -118
- arize/{models → ml}/proto.py +97 -42
- arize/{models → ml}/stream_validation.py +43 -15
- arize/ml/surrogate_explainer/__init__.py +1 -0
- arize/{models → ml}/surrogate_explainer/mimic.py +25 -10
- arize/{types.py → ml/types.py} +355 -354
- arize/pre_releases.py +44 -0
- arize/projects/__init__.py +1 -0
- arize/projects/client.py +134 -0
- arize/regions.py +40 -0
- arize/spans/__init__.py +1 -0
- arize/spans/client.py +204 -175
- arize/spans/columns.py +13 -0
- arize/spans/conversion.py +60 -37
- arize/spans/validation/__init__.py +1 -0
- arize/spans/validation/annotations/__init__.py +1 -0
- arize/spans/validation/annotations/annotations_validation.py +6 -4
- arize/spans/validation/annotations/dataframe_form_validation.py +13 -11
- arize/spans/validation/annotations/value_validation.py +35 -11
- arize/spans/validation/common/__init__.py +1 -0
- arize/spans/validation/common/argument_validation.py +33 -8
- arize/spans/validation/common/dataframe_form_validation.py +35 -9
- arize/spans/validation/common/errors.py +211 -11
- arize/spans/validation/common/value_validation.py +81 -14
- arize/spans/validation/evals/__init__.py +1 -0
- arize/spans/validation/evals/dataframe_form_validation.py +28 -8
- arize/spans/validation/evals/evals_validation.py +34 -4
- arize/spans/validation/evals/value_validation.py +26 -3
- arize/spans/validation/metadata/__init__.py +1 -1
- arize/spans/validation/metadata/argument_validation.py +14 -5
- arize/spans/validation/metadata/dataframe_form_validation.py +26 -10
- arize/spans/validation/metadata/value_validation.py +24 -10
- arize/spans/validation/spans/__init__.py +1 -0
- arize/spans/validation/spans/dataframe_form_validation.py +35 -14
- arize/spans/validation/spans/spans_validation.py +35 -4
- arize/spans/validation/spans/value_validation.py +78 -8
- arize/utils/__init__.py +1 -0
- arize/utils/arrow.py +31 -15
- arize/utils/cache.py +34 -6
- arize/utils/dataframe.py +20 -3
- arize/utils/online_tasks/__init__.py +2 -0
- arize/utils/online_tasks/dataframe_preprocessor.py +58 -47
- arize/utils/openinference_conversion.py +44 -5
- arize/utils/proto.py +10 -0
- arize/utils/size.py +5 -3
- arize/utils/types.py +105 -0
- arize/version.py +3 -1
- {arize-8.0.0a22.dist-info → arize-8.0.0b0.dist-info}/METADATA +13 -6
- arize-8.0.0b0.dist-info/RECORD +175 -0
- {arize-8.0.0a22.dist-info → arize-8.0.0b0.dist-info}/WHEEL +1 -1
- arize-8.0.0b0.dist-info/licenses/LICENSE +176 -0
- arize-8.0.0b0.dist-info/licenses/NOTICE +13 -0
- arize/_generated/protocol/flight/export_pb2.py +0 -61
- arize/_generated/protocol/flight/ingest_pb2.py +0 -365
- arize/models/__init__.py +0 -0
- arize/models/batch_validation/__init__.py +0 -0
- arize/models/bounded_executor.py +0 -34
- arize/models/surrogate_explainer/__init__.py +0 -0
- arize-8.0.0a22.dist-info/RECORD +0 -146
- arize-8.0.0a22.dist-info/licenses/LICENSE.md +0 -12
arize/_flight/client.py
CHANGED
|
@@ -5,37 +5,34 @@ import base64
|
|
|
5
5
|
import logging
|
|
6
6
|
from dataclasses import dataclass, field
|
|
7
7
|
from enum import Enum
|
|
8
|
-
from typing import TYPE_CHECKING
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
9
|
|
|
10
10
|
from google.protobuf import json_format
|
|
11
11
|
from pyarrow import flight
|
|
12
12
|
|
|
13
13
|
from arize._flight.types import FlightRequestType
|
|
14
|
-
from arize._generated.protocol.flight import
|
|
15
|
-
from arize.
|
|
16
|
-
PostExperimentDataResponse,
|
|
17
|
-
WriteSpanAnnotationResponse,
|
|
18
|
-
WriteSpanAttributesMetadataResponse,
|
|
19
|
-
WriteSpanEvaluationResponse,
|
|
20
|
-
)
|
|
21
|
-
from arize.config import get_python_version
|
|
14
|
+
from arize._generated.protocol.flight import flight_pb2
|
|
15
|
+
from arize.config import PYTHON_VERSION
|
|
22
16
|
from arize.logging import log_a_list
|
|
23
17
|
from arize.utils.openinference_conversion import convert_json_str_to_dict
|
|
24
18
|
from arize.utils.proto import get_pb_schema_tracing
|
|
25
19
|
from arize.version import __version__
|
|
26
20
|
|
|
27
21
|
if TYPE_CHECKING:
|
|
22
|
+
import types
|
|
23
|
+
from collections.abc import Iterable
|
|
24
|
+
|
|
28
25
|
import pandas as pd
|
|
29
26
|
import pyarrow as pa
|
|
30
27
|
|
|
31
28
|
|
|
32
|
-
BytesPair =
|
|
33
|
-
Headers =
|
|
29
|
+
BytesPair = tuple[bytes, bytes]
|
|
30
|
+
Headers = list[BytesPair]
|
|
34
31
|
FlightPostArrowFileResponse = (
|
|
35
|
-
WriteSpanEvaluationResponse
|
|
36
|
-
| WriteSpanAnnotationResponse
|
|
37
|
-
| WriteSpanAttributesMetadataResponse
|
|
38
|
-
| PostExperimentDataResponse
|
|
32
|
+
flight_pb2.WriteSpanEvaluationResponse
|
|
33
|
+
| flight_pb2.WriteSpanAnnotationResponse
|
|
34
|
+
| flight_pb2.WriteSpanAttributesMetadataResponse
|
|
35
|
+
| flight_pb2.PostExperimentDataResponse
|
|
39
36
|
)
|
|
40
37
|
|
|
41
38
|
logger = logging.getLogger(__name__)
|
|
@@ -51,6 +48,17 @@ class FlightActionKey(Enum):
|
|
|
51
48
|
|
|
52
49
|
@dataclass(frozen=True)
|
|
53
50
|
class ArizeFlightClient:
|
|
51
|
+
"""Low-level Apache Arrow Flight client for Arize data operations.
|
|
52
|
+
|
|
53
|
+
This client provides the underlying Flight RPC transport for uploading and
|
|
54
|
+
downloading data to/from Arize using Apache Arrow format. It's used internally
|
|
55
|
+
by public-facing clients (SpansClient, ExperimentsClient, DatasetsClient, etc.)
|
|
56
|
+
and is not intended for direct use by end users.
|
|
57
|
+
|
|
58
|
+
The client manages connections, authentication, and protocol buffer serialization
|
|
59
|
+
for Flight operations.
|
|
60
|
+
"""
|
|
61
|
+
|
|
54
62
|
api_key: str = field(repr=False)
|
|
55
63
|
host: str
|
|
56
64
|
port: int
|
|
@@ -71,7 +79,7 @@ class ArizeFlightClient:
|
|
|
71
79
|
(b"origin", b"arize-logging-client"),
|
|
72
80
|
(b"auth-token-bin", str(self.api_key).encode("utf-8")),
|
|
73
81
|
(b"sdk-language", b"python"),
|
|
74
|
-
(b"language-version",
|
|
82
|
+
(b"language-version", PYTHON_VERSION.encode("utf-8")),
|
|
75
83
|
(b"sdk-version", __version__.encode("utf-8")),
|
|
76
84
|
]
|
|
77
85
|
|
|
@@ -82,6 +90,7 @@ class ArizeFlightClient:
|
|
|
82
90
|
# ---------- Connection management ----------
|
|
83
91
|
|
|
84
92
|
def _ensure_client(self) -> flight.FlightClient:
|
|
93
|
+
"""Lazily initialize and return the underlying Flight client connection."""
|
|
85
94
|
client = object.__getattribute__(self, "_client")
|
|
86
95
|
if client is not None:
|
|
87
96
|
return client
|
|
@@ -99,6 +108,7 @@ class ArizeFlightClient:
|
|
|
99
108
|
return new_client
|
|
100
109
|
|
|
101
110
|
def close(self) -> None:
|
|
111
|
+
"""Close the Flight client connection and clean up resources."""
|
|
102
112
|
client = object.__getattribute__(self, "_client")
|
|
103
113
|
if client is not None:
|
|
104
114
|
client.close()
|
|
@@ -107,34 +117,58 @@ class ArizeFlightClient:
|
|
|
107
117
|
# ---------- Context manager ----------
|
|
108
118
|
|
|
109
119
|
def __enter__(self) -> ArizeFlightClient:
|
|
120
|
+
"""Context manager entry point. Ensures the Flight client is initialized."""
|
|
110
121
|
self._ensure_client()
|
|
111
122
|
return self
|
|
112
123
|
|
|
113
|
-
def __exit__(
|
|
124
|
+
def __exit__(
|
|
125
|
+
self,
|
|
126
|
+
exc_type: type[BaseException] | None,
|
|
127
|
+
exc_val: BaseException | None,
|
|
128
|
+
_: types.TracebackType | None,
|
|
129
|
+
) -> None:
|
|
130
|
+
"""Context manager exit point. Closes the Flight client connection."""
|
|
114
131
|
if exc_type:
|
|
115
132
|
logger.error(f"An exception occurred: {exc_val}")
|
|
116
133
|
self.close()
|
|
117
134
|
|
|
118
135
|
# ---------- methods simple passthrough wrappers ----------
|
|
119
136
|
|
|
120
|
-
def get_flight_info(self, *args:
|
|
137
|
+
def get_flight_info(self, *args: object, **kwargs: object) -> object:
|
|
138
|
+
"""Get flight information. Passthrough to underlying Flight client with auth options."""
|
|
121
139
|
client = self._ensure_client()
|
|
122
140
|
kwargs.setdefault("options", self.call_options)
|
|
123
141
|
return client.get_flight_info(*args, **kwargs)
|
|
124
142
|
|
|
125
|
-
def do_get(
|
|
143
|
+
def do_get(
|
|
144
|
+
self, *args: object, **kwargs: object
|
|
145
|
+
) -> flight.FlightStreamReader:
|
|
146
|
+
"""Retrieve data stream via Flight DoGet.
|
|
147
|
+
|
|
148
|
+
Passthrough to underlying Flight client with auth options.
|
|
149
|
+
"""
|
|
126
150
|
client = self._ensure_client()
|
|
127
151
|
kwargs.setdefault("options", self.call_options)
|
|
128
152
|
return client.do_get(*args, **kwargs)
|
|
129
153
|
|
|
130
154
|
def do_put(
|
|
131
|
-
self, *args:
|
|
155
|
+
self, *args: object, **kwargs: object
|
|
132
156
|
) -> [flight.FlightStreamWriter, flight.FlightMetadataReader]:
|
|
157
|
+
"""Upload data stream via Flight DoPut.
|
|
158
|
+
|
|
159
|
+
Passthrough to underlying Flight client with auth options.
|
|
160
|
+
"""
|
|
133
161
|
client = self._ensure_client()
|
|
134
162
|
kwargs.setdefault("options", self.call_options)
|
|
135
163
|
return client.do_put(*args, **kwargs)
|
|
136
164
|
|
|
137
|
-
def do_action(
|
|
165
|
+
def do_action(
|
|
166
|
+
self, *args: object, **kwargs: object
|
|
167
|
+
) -> Iterable[flight.Result]:
|
|
168
|
+
"""Execute an action via Flight DoAction.
|
|
169
|
+
|
|
170
|
+
Passthrough to underlying Flight client with auth options.
|
|
171
|
+
"""
|
|
138
172
|
client = self._ensure_client()
|
|
139
173
|
kwargs.setdefault("options", self.call_options)
|
|
140
174
|
return client.do_action(*args, **kwargs)
|
|
@@ -150,6 +184,26 @@ class ArizeFlightClient:
|
|
|
150
184
|
dataset_id: str | None = None,
|
|
151
185
|
experiment_name: str | None = None,
|
|
152
186
|
) -> FlightPostArrowFileResponse:
|
|
187
|
+
"""Upload an Arrow table via Flight DoPut.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
space_id: Space ID for the request.
|
|
191
|
+
request_type: Type of Flight request (EVALUATION, ANNOTATION, METADATA, or
|
|
192
|
+
LOG_EXPERIMENT_DATA).
|
|
193
|
+
pa_table: PyArrow Table containing the data to upload.
|
|
194
|
+
project_name: Project/model name (required for tracing request types).
|
|
195
|
+
dataset_id: Dataset ID (required for experiment request types).
|
|
196
|
+
experiment_name: Experiment name (required for experiment request types).
|
|
197
|
+
|
|
198
|
+
Returns:
|
|
199
|
+
FlightPostArrowFileResponse containing the server response, including counts
|
|
200
|
+
of processed records and any errors.
|
|
201
|
+
|
|
202
|
+
Raises:
|
|
203
|
+
ValueError: If request_type is unsupported or required parameters are missing
|
|
204
|
+
for the request type.
|
|
205
|
+
RuntimeError: If the Flight request fails.
|
|
206
|
+
"""
|
|
153
207
|
pa_schema = pa_table.schema
|
|
154
208
|
if request_type in (
|
|
155
209
|
FlightRequestType.EVALUATION,
|
|
@@ -187,31 +241,29 @@ class ArizeFlightClient:
|
|
|
187
241
|
if flight_response is None:
|
|
188
242
|
return None
|
|
189
243
|
|
|
190
|
-
res = None
|
|
191
|
-
match request_type:
|
|
192
|
-
case FlightRequestType.EVALUATION:
|
|
193
|
-
res = WriteSpanEvaluationResponse()
|
|
194
|
-
res.ParseFromString(flight_response.to_pybytes())
|
|
195
|
-
case FlightRequestType.ANNOTATION:
|
|
196
|
-
res = WriteSpanAnnotationResponse()
|
|
197
|
-
res.ParseFromString(flight_response.to_pybytes())
|
|
198
|
-
case FlightRequestType.METADATA:
|
|
199
|
-
res = WriteSpanAttributesMetadataResponse()
|
|
200
|
-
res.ParseFromString(flight_response.to_pybytes())
|
|
201
|
-
case FlightRequestType.LOG_EXPERIMENT_DATA:
|
|
202
|
-
res = PostExperimentDataResponse()
|
|
203
|
-
res.ParseFromString(flight_response.to_pybytes())
|
|
204
|
-
case _:
|
|
205
|
-
raise ValueError(
|
|
206
|
-
f"Unsupported request_type: {request_type}"
|
|
207
|
-
)
|
|
208
|
-
return res
|
|
209
244
|
except Exception as e:
|
|
210
|
-
logger.exception(
|
|
245
|
+
logger.exception("Error logging arrow table to Arize")
|
|
211
246
|
raise RuntimeError(
|
|
212
247
|
f"Error logging arrow table to Arize: {e}"
|
|
213
248
|
) from e
|
|
214
249
|
|
|
250
|
+
match request_type:
|
|
251
|
+
case FlightRequestType.EVALUATION:
|
|
252
|
+
res = flight_pb2.WriteSpanEvaluationResponse()
|
|
253
|
+
res.ParseFromString(flight_response.to_pybytes())
|
|
254
|
+
case FlightRequestType.ANNOTATION:
|
|
255
|
+
res = flight_pb2.WriteSpanAnnotationResponse()
|
|
256
|
+
res.ParseFromString(flight_response.to_pybytes())
|
|
257
|
+
case FlightRequestType.METADATA:
|
|
258
|
+
res = flight_pb2.WriteSpanAttributesMetadataResponse()
|
|
259
|
+
res.ParseFromString(flight_response.to_pybytes())
|
|
260
|
+
case FlightRequestType.LOG_EXPERIMENT_DATA:
|
|
261
|
+
res = flight_pb2.PostExperimentDataResponse()
|
|
262
|
+
res.ParseFromString(flight_response.to_pybytes())
|
|
263
|
+
case _:
|
|
264
|
+
raise ValueError(f"Unsupported request_type: {request_type}")
|
|
265
|
+
return res
|
|
266
|
+
|
|
215
267
|
# ---------- dataset methods ----------
|
|
216
268
|
|
|
217
269
|
def create_dataset(
|
|
@@ -220,11 +272,24 @@ class ArizeFlightClient:
|
|
|
220
272
|
dataset_name: str,
|
|
221
273
|
pa_table: pa.Table,
|
|
222
274
|
) -> str:
|
|
223
|
-
|
|
224
|
-
|
|
275
|
+
"""Create a new dataset via Flight DoPut.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
space_id: Space ID where the dataset will be created.
|
|
279
|
+
dataset_name: Name for the new dataset.
|
|
280
|
+
pa_table: PyArrow Table containing the dataset examples.
|
|
281
|
+
|
|
282
|
+
Returns:
|
|
283
|
+
The created dataset ID as a string.
|
|
284
|
+
|
|
285
|
+
Raises:
|
|
286
|
+
RuntimeError: If the Flight request fails.
|
|
287
|
+
"""
|
|
288
|
+
doput_request = flight_pb2.DoPutRequest(
|
|
289
|
+
create_dataset=flight_pb2.CreateDatasetRequest(
|
|
225
290
|
space_id=space_id,
|
|
226
291
|
dataset_name=dataset_name,
|
|
227
|
-
dataset_type=
|
|
292
|
+
dataset_type=flight_pb2.GENERATIVE,
|
|
228
293
|
)
|
|
229
294
|
)
|
|
230
295
|
descriptor = flight.FlightDescriptor.for_command(
|
|
@@ -244,14 +309,11 @@ class ArizeFlightClient:
|
|
|
244
309
|
if flight_response is None:
|
|
245
310
|
return None
|
|
246
311
|
|
|
247
|
-
res =
|
|
248
|
-
res = flight_ing_pb2.CreateDatasetResponse()
|
|
312
|
+
res = flight_pb2.CreateDatasetResponse()
|
|
249
313
|
res.ParseFromString(flight_response.to_pybytes())
|
|
250
|
-
if res
|
|
251
|
-
return str(res.dataset_id)
|
|
252
|
-
return res
|
|
314
|
+
return str(res.dataset_id) if res else None
|
|
253
315
|
except Exception as e:
|
|
254
|
-
logger.exception(
|
|
316
|
+
logger.exception("Error logging arrow table to Arize")
|
|
255
317
|
raise RuntimeError(
|
|
256
318
|
f"Error logging arrow table to Arize: {e}"
|
|
257
319
|
) from e
|
|
@@ -262,10 +324,25 @@ class ArizeFlightClient:
|
|
|
262
324
|
dataset_id: str,
|
|
263
325
|
dataset_version_id: str | None = None,
|
|
264
326
|
) -> pd.DataFrame:
|
|
327
|
+
"""Retrieve dataset examples via Flight DoGet.
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
space_id: Space ID containing the dataset.
|
|
331
|
+
dataset_id: Dataset ID to retrieve examples from.
|
|
332
|
+
dataset_version_id: Optional specific version ID. If None, retrieves the
|
|
333
|
+
latest version.
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
A pandas DataFrame containing the dataset examples with JSON string columns
|
|
337
|
+
converted to dict objects.
|
|
338
|
+
|
|
339
|
+
Raises:
|
|
340
|
+
RuntimeError: If the Flight request fails.
|
|
341
|
+
"""
|
|
265
342
|
# TODO(Kiko): Space ID should not be needed,
|
|
266
343
|
# should work on server tech debt to remove this
|
|
267
|
-
doget_request =
|
|
268
|
-
get_dataset=
|
|
344
|
+
doget_request = flight_pb2.DoGetRequest(
|
|
345
|
+
get_dataset=flight_pb2.GetDatasetRequest(
|
|
269
346
|
space_id=space_id,
|
|
270
347
|
dataset_id=dataset_id,
|
|
271
348
|
dataset_version=dataset_version_id,
|
|
@@ -278,8 +355,7 @@ class ArizeFlightClient:
|
|
|
278
355
|
reader = self.do_get(descriptor, options=self.call_options)
|
|
279
356
|
# read all data into pandas dataframe
|
|
280
357
|
df = reader.read_all().to_pandas()
|
|
281
|
-
|
|
282
|
-
return df
|
|
358
|
+
return convert_json_str_to_dict(df)
|
|
283
359
|
except Exception as e:
|
|
284
360
|
logger.exception(f"Failed to get dataset id={dataset_id}")
|
|
285
361
|
raise RuntimeError(f"Failed to get dataset id={dataset_id}") from e
|
|
@@ -291,10 +367,23 @@ class ArizeFlightClient:
|
|
|
291
367
|
space_id: str,
|
|
292
368
|
experiment_id: str,
|
|
293
369
|
) -> pd.DataFrame:
|
|
370
|
+
"""Retrieve experiment runs via Flight DoGet.
|
|
371
|
+
|
|
372
|
+
Args:
|
|
373
|
+
space_id: Space ID containing the experiment.
|
|
374
|
+
experiment_id: Experiment ID to retrieve runs from.
|
|
375
|
+
|
|
376
|
+
Returns:
|
|
377
|
+
A pandas DataFrame containing the experiment runs with JSON string columns
|
|
378
|
+
converted to dict objects.
|
|
379
|
+
|
|
380
|
+
Raises:
|
|
381
|
+
RuntimeError: If the Flight request fails.
|
|
382
|
+
"""
|
|
294
383
|
# TODO(Kiko): Space ID should not be needed,
|
|
295
384
|
# should work on server tech debt to remove this
|
|
296
|
-
doget_request =
|
|
297
|
-
get_experiment=
|
|
385
|
+
doget_request = flight_pb2.DoGetRequest(
|
|
386
|
+
get_experiment=flight_pb2.GetExperimentRequest(
|
|
298
387
|
space_id=space_id,
|
|
299
388
|
experiment_id=experiment_id,
|
|
300
389
|
)
|
|
@@ -306,8 +395,7 @@ class ArizeFlightClient:
|
|
|
306
395
|
reader = self.do_get(descriptor, options=self.call_options)
|
|
307
396
|
# read all data into pandas dataframe
|
|
308
397
|
df = reader.read_all().to_pandas()
|
|
309
|
-
|
|
310
|
-
return df
|
|
398
|
+
return convert_json_str_to_dict(df)
|
|
311
399
|
except Exception as e:
|
|
312
400
|
logger.exception(f"Failed to get experiment id={experiment_id}")
|
|
313
401
|
raise RuntimeError(
|
|
@@ -319,9 +407,26 @@ class ArizeFlightClient:
|
|
|
319
407
|
space_id: str,
|
|
320
408
|
dataset_id: str,
|
|
321
409
|
experiment_name: str,
|
|
322
|
-
) ->
|
|
323
|
-
|
|
324
|
-
|
|
410
|
+
) -> tuple[str, str] | None:
|
|
411
|
+
"""Initialize a new experiment via Flight DoAction.
|
|
412
|
+
|
|
413
|
+
Creates database entries for a new experiment and allocates a trace model for
|
|
414
|
+
capturing experiment traces.
|
|
415
|
+
|
|
416
|
+
Args:
|
|
417
|
+
space_id: Space ID where the experiment will be created.
|
|
418
|
+
dataset_id: Dataset ID the experiment will run against.
|
|
419
|
+
experiment_name: Name for the new experiment.
|
|
420
|
+
|
|
421
|
+
Returns:
|
|
422
|
+
A tuple of (experiment_id, trace_model_name) if successful, None if the
|
|
423
|
+
action response is empty.
|
|
424
|
+
|
|
425
|
+
Raises:
|
|
426
|
+
RuntimeError: If the Flight action fails.
|
|
427
|
+
"""
|
|
428
|
+
request = flight_pb2.DoActionRequest(
|
|
429
|
+
create_experiment_db_entry=flight_pb2.CreateExperimentDBEntryRequest(
|
|
325
430
|
space_id=space_id,
|
|
326
431
|
dataset_id=dataset_id,
|
|
327
432
|
experiment_name=experiment_name,
|
|
@@ -342,7 +447,7 @@ class ArizeFlightClient:
|
|
|
342
447
|
res = next(response, None)
|
|
343
448
|
if res is None:
|
|
344
449
|
return None
|
|
345
|
-
resp_pb =
|
|
450
|
+
resp_pb = flight_pb2.CreateExperimentDBEntryResponse()
|
|
346
451
|
resp_pb.ParseFromString(res.body.to_pybytes())
|
|
347
452
|
return (
|
|
348
453
|
resp_pb.experiment_id,
|
|
@@ -351,8 +456,20 @@ class ArizeFlightClient:
|
|
|
351
456
|
|
|
352
457
|
|
|
353
458
|
def append_to_pyarrow_metadata(
|
|
354
|
-
pa_schema: pa.Schema, new_metadata:
|
|
355
|
-
):
|
|
459
|
+
pa_schema: pa.Schema, new_metadata: dict[str, object]
|
|
460
|
+
) -> object:
|
|
461
|
+
"""Append metadata to a PyArrow schema without overwriting existing metadata.
|
|
462
|
+
|
|
463
|
+
Args:
|
|
464
|
+
pa_schema: The PyArrow schema to add metadata to.
|
|
465
|
+
new_metadata: Dictionary of metadata key-value pairs to append.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
A new PyArrow schema with the combined metadata.
|
|
469
|
+
|
|
470
|
+
Raises:
|
|
471
|
+
KeyError: If any keys in new_metadata already exist in the schema's metadata.
|
|
472
|
+
"""
|
|
356
473
|
# Ensure metadata is handled correctly, even if initially None.
|
|
357
474
|
metadata = pa_schema.metadata
|
|
358
475
|
if metadata is None:
|
|
@@ -377,9 +494,23 @@ def _get_pb_flight_doput_request(
|
|
|
377
494
|
model_id: str | None = None,
|
|
378
495
|
dataset_id: str | None = None,
|
|
379
496
|
experiment_name: str | None = None,
|
|
380
|
-
) ->
|
|
381
|
-
"""
|
|
382
|
-
|
|
497
|
+
) -> flight_pb2.DoPutRequest:
|
|
498
|
+
"""Construct a Flight DoPut protocol buffer request for the given request type.
|
|
499
|
+
|
|
500
|
+
Args:
|
|
501
|
+
space_id: Space ID for the request.
|
|
502
|
+
request_type: FlightRequestType enum value.
|
|
503
|
+
model_id: Optional model/project ID (required for tracing request types).
|
|
504
|
+
dataset_id: Optional dataset ID (required for experiment request types).
|
|
505
|
+
experiment_name: Optional experiment name (required for experiment request types).
|
|
506
|
+
|
|
507
|
+
Returns:
|
|
508
|
+
A DoPutRequest protocol buffer configured for the specified request type.
|
|
509
|
+
|
|
510
|
+
Raises:
|
|
511
|
+
ValueError: If the request_type is unsupported or required parameters are
|
|
512
|
+
missing for the given request_type.
|
|
513
|
+
"""
|
|
383
514
|
common_args = {"space_id": space_id}
|
|
384
515
|
|
|
385
516
|
if model_id:
|
|
@@ -392,21 +523,21 @@ def _get_pb_flight_doput_request(
|
|
|
392
523
|
if model_id:
|
|
393
524
|
# model-based request types
|
|
394
525
|
match request_type:
|
|
395
|
-
case FlightRequestType.
|
|
396
|
-
return
|
|
397
|
-
write_span_evaluation_request=
|
|
526
|
+
case FlightRequestType.EVALUATION:
|
|
527
|
+
return flight_pb2.DoPutRequest(
|
|
528
|
+
write_span_evaluation_request=flight_pb2.WriteSpanEvaluationRequest(
|
|
398
529
|
**common_args
|
|
399
530
|
)
|
|
400
531
|
)
|
|
401
532
|
case FlightRequestType.ANNOTATION:
|
|
402
|
-
return
|
|
403
|
-
write_span_annotation_request=
|
|
533
|
+
return flight_pb2.DoPutRequest(
|
|
534
|
+
write_span_annotation_request=flight_pb2.WriteSpanAnnotationRequest(
|
|
404
535
|
**common_args
|
|
405
536
|
)
|
|
406
537
|
)
|
|
407
538
|
case FlightRequestType.METADATA:
|
|
408
|
-
return
|
|
409
|
-
write_span_attributes_metadata_request=
|
|
539
|
+
return flight_pb2.DoPutRequest(
|
|
540
|
+
write_span_attributes_metadata_request=flight_pb2.WriteSpanAttributesMetadataRequest(
|
|
410
541
|
**common_args
|
|
411
542
|
)
|
|
412
543
|
)
|
|
@@ -417,8 +548,8 @@ def _get_pb_flight_doput_request(
|
|
|
417
548
|
# dataset-based request types
|
|
418
549
|
match request_type:
|
|
419
550
|
case FlightRequestType.LOG_EXPERIMENT_DATA:
|
|
420
|
-
return
|
|
421
|
-
post_experiment_data=
|
|
551
|
+
return flight_pb2.DoPutRequest(
|
|
552
|
+
post_experiment_data=flight_pb2.PostExperimentDataRequest(
|
|
422
553
|
**common_args
|
|
423
554
|
)
|
|
424
555
|
)
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"""
|
|
6
6
|
Arize REST API
|
|
7
7
|
|
|
8
|
-
API specification for the backend data server. The API is hosted globally at https://api.arize.com/v2 or in your own environment.
|
|
8
|
+
API specification for the backend data server. The API is hosted globally at https://api.arize.com/v2 or in your own environment.
|
|
9
9
|
|
|
10
|
-
The version of the OpenAPI document: 0.0
|
|
10
|
+
The version of the OpenAPI document: 2.0.0
|
|
11
11
|
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
12
12
|
|
|
13
13
|
Do not edit the class manually.
|
|
@@ -20,6 +20,7 @@ __version__ = "1.0.0"
|
|
|
20
20
|
__all__ = [
|
|
21
21
|
"DatasetsApi",
|
|
22
22
|
"ExperimentsApi",
|
|
23
|
+
"ProjectsApi",
|
|
23
24
|
"ApiResponse",
|
|
24
25
|
"ApiClient",
|
|
25
26
|
"Configuration",
|
|
@@ -30,20 +31,32 @@ __all__ = [
|
|
|
30
31
|
"ApiAttributeError",
|
|
31
32
|
"ApiException",
|
|
32
33
|
"Dataset",
|
|
34
|
+
"DatasetExample",
|
|
35
|
+
"DatasetExampleUpdate",
|
|
33
36
|
"DatasetVersion",
|
|
34
37
|
"DatasetsCreateRequest",
|
|
38
|
+
"DatasetsExamplesInsertRequest",
|
|
39
|
+
"DatasetsExamplesList200Response",
|
|
40
|
+
"DatasetsExamplesUpdateRequest",
|
|
35
41
|
"DatasetsList200Response",
|
|
36
|
-
"DatasetsListExamples200Response",
|
|
37
|
-
"Error",
|
|
38
42
|
"Experiment",
|
|
43
|
+
"ExperimentRun",
|
|
44
|
+
"ExperimentRunCreate",
|
|
39
45
|
"ExperimentsCreateRequest",
|
|
40
46
|
"ExperimentsList200Response",
|
|
41
47
|
"ExperimentsRunsList200Response",
|
|
48
|
+
"PaginationMetadata",
|
|
49
|
+
"PrimitiveValue",
|
|
50
|
+
"Problem",
|
|
51
|
+
"Project",
|
|
52
|
+
"ProjectsCreateRequest",
|
|
53
|
+
"ProjectsList200Response",
|
|
42
54
|
]
|
|
43
55
|
|
|
44
56
|
# import apis into sdk package
|
|
45
57
|
from arize._generated.api_client.api.datasets_api import DatasetsApi as DatasetsApi
|
|
46
58
|
from arize._generated.api_client.api.experiments_api import ExperimentsApi as ExperimentsApi
|
|
59
|
+
from arize._generated.api_client.api.projects_api import ProjectsApi as ProjectsApi
|
|
47
60
|
|
|
48
61
|
# import ApiClient
|
|
49
62
|
from arize._generated.api_client.api_response import ApiResponse as ApiResponse
|
|
@@ -58,13 +71,24 @@ from arize._generated.api_client.exceptions import ApiException as ApiException
|
|
|
58
71
|
|
|
59
72
|
# import models into sdk package
|
|
60
73
|
from arize._generated.api_client.models.dataset import Dataset as Dataset
|
|
74
|
+
from arize._generated.api_client.models.dataset_example import DatasetExample as DatasetExample
|
|
75
|
+
from arize._generated.api_client.models.dataset_example_update import DatasetExampleUpdate as DatasetExampleUpdate
|
|
61
76
|
from arize._generated.api_client.models.dataset_version import DatasetVersion as DatasetVersion
|
|
62
77
|
from arize._generated.api_client.models.datasets_create_request import DatasetsCreateRequest as DatasetsCreateRequest
|
|
78
|
+
from arize._generated.api_client.models.datasets_examples_insert_request import DatasetsExamplesInsertRequest as DatasetsExamplesInsertRequest
|
|
79
|
+
from arize._generated.api_client.models.datasets_examples_list200_response import DatasetsExamplesList200Response as DatasetsExamplesList200Response
|
|
80
|
+
from arize._generated.api_client.models.datasets_examples_update_request import DatasetsExamplesUpdateRequest as DatasetsExamplesUpdateRequest
|
|
63
81
|
from arize._generated.api_client.models.datasets_list200_response import DatasetsList200Response as DatasetsList200Response
|
|
64
|
-
from arize._generated.api_client.models.datasets_list_examples200_response import DatasetsListExamples200Response as DatasetsListExamples200Response
|
|
65
|
-
from arize._generated.api_client.models.error import Error as Error
|
|
66
82
|
from arize._generated.api_client.models.experiment import Experiment as Experiment
|
|
83
|
+
from arize._generated.api_client.models.experiment_run import ExperimentRun as ExperimentRun
|
|
84
|
+
from arize._generated.api_client.models.experiment_run_create import ExperimentRunCreate as ExperimentRunCreate
|
|
67
85
|
from arize._generated.api_client.models.experiments_create_request import ExperimentsCreateRequest as ExperimentsCreateRequest
|
|
68
86
|
from arize._generated.api_client.models.experiments_list200_response import ExperimentsList200Response as ExperimentsList200Response
|
|
69
87
|
from arize._generated.api_client.models.experiments_runs_list200_response import ExperimentsRunsList200Response as ExperimentsRunsList200Response
|
|
88
|
+
from arize._generated.api_client.models.pagination_metadata import PaginationMetadata as PaginationMetadata
|
|
89
|
+
from arize._generated.api_client.models.primitive_value import PrimitiveValue as PrimitiveValue
|
|
90
|
+
from arize._generated.api_client.models.problem import Problem as Problem
|
|
91
|
+
from arize._generated.api_client.models.project import Project as Project
|
|
92
|
+
from arize._generated.api_client.models.projects_create_request import ProjectsCreateRequest as ProjectsCreateRequest
|
|
93
|
+
from arize._generated.api_client.models.projects_list200_response import ProjectsList200Response as ProjectsList200Response
|
|
70
94
|
|