rapidata 2.39.1__py3-none-any.whl → 2.40.1__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.
Potentially problematic release.
This version of rapidata might be problematic. Click here for more details.
- rapidata/__init__.py +1 -1
- rapidata/rapidata_client/config/order_config.py +1 -0
- rapidata/rapidata_client/order/_rapidata_order_builder.py +35 -9
- rapidata/rapidata_client/rapidata_client.py +24 -3
- rapidata/rapidata_client/validation/validation_set_manager.py +4 -0
- {rapidata-2.39.1.dist-info → rapidata-2.40.1.dist-info}/METADATA +1 -1
- {rapidata-2.39.1.dist-info → rapidata-2.40.1.dist-info}/RECORD +9 -9
- {rapidata-2.39.1.dist-info → rapidata-2.40.1.dist-info}/LICENSE +0 -0
- {rapidata-2.39.1.dist-info → rapidata-2.40.1.dist-info}/WHEEL +0 -0
rapidata/__init__.py
CHANGED
|
@@ -10,5 +10,6 @@ class OrderConfig(BaseModel):
|
|
|
10
10
|
autoValidationSetSize (int): The maximum size of the auto-generated validation set. Defaults to 20.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
+
autoValidationSetCreation: bool = Field(default=True)
|
|
13
14
|
minOrderDatapointsForValidation: int = Field(default=50)
|
|
14
15
|
autoValidationSetSize: int = Field(default=20)
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
from typing import Literal, Optional, Sequence
|
|
2
2
|
import random
|
|
3
|
+
import urllib.parse
|
|
4
|
+
import webbrowser
|
|
5
|
+
|
|
6
|
+
from colorama import Fore
|
|
3
7
|
from rapidata.api_client.models.ab_test_selection_a_inner import AbTestSelectionAInner
|
|
4
8
|
from rapidata.api_client.models.and_user_filter_model_filters_inner import (
|
|
5
9
|
AndUserFilterModelFiltersInner,
|
|
@@ -38,7 +42,6 @@ from rapidata.rapidata_client.workflow import Workflow
|
|
|
38
42
|
from rapidata.service.openapi_service import OpenAPIService
|
|
39
43
|
from rapidata.rapidata_client.api.rapidata_api_client import (
|
|
40
44
|
suppress_rapidata_error_logging,
|
|
41
|
-
RapidataApiClient,
|
|
42
45
|
)
|
|
43
46
|
|
|
44
47
|
|
|
@@ -124,16 +127,19 @@ class RapidataOrderBuilder:
|
|
|
124
127
|
),
|
|
125
128
|
)
|
|
126
129
|
|
|
127
|
-
def _set_validation_set_id(self) ->
|
|
130
|
+
def _set_validation_set_id(self) -> bool:
|
|
128
131
|
"""
|
|
129
132
|
Get the validation set ID for the order.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
bool: True if a new validation set was created, False otherwise.
|
|
130
136
|
"""
|
|
131
137
|
assert self.__workflow is not None
|
|
132
138
|
if self.__validation_set_id:
|
|
133
139
|
logger.debug(
|
|
134
140
|
"Using specified validation set with ID: %s", self.__validation_set_id
|
|
135
141
|
)
|
|
136
|
-
return
|
|
142
|
+
return False
|
|
137
143
|
|
|
138
144
|
try:
|
|
139
145
|
with suppress_rapidata_error_logging():
|
|
@@ -153,6 +159,7 @@ class RapidataOrderBuilder:
|
|
|
153
159
|
logger.debug(
|
|
154
160
|
"Using recommended validation set with ID: %s", self.__validation_set_id
|
|
155
161
|
)
|
|
162
|
+
return False
|
|
156
163
|
except Exception as e:
|
|
157
164
|
logger.debug("No recommended validation set found, error: %s", e)
|
|
158
165
|
|
|
@@ -163,14 +170,12 @@ class RapidataOrderBuilder:
|
|
|
163
170
|
logger.debug(
|
|
164
171
|
"No recommended validation set found, dataset too small to create one."
|
|
165
172
|
)
|
|
166
|
-
return
|
|
173
|
+
return False
|
|
167
174
|
|
|
168
175
|
logger.info("No recommended validation set found, creating new one.")
|
|
169
176
|
|
|
170
177
|
managed_print()
|
|
171
|
-
managed_print(
|
|
172
|
-
f"No recommended validation set found, new one will be created.\nWe recommend adding some truths to ensure the order is accurate."
|
|
173
|
-
)
|
|
178
|
+
managed_print(f"No recommended validation set found, new one will be created.")
|
|
174
179
|
validation_set = self.__validation_set_manager._create_order_validation_set(
|
|
175
180
|
workflow=self.__workflow,
|
|
176
181
|
order_name=self._name,
|
|
@@ -185,6 +190,7 @@ class RapidataOrderBuilder:
|
|
|
185
190
|
|
|
186
191
|
logger.debug("New validation set created for order: %s", validation_set)
|
|
187
192
|
self.__validation_set_id = validation_set.id
|
|
193
|
+
return True
|
|
188
194
|
|
|
189
195
|
def _create(self) -> RapidataOrder:
|
|
190
196
|
"""
|
|
@@ -197,8 +203,10 @@ class RapidataOrderBuilder:
|
|
|
197
203
|
Returns:
|
|
198
204
|
RapidataOrder: The created RapidataOrder instance.
|
|
199
205
|
"""
|
|
200
|
-
if rapidata_config.
|
|
201
|
-
self._set_validation_set_id()
|
|
206
|
+
if rapidata_config.order.autoValidationSetCreation:
|
|
207
|
+
new_validation_set = self._set_validation_set_id()
|
|
208
|
+
else:
|
|
209
|
+
new_validation_set = False
|
|
202
210
|
|
|
203
211
|
order_model = self._to_model()
|
|
204
212
|
logger.debug("Creating order with model: %s", order_model)
|
|
@@ -210,6 +218,24 @@ class RapidataOrderBuilder:
|
|
|
210
218
|
self.order_id = str(result.order_id)
|
|
211
219
|
logger.debug("Order created with ID: %s", self.order_id)
|
|
212
220
|
|
|
221
|
+
if rapidata_config.order.autoValidationSetCreation and new_validation_set:
|
|
222
|
+
required_amount = min(int(len(self.__datapoints) * 0.01) or 1, 10)
|
|
223
|
+
managed_print()
|
|
224
|
+
managed_print(
|
|
225
|
+
Fore.YELLOW
|
|
226
|
+
+ f"A new validation set was created. Please annotate {required_amount} datapoint{('s' if required_amount != 1 else '')} so the order runs correctly."
|
|
227
|
+
+ Fore.RESET
|
|
228
|
+
)
|
|
229
|
+
link = f"https://app.{self.__openapi_service.environment}/validation-set/detail/{self.__validation_set_id}/annotate?orderId={self.order_id}&required={required_amount}"
|
|
230
|
+
could_open_browser = webbrowser.open(link)
|
|
231
|
+
if not could_open_browser:
|
|
232
|
+
encoded_url = urllib.parse.quote(link, safe="%/:=&?~#+!$,;'@()*[]")
|
|
233
|
+
managed_print(
|
|
234
|
+
Fore.RED
|
|
235
|
+
+ f"Please open this URL in your browser: '{encoded_url}'"
|
|
236
|
+
+ Fore.RESET
|
|
237
|
+
)
|
|
238
|
+
|
|
213
239
|
self.__dataset = (
|
|
214
240
|
RapidataDataset(result.dataset_id, self.__openapi_service)
|
|
215
241
|
if result.dataset_id
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from typing import Any
|
|
1
3
|
import requests
|
|
2
4
|
from packaging import version
|
|
3
5
|
from rapidata import __version__
|
|
@@ -31,7 +33,7 @@ class RapidataClient:
|
|
|
31
33
|
client_id: str | None = None,
|
|
32
34
|
client_secret: str | None = None,
|
|
33
35
|
environment: str = "rapidata.ai",
|
|
34
|
-
oauth_scope: str = "openid",
|
|
36
|
+
oauth_scope: str = "openid roles",
|
|
35
37
|
cert_path: str | None = None,
|
|
36
38
|
token: dict | None = None,
|
|
37
39
|
leeway: int = 60,
|
|
@@ -51,10 +53,14 @@ class RapidataClient:
|
|
|
51
53
|
Attributes:
|
|
52
54
|
order (RapidataOrderManager): The RapidataOrderManager instance.
|
|
53
55
|
validation (ValidationSetManager): The ValidationSetManager instance.
|
|
56
|
+
demographic (DemographicManager): The DemographicManager instance.
|
|
57
|
+
mri (RapidataBenchmarkManager): The RapidataBenchmarkManager instance.
|
|
54
58
|
"""
|
|
55
59
|
with tracer.start_as_current_span("RapidataClient.__init__"):
|
|
56
60
|
logger.debug("Checking version")
|
|
57
61
|
self._check_version()
|
|
62
|
+
if environment != "rapidata.ai":
|
|
63
|
+
rapidata_config.logging.enable_otlp = False
|
|
58
64
|
|
|
59
65
|
logger.debug("Initializing OpenAPIService")
|
|
60
66
|
self._openapi_service = OpenAPIService(
|
|
@@ -83,13 +89,28 @@ class RapidataClient:
|
|
|
83
89
|
logger.debug("Initializing RapidataBenchmarkManager")
|
|
84
90
|
self.mri = RapidataBenchmarkManager(openapi_service=self._openapi_service)
|
|
85
91
|
|
|
92
|
+
self._check_beta_features()
|
|
93
|
+
|
|
86
94
|
def reset_credentials(self):
|
|
87
95
|
"""Reset the credentials saved in the configuration file for the current environment."""
|
|
88
96
|
self._openapi_service.reset_credentials()
|
|
89
97
|
|
|
90
|
-
def
|
|
98
|
+
def _check_beta_features(self):
|
|
91
99
|
"""Enable beta features for the client."""
|
|
92
|
-
|
|
100
|
+
result: dict[str, Any] = json.loads(
|
|
101
|
+
self._openapi_service.api_client.call_api(
|
|
102
|
+
"GET",
|
|
103
|
+
f"https://auth.{self._openapi_service.environment}/connect/userinfo",
|
|
104
|
+
)
|
|
105
|
+
.read()
|
|
106
|
+
.decode("utf-8")
|
|
107
|
+
)
|
|
108
|
+
logger.debug("Userinfo: %s", result)
|
|
109
|
+
if result.get("role") != ["Admin"]:
|
|
110
|
+
logger.debug("User is not an admin, not enabling beta features")
|
|
111
|
+
return
|
|
112
|
+
|
|
113
|
+
logger.debug("User is an admin, enabling beta features")
|
|
93
114
|
rapidata_config.enableBetaFeatures = True
|
|
94
115
|
|
|
95
116
|
def _check_version(self):
|
|
@@ -641,6 +641,10 @@ class ValidationSetManager:
|
|
|
641
641
|
if dimensions:
|
|
642
642
|
validation_set.update_dimensions(dimensions)
|
|
643
643
|
|
|
644
|
+
self.__openapi_service.validation_api.validation_set_validation_set_id_update_labeling_hints_post(
|
|
645
|
+
validation_set_id=validation_set_id
|
|
646
|
+
)
|
|
647
|
+
|
|
644
648
|
return validation_set
|
|
645
649
|
|
|
646
650
|
def get_validation_set_by_id(self, validation_set_id: str) -> RapidataValidationSet:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
rapidata/__init__.py,sha256=
|
|
1
|
+
rapidata/__init__.py,sha256=56QmFS7POsslVrmIEWRk1hMRZpZmKzHDBRzESibZS0Q,917
|
|
2
2
|
rapidata/api_client/__init__.py,sha256=utY2iWepKJQO_iGz6aIg_qSoqoDkV9pBMAA58pIFE4M,36016
|
|
3
3
|
rapidata/api_client/api/__init__.py,sha256=07qqwzQiBYt5V2BtnzbXhZL2cmVHATyZmCSGshIXLck,1603
|
|
4
4
|
rapidata/api_client/api/benchmark_api.py,sha256=Mlx2qDDJcgPjWvaBnps9dxvVd0re1knG0SyoLUiHKSc,119756
|
|
@@ -584,7 +584,7 @@ rapidata/rapidata_client/config/__init__.py,sha256=AdL9mKlOa_xm3spFKPBBdTYzhioQh
|
|
|
584
584
|
rapidata/rapidata_client/config/logger.py,sha256=nQl9w6wLdvKGJFqtEQWoUBAlDtvYmo3w4ekIx4sNynI,5518
|
|
585
585
|
rapidata/rapidata_client/config/logging_config.py,sha256=ePCh7X6v0Yzkgq1MhFNsHwLdcPEI4mYCCvBDxmWT7sU,2167
|
|
586
586
|
rapidata/rapidata_client/config/managed_print.py,sha256=2T6dwgR1EZzFAdOEyPp_BBUsa-qrEuhOXgFhsSQKvRo,185
|
|
587
|
-
rapidata/rapidata_client/config/order_config.py,sha256=
|
|
587
|
+
rapidata/rapidata_client/config/order_config.py,sha256=XxRZERzUUA9md6-PVlV__eCw8DD2kPbT_UmMwG1mAS4,615
|
|
588
588
|
rapidata/rapidata_client/config/rapidata_config.py,sha256=mURnKdl5-2sE4e_IYY9-aBkix6a12t47otEErGE_q0c,1507
|
|
589
589
|
rapidata/rapidata_client/config/tracer.py,sha256=h3GXzaX79HPcip4fBhLaLW0mRlXttR7D3KA78ZT0KVw,4736
|
|
590
590
|
rapidata/rapidata_client/config/upload_config.py,sha256=AYba-Nw9fddLFyfGB4ar2G8zZIVOHrCL_HZjTmvrKGQ,434
|
|
@@ -632,11 +632,11 @@ rapidata/rapidata_client/filter/response_count_filter.py,sha256=i2u2YQD3_RLQRZyq
|
|
|
632
632
|
rapidata/rapidata_client/filter/user_score_filter.py,sha256=4B3Zzp7aosDFmte3nLPTlXMN4zatT6Wcq5QLIoXqhgI,1910
|
|
633
633
|
rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
634
634
|
rapidata/rapidata_client/order/_rapidata_dataset.py,sha256=ftJD0czFX79AG9It7q2qdrQmUIGoyGq713AoUoC6nfU,18976
|
|
635
|
-
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=
|
|
635
|
+
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=e2W_aH-TxsZHcApCsdbps4lqYCwRh5uhldy0mxv2oDc,16878
|
|
636
636
|
rapidata/rapidata_client/order/rapidata_order.py,sha256=FvZi3t4dARRNsKWvYiNxVvM50AzPwQYR3AzI4utD6OI,14497
|
|
637
637
|
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=XiV_BpJxG6d8o0rFDYhnB3_mb576CQG5hY-qVXlJZKY,42592
|
|
638
638
|
rapidata/rapidata_client/order/rapidata_results.py,sha256=weL4S14fzug3ZOJbQk9Oj-4tv2jx5aZAMp7VJ-a6Qq4,8437
|
|
639
|
-
rapidata/rapidata_client/rapidata_client.py,sha256=
|
|
639
|
+
rapidata/rapidata_client/rapidata_client.py,sha256=Dm7ZW2tv0QNL1pMk8NHY79vpFXyPeKU6s0WMFHHIH20,5728
|
|
640
640
|
rapidata/rapidata_client/referee/__init__.py,sha256=J8oZJNUduPr-Tmn8iJwR-qBiSv7owhUFcEzXTRETecw,155
|
|
641
641
|
rapidata/rapidata_client/referee/_base_referee.py,sha256=aoH3Werw-AtQo2TncG69OmCVvnbXYJBfsRCQry_Pll0,497
|
|
642
642
|
rapidata/rapidata_client/referee/_early_stopping_referee.py,sha256=_JyFcTpncI0PrLf7Ix78FtLto31sdyGDS-2QbVTuvr8,2079
|
|
@@ -672,7 +672,7 @@ rapidata/rapidata_client/validation/rapids/__init__.py,sha256=WU5PPwtTJlte6U90MD
|
|
|
672
672
|
rapidata/rapidata_client/validation/rapids/box.py,sha256=Tm2_fVdOuj-eTT8hDMajlpgWQLNtKZqw5_ud2xvjR2w,587
|
|
673
673
|
rapidata/rapidata_client/validation/rapids/rapids.py,sha256=QckFItbKggezXb2awkDlYJ3mOw0Z7Z7gHzkWMBQEGl4,4822
|
|
674
674
|
rapidata/rapidata_client/validation/rapids/rapids_manager.py,sha256=H4pjPghUUQS8Bk2mqcnxVmononVb14erpCvZm6q-kOk,14137
|
|
675
|
-
rapidata/rapidata_client/validation/validation_set_manager.py,sha256=
|
|
675
|
+
rapidata/rapidata_client/validation/validation_set_manager.py,sha256=XdXpa0zko0tpTgowGrE5DAjnIM9lM8WKemGYibZeAa8,34864
|
|
676
676
|
rapidata/rapidata_client/workflow/__init__.py,sha256=6kfMN7TQVpiQNGjNHg3X7KdnCyYe3K2TIq7ZVEatQcU,476
|
|
677
677
|
rapidata/rapidata_client/workflow/_base_workflow.py,sha256=iuWomsy1zIcIxLzYTBKmAHs4sQ_D4xQkMaNWqf57y3E,1461
|
|
678
678
|
rapidata/rapidata_client/workflow/_classify_workflow.py,sha256=kw-otP_m1TY-mWSjYeMtrD2lLRtsNoocxQ00x50sKo8,2520
|
|
@@ -689,7 +689,7 @@ rapidata/service/credential_manager.py,sha256=T3yL4tXVnibRytxjQkOC-ex3kFGQR5KcKU
|
|
|
689
689
|
rapidata/service/local_file_service.py,sha256=0Q4LdoEtPFKzgXK2oZ1cQ-X7FipakscjGnnBH8dRFRQ,855
|
|
690
690
|
rapidata/service/openapi_service.py,sha256=k3V4eMNcAjBcxEv17lDivK8LV5TEjRTL9B_5KBlhcas,5482
|
|
691
691
|
rapidata/types/__init__.py,sha256=gSGrmWV5gEA6pPfAR5vwSy_DvibO5IjCZDiB7LtlMOQ,6134
|
|
692
|
-
rapidata-2.
|
|
693
|
-
rapidata-2.
|
|
694
|
-
rapidata-2.
|
|
695
|
-
rapidata-2.
|
|
692
|
+
rapidata-2.40.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
693
|
+
rapidata-2.40.1.dist-info/METADATA,sha256=-BOtvVuVwtdqSq-KcoEi9TYV2irzM9oFRjaIKd3U5Js,1406
|
|
694
|
+
rapidata-2.40.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
695
|
+
rapidata-2.40.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|