arize 8.0.0a21__py3-none-any.whl → 8.0.0a23__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.
Files changed (166) hide show
  1. arize/__init__.py +17 -9
  2. arize/_exporter/client.py +55 -36
  3. arize/_exporter/parsers/tracing_data_parser.py +41 -30
  4. arize/_exporter/validation.py +3 -3
  5. arize/_flight/client.py +208 -77
  6. arize/_generated/api_client/__init__.py +30 -6
  7. arize/_generated/api_client/api/__init__.py +1 -0
  8. arize/_generated/api_client/api/datasets_api.py +864 -190
  9. arize/_generated/api_client/api/experiments_api.py +167 -131
  10. arize/_generated/api_client/api/projects_api.py +1197 -0
  11. arize/_generated/api_client/api_client.py +2 -2
  12. arize/_generated/api_client/configuration.py +42 -34
  13. arize/_generated/api_client/exceptions.py +2 -2
  14. arize/_generated/api_client/models/__init__.py +15 -4
  15. arize/_generated/api_client/models/dataset.py +10 -10
  16. arize/_generated/api_client/models/dataset_example.py +111 -0
  17. arize/_generated/api_client/models/dataset_example_update.py +100 -0
  18. arize/_generated/api_client/models/dataset_version.py +13 -13
  19. arize/_generated/api_client/models/datasets_create_request.py +16 -8
  20. arize/_generated/api_client/models/datasets_examples_insert_request.py +100 -0
  21. arize/_generated/api_client/models/datasets_examples_list200_response.py +106 -0
  22. arize/_generated/api_client/models/datasets_examples_update_request.py +102 -0
  23. arize/_generated/api_client/models/datasets_list200_response.py +10 -4
  24. arize/_generated/api_client/models/experiment.py +14 -16
  25. arize/_generated/api_client/models/experiment_run.py +108 -0
  26. arize/_generated/api_client/models/experiment_run_create.py +102 -0
  27. arize/_generated/api_client/models/experiments_create_request.py +16 -10
  28. arize/_generated/api_client/models/experiments_list200_response.py +10 -4
  29. arize/_generated/api_client/models/experiments_runs_list200_response.py +19 -5
  30. arize/_generated/api_client/models/{error.py → pagination_metadata.py} +13 -11
  31. arize/_generated/api_client/models/primitive_value.py +172 -0
  32. arize/_generated/api_client/models/problem.py +100 -0
  33. arize/_generated/api_client/models/project.py +99 -0
  34. arize/_generated/api_client/models/{datasets_list_examples200_response.py → projects_create_request.py} +13 -11
  35. arize/_generated/api_client/models/projects_list200_response.py +106 -0
  36. arize/_generated/api_client/rest.py +2 -2
  37. arize/_generated/api_client/test/test_dataset.py +4 -2
  38. arize/_generated/api_client/test/test_dataset_example.py +56 -0
  39. arize/_generated/api_client/test/test_dataset_example_update.py +52 -0
  40. arize/_generated/api_client/test/test_dataset_version.py +7 -2
  41. arize/_generated/api_client/test/test_datasets_api.py +27 -13
  42. arize/_generated/api_client/test/test_datasets_create_request.py +8 -4
  43. arize/_generated/api_client/test/{test_datasets_list_examples200_response.py → test_datasets_examples_insert_request.py} +19 -15
  44. arize/_generated/api_client/test/test_datasets_examples_list200_response.py +66 -0
  45. arize/_generated/api_client/test/test_datasets_examples_update_request.py +61 -0
  46. arize/_generated/api_client/test/test_datasets_list200_response.py +9 -3
  47. arize/_generated/api_client/test/test_experiment.py +2 -4
  48. arize/_generated/api_client/test/test_experiment_run.py +56 -0
  49. arize/_generated/api_client/test/test_experiment_run_create.py +54 -0
  50. arize/_generated/api_client/test/test_experiments_api.py +6 -6
  51. arize/_generated/api_client/test/test_experiments_create_request.py +9 -6
  52. arize/_generated/api_client/test/test_experiments_list200_response.py +9 -5
  53. arize/_generated/api_client/test/test_experiments_runs_list200_response.py +15 -5
  54. arize/_generated/api_client/test/test_pagination_metadata.py +53 -0
  55. arize/_generated/api_client/test/{test_error.py → test_primitive_value.py} +13 -14
  56. arize/_generated/api_client/test/test_problem.py +57 -0
  57. arize/_generated/api_client/test/test_project.py +58 -0
  58. arize/_generated/api_client/test/test_projects_api.py +59 -0
  59. arize/_generated/api_client/test/test_projects_create_request.py +54 -0
  60. arize/_generated/api_client/test/test_projects_list200_response.py +70 -0
  61. arize/_generated/api_client_README.md +43 -29
  62. arize/_generated/protocol/flight/flight_pb2.py +400 -0
  63. arize/_lazy.py +27 -19
  64. arize/client.py +269 -55
  65. arize/config.py +365 -116
  66. arize/constants/__init__.py +1 -0
  67. arize/constants/config.py +11 -4
  68. arize/constants/ml.py +6 -4
  69. arize/constants/openinference.py +2 -0
  70. arize/constants/pyarrow.py +2 -0
  71. arize/constants/spans.py +3 -1
  72. arize/datasets/__init__.py +1 -0
  73. arize/datasets/client.py +299 -84
  74. arize/datasets/errors.py +32 -2
  75. arize/datasets/validation.py +18 -8
  76. arize/embeddings/__init__.py +2 -0
  77. arize/embeddings/auto_generator.py +23 -19
  78. arize/embeddings/base_generators.py +89 -36
  79. arize/embeddings/constants.py +2 -0
  80. arize/embeddings/cv_generators.py +26 -4
  81. arize/embeddings/errors.py +27 -5
  82. arize/embeddings/nlp_generators.py +31 -12
  83. arize/embeddings/tabular_generators.py +32 -20
  84. arize/embeddings/usecases.py +12 -2
  85. arize/exceptions/__init__.py +1 -0
  86. arize/exceptions/auth.py +11 -1
  87. arize/exceptions/base.py +29 -4
  88. arize/exceptions/models.py +21 -2
  89. arize/exceptions/parameters.py +31 -0
  90. arize/exceptions/spaces.py +12 -1
  91. arize/exceptions/types.py +86 -7
  92. arize/exceptions/values.py +220 -20
  93. arize/experiments/__init__.py +1 -0
  94. arize/experiments/client.py +390 -286
  95. arize/experiments/evaluators/__init__.py +1 -0
  96. arize/experiments/evaluators/base.py +74 -41
  97. arize/experiments/evaluators/exceptions.py +6 -3
  98. arize/experiments/evaluators/executors.py +121 -73
  99. arize/experiments/evaluators/rate_limiters.py +106 -57
  100. arize/experiments/evaluators/types.py +34 -7
  101. arize/experiments/evaluators/utils.py +65 -27
  102. arize/experiments/functions.py +103 -101
  103. arize/experiments/tracing.py +52 -44
  104. arize/experiments/types.py +56 -31
  105. arize/logging.py +54 -22
  106. arize/models/__init__.py +1 -0
  107. arize/models/batch_validation/__init__.py +1 -0
  108. arize/models/batch_validation/errors.py +543 -65
  109. arize/models/batch_validation/validator.py +339 -300
  110. arize/models/bounded_executor.py +20 -7
  111. arize/models/casting.py +75 -29
  112. arize/models/client.py +326 -107
  113. arize/models/proto.py +95 -40
  114. arize/models/stream_validation.py +42 -14
  115. arize/models/surrogate_explainer/__init__.py +1 -0
  116. arize/models/surrogate_explainer/mimic.py +24 -13
  117. arize/pre_releases.py +43 -0
  118. arize/projects/__init__.py +1 -0
  119. arize/projects/client.py +129 -0
  120. arize/regions.py +40 -0
  121. arize/spans/__init__.py +1 -0
  122. arize/spans/client.py +130 -106
  123. arize/spans/columns.py +13 -0
  124. arize/spans/conversion.py +54 -38
  125. arize/spans/validation/__init__.py +1 -0
  126. arize/spans/validation/annotations/__init__.py +1 -0
  127. arize/spans/validation/annotations/annotations_validation.py +6 -4
  128. arize/spans/validation/annotations/dataframe_form_validation.py +13 -11
  129. arize/spans/validation/annotations/value_validation.py +35 -11
  130. arize/spans/validation/common/__init__.py +1 -0
  131. arize/spans/validation/common/argument_validation.py +33 -8
  132. arize/spans/validation/common/dataframe_form_validation.py +35 -9
  133. arize/spans/validation/common/errors.py +211 -11
  134. arize/spans/validation/common/value_validation.py +80 -13
  135. arize/spans/validation/evals/__init__.py +1 -0
  136. arize/spans/validation/evals/dataframe_form_validation.py +28 -8
  137. arize/spans/validation/evals/evals_validation.py +34 -4
  138. arize/spans/validation/evals/value_validation.py +26 -3
  139. arize/spans/validation/metadata/__init__.py +1 -1
  140. arize/spans/validation/metadata/argument_validation.py +14 -5
  141. arize/spans/validation/metadata/dataframe_form_validation.py +26 -10
  142. arize/spans/validation/metadata/value_validation.py +24 -10
  143. arize/spans/validation/spans/__init__.py +1 -0
  144. arize/spans/validation/spans/dataframe_form_validation.py +34 -13
  145. arize/spans/validation/spans/spans_validation.py +35 -4
  146. arize/spans/validation/spans/value_validation.py +76 -7
  147. arize/types.py +293 -157
  148. arize/utils/__init__.py +1 -0
  149. arize/utils/arrow.py +31 -15
  150. arize/utils/cache.py +34 -6
  151. arize/utils/dataframe.py +19 -2
  152. arize/utils/online_tasks/__init__.py +2 -0
  153. arize/utils/online_tasks/dataframe_preprocessor.py +53 -41
  154. arize/utils/openinference_conversion.py +44 -5
  155. arize/utils/proto.py +10 -0
  156. arize/utils/size.py +5 -3
  157. arize/version.py +3 -1
  158. {arize-8.0.0a21.dist-info → arize-8.0.0a23.dist-info}/METADATA +4 -3
  159. arize-8.0.0a23.dist-info/RECORD +174 -0
  160. {arize-8.0.0a21.dist-info → arize-8.0.0a23.dist-info}/WHEEL +1 -1
  161. arize-8.0.0a23.dist-info/licenses/LICENSE +176 -0
  162. arize-8.0.0a23.dist-info/licenses/NOTICE +13 -0
  163. arize/_generated/protocol/flight/export_pb2.py +0 -61
  164. arize/_generated/protocol/flight/ingest_pb2.py +0 -365
  165. arize-8.0.0a21.dist-info/RECORD +0 -146
  166. arize-8.0.0a21.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, Any, Dict, Tuple
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: Dict[str, Tuple[str, str]] = {}
18
- _EXTRAS: Dict[str, Tuple[str | None, Tuple[str, ...]]] = {}
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: Dict[str, Any] = {}
22
+ self._lazy_cache: dict[str, object] = {}
23
23
  self._lazy_lock = threading.Lock()
