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/_lazy.py
CHANGED
|
@@ -5,7 +5,7 @@ import logging
|
|
|
5
5
|
import sys
|
|
6
6
|
import threading
|
|
7
7
|
from importlib import import_module
|
|
8
|
-
from typing import TYPE_CHECKING,
|
|
8
|
+
from typing import TYPE_CHECKING, ClassVar
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from arize.config import SDKConfiguration
|
|
@@ -14,15 +14,15 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class LazySubclientsMixin:
|
|
17
|
-
_SUBCLIENTS:
|
|
18
|
-
_EXTRAS:
|
|
17
|
+
_SUBCLIENTS: ClassVar[dict[str, tuple[str, str]]] = {}
|
|
18
|
+
_EXTRAS: ClassVar[dict[str, tuple[str | None, tuple[str, ...]]]] = {}
|
|
19
19
|
|
|
20
|
-
def __init__(self, sdk_config: SDKConfiguration):
|
|
20
|
+
def __init__(self, sdk_config: SDKConfiguration) -> None:
|
|
21
21
|
self.sdk_config = sdk_config
|
|
22
|
-
self._lazy_cache:
|
|
22
|
+
self._lazy_cache: dict[str, object] = {}
|
|
23
23
|
self._lazy_lock = threading.Lock()
|
|
24
24
|
|
|
25
|
-
def __getattr__(self, name: str) ->
|
|
25
|
+
def __getattr__(self, name: str) -> object:
|
|
26
26
|
subs = self._SUBCLIENTS
|
|
27
27
|
if name not in subs:
|
|
28
28
|
raise AttributeError(
|
|
@@ -50,26 +50,31 @@ class LazySubclientsMixin:
|
|
|
50
50
|
self._lazy_cache[name] = instance
|
|
51
51
|
return instance
|
|
52
52
|
|
|
53
|
-
def __dir__(self):
|
|
53
|
+
def __dir__(self) -> list[str]:
|
|
54
54
|
return sorted({*super().__dir__(), *self._SUBCLIENTS.keys()})
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
class OptionalDependencyError(ImportError): ...
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def _can_import(module_name: str) -> bool:
|
|
61
|
+
"""Check if a module can be imported without raising an exception."""
|
|
62
|
+
try:
|
|
63
|
+
import_module(module_name)
|
|
64
|
+
except Exception:
|
|
65
|
+
return False
|
|
66
|
+
else:
|
|
67
|
+
return True
|
|
68
|
+
|
|
69
|
+
|
|
60
70
|
def require(
|
|
61
71
|
extra_key: str | None,
|
|
62
|
-
required:
|
|
63
|
-
pkgname="arize",
|
|
64
|
-
):
|
|
72
|
+
required: tuple[str, ...],
|
|
73
|
+
pkgname: str = "arize",
|
|
74
|
+
) -> None:
|
|
65
75
|
if not required:
|
|
66
76
|
return
|
|
67
|
-
missing = []
|
|
68
|
-
for p in required:
|
|
69
|
-
try:
|
|
70
|
-
import_module(p)
|
|
71
|
-
except Exception:
|
|
72
|
-
missing.append(p)
|
|
77
|
+
missing = [p for p in required if not _can_import(p)]
|
|
73
78
|
if missing:
|
|
74
79
|
raise OptionalDependencyError(
|
|
75
80
|
f"Missing optional dependencies: {', '.join(missing)}. "
|
|
@@ -77,11 +82,14 @@ def require(
|
|
|
77
82
|
)
|
|
78
83
|
|
|
79
84
|
|
|
80
|
-
def _dynamic_import(modname: str, retries: int = 2):
|
|
81
|
-
|
|
85
|
+
def _dynamic_import(modname: str, retries: int = 2) -> object:
|
|
86
|
+
def _attempt_import(remaining_attempts: int) -> object:
|
|
82
87
|
try:
|
|
83
88
|
return import_module(modname)
|
|
84
89
|
except (ModuleNotFoundError, ImportError, KeyError):
|
|
85
90
|
sys.modules.pop(modname, None)
|
|
86
|
-
if
|
|
91
|
+
if remaining_attempts <= 1:
|
|
87
92
|
raise
|
|
93
|
+
return _attempt_import(remaining_attempts - 1)
|
|
94
|
+
|
|
95
|
+
return _attempt_import(retries) if retries > 0 else None
|
arize/client.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
"""Main Arize SDK client for interacting with Arize AI platform services."""
|
|
2
|
+
|
|
1
3
|
from __future__ import annotations
|
|
2
4
|
|
|
3
5
|
import logging
|
|
4
6
|
import shutil
|
|
5
7
|
from pathlib import Path
|
|
6
|
-
from typing import TYPE_CHECKING
|
|
8
|
+
from typing import TYPE_CHECKING, ClassVar
|
|
7
9
|
|
|
8
10
|
from arize._lazy import LazySubclientsMixin
|
|
9
11
|
from arize.config import SDKConfiguration
|
|
@@ -11,56 +13,77 @@ from arize.config import SDKConfiguration
|
|
|
11
13
|
if TYPE_CHECKING:
|
|
12
14
|
from arize.datasets.client import DatasetsClient
|
|
13
15
|
from arize.experiments.client import ExperimentsClient
|
|
14
|
-
from arize.
|
|
16
|
+
from arize.ml.client import MLModelsClient
|
|
17
|
+
from arize.projects.client import ProjectsClient
|
|
18
|
+
from arize.regions import Region
|
|
15
19
|
from arize.spans.client import SpansClient
|
|
16
20
|
|
|
17
21
|
logger = logging.getLogger(__name__)
|
|
18
22
|
|
|
23
|
+
# TODO(Kiko): Clean commented lines over the SDK
|
|
24
|
+
# TODO(Kiko): Implement https://github.com/Arize-ai/arize/pull/59917
|
|
25
|
+
|
|
26
|
+
# TODO(Kiko): Go private connect. Need a `base_domain`, such that we get:
|
|
27
|
+
# - api.<base_domain>
|
|
28
|
+
# - app.<base_domain>
|
|
29
|
+
# - flight.<base_domain>
|
|
30
|
+
# - otlp.<base_domain>
|
|
31
|
+
|
|
32
|
+
# TODO(Kiko): Enforce type checking, remove all type ignores
|
|
33
|
+
|
|
34
|
+
# TODO(Kiko): Go over docstrings
|
|
35
|
+
# TODO(Kiko): Missing parameter descriptions in some docstrings
|
|
36
|
+
# TODO(Kiko): Missing return descriptions in some docstrings
|
|
37
|
+
|
|
38
|
+
# TODO(Kiko): Go over headers on each logging call
|
|
39
|
+
|
|
40
|
+
# TODO(Kiko): Need to implement 'Update existing examples in a dataset'
|
|
19
41
|
|
|
20
42
|
# TODO(Kiko): why logs don't show on scripts, only on jupyter notebooks
|
|
21
43
|
# TODO(Kiko): test caching in colab environment
|
|
22
|
-
# TODO(Kiko): models need to follow resource first pattern
|
|
23
|
-
# - models.DatasetsList200Response
|
|
24
|
-
# - models.DatasetsListExamples200Response
|
|
25
|
-
# - models.ExperimentsList200Response
|
|
26
|
-
# - models.ExperimentsRunsList200Response
|
|
27
44
|
# TODO(Kiko): Protobuf versioning is too old
|
|
28
|
-
# TODO(Kiko): It does not make any sense to require space ID in run_experiment, dataset ID should suffice
|
|
29
|
-
# TODO(Kiko): Should probably wrap every single method of gen clients so that we can add nice docstrings
|
|
30
|
-
# TODO(Kiko): Add flight max_chunksize opt to write_table. In config?
|
|
31
|
-
# TODO(Kiko): experimental/datasets must be adapted into the datasets subclient
|
|
32
|
-
# TODO(Kiko): experimental/prompt hub is missing
|
|
33
|
-
# TODO(Kiko): exporter/utils/schema_parser is missing
|
|
34
45
|
# TODO(Kiko): Go through main APIs and add CtxAdapter where missing
|
|
35
46
|
# TODO(Kiko): Search and handle other TODOs
|
|
36
47
|
# TODO(Kiko): Go over **every file** and do not import anything at runtime, use `if TYPE_CHECKING`
|
|
37
48
|
# with `from __future__ import annotations` (must include for Python < 3.11)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# TODO(Kiko): Make sure the client has same options as SDKConfiguration
|
|
49
|
+
|
|
50
|
+
|
|
41
51
|
class ArizeClient(LazySubclientsMixin):
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
"""Root client for the Arize SDK.
|
|
53
|
+
|
|
54
|
+
The ArizeClient provides access to all Arize platform services including datasets,
|
|
55
|
+
experiments, ML models, projects, and spans. It uses SDKConfiguration internally to
|
|
56
|
+
manage configuration settings.
|
|
57
|
+
|
|
58
|
+
All parameters are optional (except api_key which must be provided via argument
|
|
59
|
+
or environment variable). For each parameter, values are resolved in this order:
|
|
60
|
+
|
|
61
|
+
1. Explicit value passed to constructor (highest priority)
|
|
62
|
+
2. Environment variable value (see SDKConfiguration for variable names)
|
|
63
|
+
3. Built-in default value (lowest priority)
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
Initialize with API key only (other settings use defaults):
|
|
67
|
+
|
|
68
|
+
>>> client = ArizeClient(api_key="your-api-key")
|
|
69
|
+
|
|
70
|
+
Initialize with custom endpoints:
|
|
71
|
+
|
|
72
|
+
>>> client = ArizeClient(
|
|
73
|
+
... api_key="your-api-key",
|
|
74
|
+
... api_host="custom.api.com",
|
|
75
|
+
... flight_port=8443,
|
|
76
|
+
... )
|
|
77
|
+
|
|
78
|
+
Initialize with region (overrides host/port settings):
|
|
79
|
+
|
|
80
|
+
>>> from arize.regions import Region
|
|
81
|
+
>>> client = ArizeClient(
|
|
82
|
+
... api_key="your-api-key", region=Region.EU_WEST
|
|
83
|
+
... )
|
|
61
84
|
"""
|
|
62
85
|
|
|
63
|
-
_SUBCLIENTS = {
|
|
86
|
+
_SUBCLIENTS: ClassVar[dict[str, tuple[str, str]]] = {
|
|
64
87
|
"datasets": (
|
|
65
88
|
"arize.datasets.client",
|
|
66
89
|
"DatasetsClient",
|
|
@@ -69,16 +92,20 @@ class ArizeClient(LazySubclientsMixin):
|
|
|
69
92
|
"arize.experiments.client",
|
|
70
93
|
"ExperimentsClient",
|
|
71
94
|
),
|
|
95
|
+
"projects": (
|
|
96
|
+
"arize.projects.client",
|
|
97
|
+
"ProjectsClient",
|
|
98
|
+
),
|
|
99
|
+
"ml": (
|
|
100
|
+
"arize.ml.client",
|
|
101
|
+
"MLModelsClient",
|
|
102
|
+
),
|
|
72
103
|
"spans": (
|
|
73
104
|
"arize.spans.client",
|
|
74
105
|
"SpansClient",
|
|
75
106
|
),
|
|
76
|
-
"models": (
|
|
77
|
-
"arize.models.client",
|
|
78
|
-
"MLModelsClient",
|
|
79
|
-
),
|
|
80
107
|
}
|
|
81
|
-
_EXTRAS = {
|
|
108
|
+
_EXTRAS: ClassVar[dict[str, tuple[str | None, tuple[str, ...]]]] = {
|
|
82
109
|
# Gate only the generated-backed ones
|
|
83
110
|
"datasets": (
|
|
84
111
|
"datasets-experiments",
|
|
@@ -114,31 +141,82 @@ class ArizeClient(LazySubclientsMixin):
|
|
|
114
141
|
# Imports are gated in each method of the models client
|
|
115
142
|
# This is to allow for very lean package install if people only
|
|
116
143
|
# want to stream ML records
|
|
117
|
-
"
|
|
144
|
+
"ml": (None, ()),
|
|
118
145
|
}
|
|
119
146
|
|
|
120
147
|
def __init__(
|
|
121
148
|
self,
|
|
122
149
|
*,
|
|
123
150
|
api_key: str | None = None,
|
|
151
|
+
region: Region | None = None,
|
|
124
152
|
api_host: str | None = None,
|
|
125
153
|
api_scheme: str | None = None,
|
|
126
154
|
otlp_host: str | None = None,
|
|
127
155
|
otlp_scheme: str | None = None,
|
|
128
|
-
|
|
129
|
-
|
|
156
|
+
flight_host: str | None = None,
|
|
157
|
+
flight_port: int | None = None,
|
|
130
158
|
flight_scheme: str | None = None,
|
|
131
159
|
pyarrow_max_chunksize: int | None = None,
|
|
132
160
|
request_verify: bool | None = None,
|
|
133
161
|
stream_max_workers: int | None = None,
|
|
134
162
|
stream_max_queue_bound: int | None = None,
|
|
135
163
|
max_http_payload_size_mb: float | None = None,
|
|
136
|
-
|
|
164
|
+
arize_directory: str | None = None,
|
|
137
165
|
enable_caching: bool | None = None,
|
|
138
|
-
|
|
166
|
+
single_host: str | None = None,
|
|
167
|
+
single_port: int | None = None,
|
|
168
|
+
) -> None:
|
|
169
|
+
"""Initialize the Arize client with configuration parameters.
|
|
170
|
+
|
|
171
|
+
All parameters are optional and follow the precedence order documented in the
|
|
172
|
+
class docstring: explicit argument > environment variable > default value.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
api_key: Arize API key for authentication. Required - must be provided here
|
|
176
|
+
or via ARIZE_API_KEY environment variable. Raises MissingAPIKeyError if not set.
|
|
177
|
+
region: Arize region (e.g., Region.US_CENTRAL, Region.EU_WEST). When specified,
|
|
178
|
+
overrides individual host/port settings. ENV: ARIZE_REGION. Default: Region.UNSPECIFIED.
|
|
179
|
+
api_host: Custom API endpoint host. ENV: ARIZE_API_HOST. Default: "api.arize.com".
|
|
180
|
+
api_scheme: API endpoint scheme (http/https). ENV: ARIZE_API_SCHEME. Default: "https".
|
|
181
|
+
otlp_host: OTLP endpoint host. ENV: ARIZE_OTLP_HOST. Default: "otlp.arize.com".
|
|
182
|
+
otlp_scheme: OTLP endpoint scheme (http/https). ENV: ARIZE_OTLP_SCHEME. Default: "https".
|
|
183
|
+
flight_host: Apache Arrow Flight endpoint host. ENV: ARIZE_FLIGHT_HOST.
|
|
184
|
+
Default: "flight.arize.com".
|
|
185
|
+
flight_port: Apache Arrow Flight endpoint port (1-65535). ENV: ARIZE_FLIGHT_PORT.
|
|
186
|
+
Default: 443.
|
|
187
|
+
flight_scheme: Apache Arrow Flight endpoint scheme. ENV: ARIZE_FLIGHT_SCHEME.
|
|
188
|
+
Default: "grpc+tls".
|
|
189
|
+
pyarrow_max_chunksize: Maximum PyArrow chunk size (1 to MAX_CHUNKSIZE).
|
|
190
|
+
ENV: ARIZE_MAX_CHUNKSIZE. Default: 10_000.
|
|
191
|
+
request_verify: Whether to verify SSL certificates. ENV: ARIZE_REQUEST_VERIFY.
|
|
192
|
+
Default: True.
|
|
193
|
+
stream_max_workers: Maximum worker threads for streaming (minimum: 1).
|
|
194
|
+
ENV: ARIZE_STREAM_MAX_WORKERS. Default: 8.
|
|
195
|
+
stream_max_queue_bound: Maximum queue size for streaming (minimum: 1).
|
|
196
|
+
ENV: ARIZE_STREAM_MAX_QUEUE_BOUND. Default: 5000.
|
|
197
|
+
max_http_payload_size_mb: Maximum HTTP payload size in MB (minimum: 1).
|
|
198
|
+
ENV: ARIZE_MAX_HTTP_PAYLOAD_SIZE_MB. Default: 100.
|
|
199
|
+
arize_directory: Directory for SDK files (cache, logs, etc.).
|
|
200
|
+
ENV: ARIZE_DIRECTORY. Default: "~/.arize".
|
|
201
|
+
enable_caching: Whether to enable local caching. ENV: ARIZE_ENABLE_CACHING.
|
|
202
|
+
Default: True.
|
|
203
|
+
single_host: Single host for all endpoints (overrides individual hosts).
|
|
204
|
+
ENV: ARIZE_SINGLE_HOST. Default: None.
|
|
205
|
+
single_port: Single port for all endpoints (overrides individual ports).
|
|
206
|
+
ENV: ARIZE_SINGLE_PORT. Default: 0 (not set).
|
|
207
|
+
|
|
208
|
+
Raises:
|
|
209
|
+
MissingAPIKeyError: If api_key is not provided via argument or environment variable.
|
|
210
|
+
|
|
211
|
+
Notes:
|
|
212
|
+
Values provided to this class override environment variables, which in turn
|
|
213
|
+
override default values. See SDKConfiguration for detailed parameter documentation.
|
|
214
|
+
"""
|
|
139
215
|
cfg_kwargs: dict = {}
|
|
140
216
|
if api_key is not None:
|
|
141
217
|
cfg_kwargs["api_key"] = api_key
|
|
218
|
+
if region is not None:
|
|
219
|
+
cfg_kwargs["region"] = region
|
|
142
220
|
if api_host is not None:
|
|
143
221
|
cfg_kwargs["api_host"] = api_host
|
|
144
222
|
if api_scheme is not None:
|
|
@@ -147,10 +225,10 @@ class ArizeClient(LazySubclientsMixin):
|
|
|
147
225
|
cfg_kwargs["otlp_host"] = otlp_host
|
|
148
226
|
if otlp_scheme is not None:
|
|
149
227
|
cfg_kwargs["otlp_scheme"] = otlp_scheme
|
|
150
|
-
if
|
|
151
|
-
cfg_kwargs["
|
|
152
|
-
if
|
|
153
|
-
cfg_kwargs["
|
|
228
|
+
if flight_host is not None:
|
|
229
|
+
cfg_kwargs["flight_host"] = flight_host
|
|
230
|
+
if flight_port is not None:
|
|
231
|
+
cfg_kwargs["flight_port"] = flight_port
|
|
154
232
|
if flight_scheme is not None:
|
|
155
233
|
cfg_kwargs["flight_scheme"] = flight_scheme
|
|
156
234
|
if pyarrow_max_chunksize is not None:
|
|
@@ -163,33 +241,63 @@ class ArizeClient(LazySubclientsMixin):
|
|
|
163
241
|
cfg_kwargs["stream_max_queue_bound"] = stream_max_queue_bound
|
|
164
242
|
if max_http_payload_size_mb is not None:
|
|
165
243
|
cfg_kwargs["max_http_payload_size_mb"] = max_http_payload_size_mb
|
|
166
|
-
if
|
|
167
|
-
cfg_kwargs["
|
|
244
|
+
if arize_directory is not None:
|
|
245
|
+
cfg_kwargs["arize_directory"] = arize_directory
|
|
168
246
|
if enable_caching is not None:
|
|
169
247
|
cfg_kwargs["enable_caching"] = enable_caching
|
|
248
|
+
if single_host is not None:
|
|
249
|
+
cfg_kwargs["single_host"] = single_host
|
|
250
|
+
if single_port is not None:
|
|
251
|
+
cfg_kwargs["single_port"] = single_port
|
|
170
252
|
|
|
171
253
|
# Only the explicitly provided fields are passed; the rest use
|
|
172
|
-
# SDKConfiguration
|
|
254
|
+
# SDKConfiguration's default factories / defaults.
|
|
173
255
|
super().__init__(SDKConfiguration(**cfg_kwargs))
|
|
174
256
|
|
|
175
257
|
# typed properties for IDE completion
|
|
176
258
|
@property
|
|
177
259
|
def datasets(self) -> DatasetsClient:
|
|
260
|
+
"""Access the datasets client for dataset operations (lazy-loaded)."""
|
|
178
261
|
return self.__getattr__("datasets")
|
|
179
262
|
|
|
180
263
|
@property
|
|
181
264
|
def experiments(self) -> ExperimentsClient:
|
|
265
|
+
"""Access the experiments client for experiment operations (lazy-loaded)."""
|
|
182
266
|
return self.__getattr__("experiments")
|
|
183
267
|
|
|
184
268
|
@property
|
|
185
|
-
def
|
|
186
|
-
|
|
269
|
+
def ml(self) -> MLModelsClient:
|
|
270
|
+
"""Access the ML models client for ML model operations (lazy-loaded)."""
|
|
271
|
+
return self.__getattr__("ml")
|
|
187
272
|
|
|
188
273
|
@property
|
|
189
|
-
def
|
|
190
|
-
|
|
274
|
+
def projects(self) -> ProjectsClient:
|
|
275
|
+
"""Access the projects client for project operations (lazy-loaded)."""
|
|
276
|
+
return self.__getattr__("projects")
|
|
277
|
+
|
|
278
|
+
@property
|
|
279
|
+
def spans(self) -> SpansClient:
|
|
280
|
+
"""Access the spans client for tracing and span operations (lazy-loaded)."""
|
|
281
|
+
return self.__getattr__("spans")
|
|
191
282
|
|
|
192
283
|
def __repr__(self) -> str:
|
|
284
|
+
"""Return a string representation of the Arize client configuration."""
|
|
285
|
+
# The repr looks like:
|
|
286
|
+
# ArizeClient(
|
|
287
|
+
# sdk_config=SDKConfiguration(
|
|
288
|
+
# api_key='cacaca***',
|
|
289
|
+
# api_host='api.arize.com',
|
|
290
|
+
# ...
|
|
291
|
+
# arize_directory='~/.arize',
|
|
292
|
+
# enable_caching=True,
|
|
293
|
+
# )
|
|
294
|
+
# subclients={
|
|
295
|
+
# 'datasets': lazy,
|
|
296
|
+
# 'experiments': lazy,
|
|
297
|
+
# 'spans': lazy,
|
|
298
|
+
# 'ml': lazy,
|
|
299
|
+
# }
|
|
300
|
+
# )
|
|
193
301
|
lines = [f"{self.__class__.__name__}("]
|
|
194
302
|
# Indent the SDKConfiguration repr
|
|
195
303
|
cfg_repr = repr(self.sdk_config).splitlines()
|
|
@@ -205,7 +313,22 @@ class ArizeClient(LazySubclientsMixin):
|
|
|
205
313
|
return "\n".join(lines)
|
|
206
314
|
|
|
207
315
|
def clear_cache(self) -> None:
|
|
208
|
-
|
|
316
|
+
"""Clear the local cache directory.
|
|
317
|
+
|
|
318
|
+
Removes all cached data from the SDK's cache directory. This can be useful
|
|
319
|
+
when troubleshooting caching issues or freeing up disk space. The cache
|
|
320
|
+
directory is automatically recreated on subsequent operations that require
|
|
321
|
+
caching.
|
|
322
|
+
|
|
323
|
+
Raises:
|
|
324
|
+
NotADirectoryError: If the cache path exists but is not a directory.
|
|
325
|
+
|
|
326
|
+
Notes:
|
|
327
|
+
- This operation permanently deletes all cached data
|
|
328
|
+
- If the cache directory doesn't exist, a warning is logged but no error is raised
|
|
329
|
+
- The cache directory location is configured via sdk_config.cache_dir
|
|
330
|
+
"""
|
|
331
|
+
p = Path(self.sdk_config.cache_dir).expanduser().resolve()
|
|
209
332
|
|
|
210
333
|
if not p.exists():
|
|
211
334
|
logger.warning(
|