24
24
 
25
- def __getattr__(self, name: str) -> Any:
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: Tuple[str, ...],
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
- for i in range(retries):
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 i + 1 == retries:
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
@@ -12,54 +14,166 @@ if TYPE_CHECKING:
12
14
  from arize.datasets.client import DatasetsClient
13
15
  from arize.experiments.client import ExperimentsClient
14
16
  from arize.models.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
 
19
23
 
24
+ # TODO(Kiko): Enforce type checking, remove all type ignores
25
+
26
+ # TODO(Kiko): Go over docstrings
27
+ # TODO(Kiko): Missing parameter descriptions in some docstrings
28
+ # TODO(Kiko): Missing return descriptions in some docstrings
29
+
30
+ # TODO(Kiko): Go over headers on each logging call
31
+
32
+ # TODO(Kiko): Need to implement 'Update existing examples in a dataset'
33
+
34
+ # TODO(Kiko): why logs don't show on scripts, only on jupyter notebooks
20
35
  # TODO(Kiko): test caching in colab environment
21
- # TODO(Kiko): models need to follow resource first pattern
22
- # - models.DatasetsList200Response
23
- # - models.DatasetsListExamples200Response
24
- # - models.ExperimentsList200Response
25
- # - models.ExperimentsRunsList200Response
26
36
  # TODO(Kiko): Protobuf versioning is too old
27
- # TODO(Kiko): It does not make any sense to require space ID in run_experiment, dataset ID should suffice
28
- # TODO(Kiko): Should probably wrap every single method of gen clients so that we can add nice docstrings
29
- # TODO(Kiko): Add flight max_chunksize opt to write_table. In config?
30
- # TODO(Kiko): experimental/datasets must be adapted into the datasets subclient
31
- # TODO(Kiko): experimental/prompt hub is missing
32
- # TODO(Kiko): exporter/utils/schema_parser is missing
33
37
  # TODO(Kiko): Go through main APIs and add CtxAdapter where missing
34
38
  # TODO(Kiko): Search and handle other TODOs
35
39
  # TODO(Kiko): Go over **every file** and do not import anything at runtime, use `if TYPE_CHECKING`
36
40
  # with `from __future__ import annotations` (must include for Python < 3.11)
37
- # TODO(Kiko): Go over docstrings
38
- # TODO(Kiko): Go headers on each logging call
39
- # TODO(Kiko): Make sure the client has same options as SDKConfiguration
41
+
42
+
40
43
  class ArizeClient(LazySubclientsMixin):
41
- """
42
- Root client for the Arize SDK. All parameters are optional. If not provided, they will be read
43
- from environment variables. If those are absent, built-in defaults will be used with the only
44
- exception of `api_key`, which is required to be provided either via argument or environment
45
- variable (ARIZE_API_KEY).
46
-
47
- Parameters (all optional):
48
- api_key: If not provided, read from environment (ARIZE_API_KEY). If absent, raises.
49
- api_host: If not provided, read from environment (ARIZE_API_HOST) or default.
50
- api_scheme: If not provided, read from environment (ARIZE_API_INSECURE -> http/https) or default.
51
- flight_server_host: If not provided, read from environment (ARIZE_FLIGHT_HOST) or default.
52
- flight_server_port: If not provided, read from environment (ARIZE_FLIGHT_PORT) or default.
53
- flight_scheme: If not provided, read from environment (ARIZE_FLIGHT_TRANSPORT_SCHEME) or default.
54
- request_verify: If not provided, read from environment (ARIZE_REQUEST_VERIFY) or defaults to True.
55
-
56
- Resolution order for each field:
57
- 1) Value passed here (if not None)
58
- 2) Environment variable (handled by SDKConfiguration class)
59
- 3) Built-in default constant (handled by SDKConfiguration class)
44
+ """Root client for the Arize SDK.
45
+
46
+ The ArizeClient provides access to all Arize platform services including datasets,
47
+ experiments, models, projects, and spans. It uses SDKConfiguration internally to
48
+ manage configuration settings.
49
+
50
+ Configuration Precedence
51
+ ------------------------
52
+ All parameters are optional (except api_key which must be provided via argument
53
+ or environment variable). For each parameter, values are resolved in this order:
54
+ 1. Explicit value passed to constructor (highest priority)
55
+ 2. Environment variable value (see SDKConfiguration for variable names)
56
+ 3. Built-in default value (lowest priority)
57
+
58
+ Parameters
59
+ ----------
60
+ api_key : str
61
+ Arize API key for authentication. Required - must be provided via this parameter
62
+ or the ARIZE_API_KEY environment variable.
63
+ Environment variable: ARIZE_API_KEY
64
+ Default: None (raises MissingAPIKeyError if not provided)
65
+
66
+ region : Region, optional
67
+ Arize region (e.g., Region.US_CENTRAL, Region.EU_WEST). When specified,
68
+ overrides individual host/port settings with region-specific endpoints.
69
+ Environment variable: ARIZE_REGION
70
+ Default: Region.UNSPECIFIED
71
+
72
+ api_host : str, optional
73
+ Custom API endpoint host override.
74
+ Environment variable: ARIZE_API_HOST
75
+ Default: "api.arize.com"
76
+
77
+ api_scheme : str, optional
78
+ API endpoint scheme (http/https).
79
+ Environment variable: ARIZE_API_SCHEME
80
+ Default: "https"
81
+
82
+ otlp_host : str, optional
83
+ OTLP (OpenTelemetry Protocol) endpoint host override.
84
+ Environment variable: ARIZE_OTLP_HOST
85
+ Default: "otlp.arize.com"
86
+
87
+ otlp_scheme : str, optional
88
+ OTLP endpoint scheme (http/https).
89
+ Environment variable: ARIZE_OTLP_SCHEME
90
+ Default: "https"
91
+
92
+ flight_host : str, optional
93
+ Apache Arrow Flight endpoint host override.
94
+ Environment variable: ARIZE_FLIGHT_HOST
95
+ Default: "flight.arize.com"
96
+
97
+ flight_port : int, optional
98
+ Apache Arrow Flight endpoint port (1-65535).
99
+ Environment variable: ARIZE_FLIGHT_PORT
100
+ Default: 443
101
+
102
+ flight_scheme : str, optional
103
+ Apache Arrow Flight endpoint scheme.
104
+ Environment variable: ARIZE_FLIGHT_SCHEME
105
+ Default: "grpc+tls"
106
+
107
+ pyarrow_max_chunksize : int, optional
108
+ Maximum chunk size for PyArrow operations (1 to MAX_CHUNKSIZE).
109
+ Environment variable: ARIZE_MAX_CHUNKSIZE
110
+ Default: 10_000
111
+
112
+ request_verify : bool, optional
113
+ Whether to verify SSL certificates for HTTP requests.
114
+ Environment variable: ARIZE_REQUEST_VERIFY
115
+ Default: True
116
+
117
+ stream_max_workers : int, optional
118
+ Maximum number of worker threads for streaming operations (minimum: 1).
119
+ Environment variable: ARIZE_STREAM_MAX_WORKERS
120
+ Default: 8
121
+
122
+ stream_max_queue_bound : int, optional
123
+ Maximum queue size for streaming operations (minimum: 1).
124
+ Environment variable: ARIZE_STREAM_MAX_QUEUE_BOUND
125
+ Default: 5000
126
+
127
+ max_http_payload_size_mb : float, optional
128
+ Maximum HTTP payload size in megabytes (minimum: 1).
129
+ Environment variable: ARIZE_MAX_HTTP_PAYLOAD_SIZE_MB
130
+ Default: 100
131
+
132
+ arize_directory : str, optional
133
+ Directory for Arize SDK files (cache, logs, etc.).
134
+ Environment variable: ARIZE_DIRECTORY
135
+ Default: "~/.arize"
136
+
137
+ enable_caching : bool, optional
138
+ Whether to enable local caching.
139
+ Environment variable: ARIZE_ENABLE_CACHING
140
+ Default: True
141
+
142
+ single_host : str, optional
143
+ Single host to use for all endpoints. Overrides individual host settings.
144
+ Environment variable: ARIZE_SINGLE_HOST
145
+ Default: None (not set)
146
+
147
+ single_port : int, optional
148
+ Single port to use for all endpoints. Overrides individual port settings (0-65535).
149
+ Environment variable: ARIZE_SINGLE_PORT
150
+ Default: 0 (not set)
151
+
152
+ Examples:
153
+ --------
154
+ Initialize with API key only (other settings use defaults):
155
+
156
+ >>> client = ArizeClient(api_key="your-api-key")
157
+
158
+ Initialize with custom endpoints:
159
+
160
+ >>> client = ArizeClient(
161
+ ... api_key="your-api-key",
162
+ ... api_host="custom.api.com",
163
+ ... flight_port=8443,
164
+ ... )
165
+
166
+ Initialize with region (overrides host/port settings):
167
+
168
+ >>> from arize.regions import Region
169
+ >>> client = ArizeClient(api_key="your-api-key", region=Region.EU_WEST)
170
+
171
+ See Also:
172
+ --------
173
+ SDKConfiguration : Internal configuration class with detailed parameter documentation
60
174
  """
61
175
 
62
- _SUBCLIENTS = {
176
+ _SUBCLIENTS: ClassVar[dict[str, tuple[str, str]]] = {
63
177
  "datasets": (
64
178
  "arize.datasets.client",
65
179
  "DatasetsClient",
@@ -68,16 +182,20 @@ class ArizeClient(LazySubclientsMixin):
68
182
  "arize.experiments.client",
69
183
  "ExperimentsClient",
70
184
  ),
71
- "spans": (
72
- "arize.spans.client",
73
- "SpansClient",
185
+ "projects": (
186
+ "arize.projects.client",
187
+ "ProjectsClient",
74
188
  ),
75
189
  "models": (
76
190
  "arize.models.client",
77
191
  "MLModelsClient",
78
192
  ),
193
+ "spans": (
194
+ "arize.spans.client",
195
+ "SpansClient",
196
+ ),
79
197
  }
80
- _EXTRAS = {
198
+ _EXTRAS: ClassVar[dict[str, tuple[str | None, tuple[str, ...]]]] = {
81
199
  # Gate only the generated-backed ones
82
200
  "datasets": (
83
201
  "datasets-experiments",
@@ -120,24 +238,75 @@ class ArizeClient(LazySubclientsMixin):
120
238
  self,
121
239
  *,
122
240
  api_key: str | None = None,
241
+ region: Region | None = None,
123
242
  api_host: str | None = None,
124
243
  api_scheme: str | None = None,
125
244
  otlp_host: str | None = None,
126
245
  otlp_scheme: str | None = None,
127
- flight_server_host: str | None = None,
128
- flight_server_port: int | None = None,
246
+ flight_host: str | None = None,
247
+ flight_port: int | None = None,
129
248
  flight_scheme: str | None = None,
130
249
  pyarrow_max_chunksize: int | None = None,
131
250
  request_verify: bool | None = None,
132
251
  stream_max_workers: int | None = None,
133
252
  stream_max_queue_bound: int | None = None,
134
253
  max_http_payload_size_mb: float | None = None,
135
- arize_direcory: str | None = None,
254
+ arize_directory: str | None = None,
136
255
  enable_caching: bool | None = None,
137
- ):
256
+ single_host: str | None = None,
257
+ single_port: int | None = None,
258
+ ) -> None:
259
+ """Initialize the Arize client with configuration parameters.
260
+
261
+ All parameters are optional and follow the precedence order documented in the
262
+ class docstring: explicit argument > environment variable > default value.
263
+
264
+ Args:
265
+ api_key: Arize API key for authentication. Required - must be provided here
266
+ or via ARIZE_API_KEY environment variable. Raises MissingAPIKeyError if not set.
267
+ region: Arize region (e.g., Region.US_CENTRAL, Region.EU_WEST). When specified,
268
+ overrides individual host/port settings. ENV: ARIZE_REGION. Default: Region.UNSPECIFIED.
269
+ api_host: Custom API endpoint host. ENV: ARIZE_API_HOST. Default: "api.arize.com".
270
+ api_scheme: API endpoint scheme (http/https). ENV: ARIZE_API_SCHEME. Default: "https".
271
+ otlp_host: OTLP endpoint host. ENV: ARIZE_OTLP_HOST. Default: "otlp.arize.com".
272
+ otlp_scheme: OTLP endpoint scheme (http/https). ENV: ARIZE_OTLP_SCHEME. Default: "https".
273
+ flight_host: Apache Arrow Flight endpoint host. ENV: ARIZE_FLIGHT_HOST.
274
+ Default: "flight.arize.com".
275
+ flight_port: Apache Arrow Flight endpoint port (1-65535). ENV: ARIZE_FLIGHT_PORT.
276
+ Default: 443.
277
+ flight_scheme: Apache Arrow Flight endpoint scheme. ENV: ARIZE_FLIGHT_SCHEME.
278
+ Default: "grpc+tls".
279
+ pyarrow_max_chunksize: Maximum PyArrow chunk size (1 to MAX_CHUNKSIZE).
280
+ ENV: ARIZE_MAX_CHUNKSIZE. Default: 10_000.
281
+ request_verify: Whether to verify SSL certificates. ENV: ARIZE_REQUEST_VERIFY.
282
+ Default: True.
283
+ stream_max_workers: Maximum worker threads for streaming (minimum: 1).
284
+ ENV: ARIZE_STREAM_MAX_WORKERS. Default: 8.
285
+ stream_max_queue_bound: Maximum queue size for streaming (minimum: 1).
286
+ ENV: ARIZE_STREAM_MAX_QUEUE_BOUND. Default: 5000.
287
+ max_http_payload_size_mb: Maximum HTTP payload size in MB (minimum: 1).
288
+ ENV: ARIZE_MAX_HTTP_PAYLOAD_SIZE_MB. Default: 100.
289
+ arize_directory: Directory for SDK files (cache, logs, etc.).
290
+ ENV: ARIZE_DIRECTORY. Default: "~/.arize".
291
+ enable_caching: Whether to enable local caching. ENV: ARIZE_ENABLE_CACHING.
292
+ Default: True.
293
+ single_host: Single host for all endpoints (overrides individual hosts).
294
+ ENV: ARIZE_SINGLE_HOST. Default: None.
295
+ single_port: Single port for all endpoints (overrides individual ports).
296
+ ENV: ARIZE_SINGLE_PORT. Default: 0 (not set).
297
+
298
+ Raises:
299
+ MissingAPIKeyError: If api_key is not provided via argument or environment variable.
300
+
301
+ Notes:
302
+ Values provided here override environment variables, which in turn override
303
+ default values. See SDKConfiguration for detailed parameter documentation.
304
+ """
138
305
  cfg_kwargs: dict = {}
139
306
  if api_key is not None:
140
307
  cfg_kwargs["api_key"] = api_key
308
+ if region is not None:
309
+ cfg_kwargs["region"] = region
141
310
  if api_host is not None:
142
311
  cfg_kwargs["api_host"] = api_host
143
312
  if api_scheme is not None:
@@ -146,10 +315,10 @@ class ArizeClient(LazySubclientsMixin):
146
315
  cfg_kwargs["otlp_host"] = otlp_host
147
316
  if otlp_scheme is not None:
148
317
  cfg_kwargs["otlp_scheme"] = otlp_scheme
149
- if flight_server_host is not None:
150
- cfg_kwargs["flight_server_host"] = flight_server_host
151
- if flight_server_port is not None:
152
- cfg_kwargs["flight_server_port"] = flight_server_port
318
+ if flight_host is not None:
319
+ cfg_kwargs["flight_host"] = flight_host
320
+ if flight_port is not None:
321
+ cfg_kwargs["flight_port"] = flight_port
153
322
  if flight_scheme is not None:
154
323
  cfg_kwargs["flight_scheme"] = flight_scheme
155
324
  if pyarrow_max_chunksize is not None:
@@ -162,33 +331,63 @@ class ArizeClient(LazySubclientsMixin):
162
331
  cfg_kwargs["stream_max_queue_bound"] = stream_max_queue_bound
163
332
  if max_http_payload_size_mb is not None:
164
333
  cfg_kwargs["max_http_payload_size_mb"] = max_http_payload_size_mb
165
- if arize_direcory is not None:
166
- cfg_kwargs["arize_direcory"] = arize_direcory
334
+ if arize_directory is not None:
335
+ cfg_kwargs["arize_directory"] = arize_directory
167
336
  if enable_caching is not None:
168
337
  cfg_kwargs["enable_caching"] = enable_caching
338
+ if single_host is not None:
339
+ cfg_kwargs["single_host"] = single_host
340
+ if single_port is not None:
341
+ cfg_kwargs["single_port"] = single_port
169
342
 
170
343
  # Only the explicitly provided fields are passed; the rest use
171
- # SDKConfigurations default factories / defaults.
344
+ # SDKConfiguration's default factories / defaults.
172
345
  super().__init__(SDKConfiguration(**cfg_kwargs))
173
346
 
174
347
  # typed properties for IDE completion
175
348
  @property
176
349
  def datasets(self) -> DatasetsClient:
350
+ """Access the datasets client for dataset operations (lazy-loaded)."""
177
351
  return self.__getattr__("datasets")
178
352
 
179
353
  @property
180
354
  def experiments(self) -> ExperimentsClient:
355
+ """Access the experiments client for experiment operations (lazy-loaded)."""
181
356
  return self.__getattr__("experiments")
182
357
 
183
- @property
184
- def spans(self) -> SpansClient:
185
- return self.__getattr__("spans")
186
-
187
358
  @property
188
359
  def models(self) -> MLModelsClient:
360
+ """Access the models client for ML model operations (lazy-loaded)."""
189
361
  return self.__getattr__("models")
190
362
 
363
+ @property
364
+ def projects(self) -> ProjectsClient:
365
+ """Access the projects client for project operations (lazy-loaded)."""
366
+ return self.__getattr__("projects")
367
+
368
+ @property
369
+ def spans(self) -> SpansClient:
370
+ """Access the spans client for tracing and span operations (lazy-loaded)."""
371
+ return self.__getattr__("spans")
372
+
191
373
  def __repr__(self) -> str:
374
+ """Return a string representation of the Arize client configuration."""
375
+ # The repr looks like:
376
+ # ArizeClient(
377
+ # sdk_config=SDKConfiguration(
378
+ # api_key='cacaca***',
379
+ # api_host='api.arize.com',
380
+ # ...
381
+ # arize_directory='~/.arize',
382
+ # enable_caching=True,
383
+ # )
384
+ # subclients={
385
+ # 'datasets': lazy,
386
+ # 'experiments': lazy,
387
+ # 'spans': lazy,
388
+ # 'models': lazy,
389
+ # }
390
+ # )
192
391
  lines = [f"{self.__class__.__name__}("]
193
392
  # Indent the SDKConfiguration repr
194
393
  cfg_repr = repr(self.sdk_config).splitlines()
@@ -204,7 +403,22 @@ class ArizeClient(LazySubclientsMixin):
204
403
  return "\n".join(lines)
205
404
 
206
405
  def clear_cache(self) -> None:
207
- p = Path(self.sdk_config.cache_dir)
406
+ """Clear the local cache directory.
407
+
408
+ Removes all cached data from the SDK's cache directory. This can be useful
409
+ when troubleshooting caching issues or freeing up disk space. The cache
410
+ directory is automatically recreated on subsequent operations that require
411
+ caching.
412
+
413
+ Raises:
414
+ NotADirectoryError: If the cache path exists but is not a directory.
415
+
416
+ Notes:
417
+ - This operation permanently deletes all cached data
418
+ - If the cache directory doesn't exist, a warning is logged but no error is raised
419
+ - The cache directory location is configured via sdk_config.cache_dir
420
+ """
421
+ p = Path(self.sdk_config.cache_dir).expanduser().resolve()
208
422
 
209
423
  if not p.exists():
210
424
  logger.warning(