rapidata 2.37.0__py3-none-any.whl → 2.38.0__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 +3 -4
- rapidata/rapidata_client/__init__.py +1 -4
- rapidata/rapidata_client/api/{rapidata_exception.py → rapidata_api_client.py} +119 -2
- rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +88 -46
- rapidata/rapidata_client/benchmark/participant/_participant.py +26 -9
- rapidata/rapidata_client/benchmark/rapidata_benchmark.py +274 -205
- rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +98 -76
- rapidata/rapidata_client/config/__init__.py +3 -0
- rapidata/rapidata_client/config/logger.py +135 -0
- rapidata/rapidata_client/config/logging_config.py +58 -0
- rapidata/rapidata_client/config/managed_print.py +6 -0
- rapidata/rapidata_client/config/order_config.py +14 -0
- rapidata/rapidata_client/config/rapidata_config.py +14 -9
- rapidata/rapidata_client/config/tracer.py +130 -0
- rapidata/rapidata_client/config/upload_config.py +14 -0
- rapidata/rapidata_client/datapoints/_datapoint.py +1 -1
- rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
- rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
- rapidata/rapidata_client/demographic/demographic_manager.py +16 -14
- rapidata/rapidata_client/filter/_base_filter.py +11 -5
- rapidata/rapidata_client/filter/age_filter.py +9 -3
- rapidata/rapidata_client/filter/and_filter.py +20 -5
- rapidata/rapidata_client/filter/campaign_filter.py +7 -1
- rapidata/rapidata_client/filter/country_filter.py +8 -2
- rapidata/rapidata_client/filter/custom_filter.py +9 -3
- rapidata/rapidata_client/filter/gender_filter.py +9 -3
- rapidata/rapidata_client/filter/language_filter.py +12 -5
- rapidata/rapidata_client/filter/new_user_filter.py +3 -4
- rapidata/rapidata_client/filter/not_filter.py +17 -5
- rapidata/rapidata_client/filter/or_filter.py +20 -5
- rapidata/rapidata_client/filter/response_count_filter.py +6 -0
- rapidata/rapidata_client/filter/user_score_filter.py +17 -5
- rapidata/rapidata_client/order/_rapidata_dataset.py +45 -17
- rapidata/rapidata_client/order/_rapidata_order_builder.py +19 -13
- rapidata/rapidata_client/order/rapidata_order.py +60 -48
- rapidata/rapidata_client/order/rapidata_order_manager.py +231 -197
- rapidata/rapidata_client/order/rapidata_results.py +71 -57
- rapidata/rapidata_client/rapidata_client.py +36 -23
- rapidata/rapidata_client/selection/_base_selection.py +6 -0
- rapidata/rapidata_client/selection/static_selection.py +5 -10
- rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
- rapidata/rapidata_client/validation/rapidata_validation_set.py +20 -16
- rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
- rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
- rapidata/rapidata_client/workflow/_base_workflow.py +6 -1
- rapidata/rapidata_client/workflow/_classify_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_compare_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_draw_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_evaluation_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_free_text_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_locate_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_ranking_workflow.py +12 -0
- rapidata/rapidata_client/workflow/_select_words_workflow.py +6 -0
- rapidata/rapidata_client/workflow/_timestamp_workflow.py +6 -0
- rapidata/service/credential_manager.py +1 -1
- rapidata/service/openapi_service.py +2 -2
- {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/METADATA +4 -1
- {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/RECORD +62 -59
- rapidata/rapidata_client/logging/__init__.py +0 -2
- rapidata/rapidata_client/logging/logger.py +0 -122
- rapidata/rapidata_client/logging/output_manager.py +0 -20
- {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/LICENSE +0 -0
- {rapidata-2.37.0.dist-info → rapidata-2.38.0.dist-info}/WHEEL +0 -0
|
@@ -2,56 +2,63 @@ import pandas as pd
|
|
|
2
2
|
from typing import Any
|
|
3
3
|
from pandas.core.indexes.base import Index
|
|
4
4
|
import json
|
|
5
|
-
from rapidata.rapidata_client.
|
|
5
|
+
from rapidata.rapidata_client.config import managed_print
|
|
6
|
+
|
|
6
7
|
|
|
7
8
|
class RapidataResults(dict):
|
|
8
9
|
"""
|
|
9
10
|
A specialized dictionary class for handling Rapidata API results.
|
|
10
11
|
Extends the built-in dict class with specialized methods.
|
|
11
12
|
"""
|
|
13
|
+
|
|
12
14
|
def to_pandas(self, split_details: bool = False) -> pd.DataFrame:
|
|
13
15
|
"""
|
|
14
16
|
Warning:
|
|
15
17
|
This method is currently under development. The structure of the results may change in the future.
|
|
16
18
|
|
|
17
19
|
Converts the results to a pandas DataFrame.
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
For Compare results, creates standardized A/B columns for metrics.
|
|
20
22
|
For regular results, flattens nested dictionaries into columns with underscore-separated names.
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
Args:
|
|
23
25
|
split_details: If True, splits each datapoint by its detailed results,
|
|
24
26
|
creating a row for each response with global metrics copied.
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
Returns:
|
|
27
29
|
pd.DataFrame: A DataFrame containing the processed results
|
|
28
|
-
|
|
30
|
+
|
|
29
31
|
Raises:
|
|
30
32
|
ValueError: If split_details is True but no detailed results are found
|
|
31
33
|
"""
|
|
32
34
|
if "results" not in self or not self["results"]:
|
|
33
35
|
return pd.DataFrame()
|
|
34
|
-
|
|
36
|
+
|
|
35
37
|
if self["info"].get("orderType") is None:
|
|
36
|
-
managed_print(
|
|
37
|
-
|
|
38
|
+
managed_print(
|
|
39
|
+
"Warning: Results are old and Order type is not specified. Dataframe might be wrong."
|
|
40
|
+
)
|
|
41
|
+
|
|
38
42
|
# Check for detailed results if split_details is True
|
|
39
43
|
if split_details:
|
|
40
44
|
if not self._has_detailed_results():
|
|
41
45
|
raise ValueError("No detailed results found in the data")
|
|
42
46
|
return self._to_pandas_with_detailed_results()
|
|
43
|
-
|
|
44
|
-
if
|
|
47
|
+
|
|
48
|
+
if (
|
|
49
|
+
self["info"].get("orderType") == "Compare"
|
|
50
|
+
or self["info"].get("orderType") == "Ranking"
|
|
51
|
+
):
|
|
45
52
|
return self._compare_to_pandas()
|
|
46
|
-
|
|
53
|
+
|
|
47
54
|
# Get the structure from first item
|
|
48
55
|
first_item = self["results"][0]
|
|
49
56
|
columns = []
|
|
50
57
|
path_map = {} # Maps flattened column names to paths to reach the values
|
|
51
|
-
|
|
58
|
+
|
|
52
59
|
# Build the column structure once
|
|
53
60
|
self._build_column_structure(first_item, columns, path_map)
|
|
54
|
-
|
|
61
|
+
|
|
55
62
|
# Extract data using the known structure
|
|
56
63
|
data = []
|
|
57
64
|
for item in self["results"]:
|
|
@@ -60,82 +67,84 @@ class RapidataResults(dict):
|
|
|
60
67
|
value = self._get_value_from_path(item, path)
|
|
61
68
|
row.append(value)
|
|
62
69
|
data.append(row)
|
|
63
|
-
|
|
70
|
+
|
|
64
71
|
return pd.DataFrame(data, columns=Index(columns))
|
|
65
|
-
|
|
72
|
+
|
|
66
73
|
def _has_detailed_results(self) -> bool:
|
|
67
74
|
"""
|
|
68
75
|
Checks if the results contain detailed results.
|
|
69
|
-
|
|
76
|
+
|
|
70
77
|
Returns:
|
|
71
78
|
bool: True if detailed results exist, False otherwise
|
|
72
79
|
"""
|
|
73
80
|
if not self.get("results"):
|
|
74
81
|
return False
|
|
75
|
-
|
|
82
|
+
|
|
76
83
|
first_result = self["results"][0]
|
|
77
|
-
return "detailedResults" in first_result and isinstance(
|
|
78
|
-
|
|
84
|
+
return "detailedResults" in first_result and isinstance(
|
|
85
|
+
first_result["detailedResults"], list
|
|
86
|
+
)
|
|
87
|
+
|
|
79
88
|
def _to_pandas_with_detailed_results(self) -> pd.DataFrame:
|
|
80
89
|
"""
|
|
81
90
|
Converts results to a pandas DataFrame with detailed results split into separate rows.
|
|
82
|
-
|
|
91
|
+
|
|
83
92
|
Returns:
|
|
84
93
|
pd.DataFrame: A DataFrame with one row per detailed result
|
|
85
94
|
"""
|
|
86
95
|
rows = []
|
|
87
|
-
|
|
96
|
+
|
|
88
97
|
for result in self["results"]:
|
|
89
98
|
# Get all non-detailed results fields
|
|
90
99
|
base_data = {k: v for k, v in result.items() if k != "detailedResults"}
|
|
91
|
-
|
|
100
|
+
|
|
92
101
|
# Process each detailed result
|
|
93
102
|
for detailed_result in result["detailedResults"]:
|
|
94
103
|
row = base_data.copy() # Copy base data for each detailed result
|
|
95
|
-
|
|
104
|
+
|
|
96
105
|
# Add flattened detailed result data
|
|
97
106
|
flattened = self._flatten_dict(detailed_result)
|
|
98
107
|
for key, value in flattened.items():
|
|
99
108
|
row[key] = value
|
|
100
|
-
|
|
109
|
+
|
|
101
110
|
rows.append(row)
|
|
102
|
-
|
|
111
|
+
|
|
103
112
|
return pd.DataFrame(rows)
|
|
104
|
-
|
|
105
|
-
def _flatten_dict(self, d: dict[str, Any], parent_key: str =
|
|
113
|
+
|
|
114
|
+
def _flatten_dict(self, d: dict[str, Any], parent_key: str = "") -> dict[str, Any]:
|
|
106
115
|
"""
|
|
107
116
|
Flattens a nested dictionary into a single-level dictionary with underscore-separated keys.
|
|
108
|
-
|
|
117
|
+
|
|
109
118
|
Args:
|
|
110
119
|
d: The dictionary to flatten
|
|
111
120
|
parent_key: The parent key for nested dictionaries
|
|
112
|
-
|
|
121
|
+
|
|
113
122
|
Returns:
|
|
114
123
|
dict: A flattened dictionary
|
|
115
124
|
"""
|
|
116
125
|
items: list[tuple[str, Any]] = []
|
|
117
|
-
|
|
126
|
+
|
|
118
127
|
for key, value in d.items():
|
|
119
128
|
new_key = f"{parent_key}_{key}" if parent_key else key
|
|
120
|
-
|
|
129
|
+
|
|
121
130
|
if isinstance(value, dict):
|
|
122
131
|
items.extend(self._flatten_dict(value, new_key).items())
|
|
123
132
|
else:
|
|
124
133
|
items.append((new_key, value))
|
|
125
|
-
|
|
134
|
+
|
|
126
135
|
return dict(items)
|
|
127
136
|
|
|
128
137
|
def _build_column_structure(
|
|
129
|
-
self,
|
|
130
|
-
d: dict[str, Any],
|
|
131
|
-
columns: list[str],
|
|
132
|
-
path_map: dict[str, list[str]],
|
|
133
|
-
parent_key: str =
|
|
134
|
-
current_path: list[str] | None = None
|
|
138
|
+
self,
|
|
139
|
+
d: dict[str, Any],
|
|
140
|
+
columns: list[str],
|
|
141
|
+
path_map: dict[str, list[str]],
|
|
142
|
+
parent_key: str = "",
|
|
143
|
+
current_path: list[str] | None = None,
|
|
135
144
|
) -> None:
|
|
136
145
|
"""
|
|
137
146
|
Builds the column structure and paths to reach values in nested dictionaries.
|
|
138
|
-
|
|
147
|
+
|
|
139
148
|
Args:
|
|
140
149
|
d: The dictionary to analyze
|
|
141
150
|
columns: List to store column names
|
|
@@ -145,25 +154,27 @@ class RapidataResults(dict):
|
|
|
145
154
|
"""
|
|
146
155
|
if current_path is None:
|
|
147
156
|
current_path = []
|
|
148
|
-
|
|
157
|
+
|
|
149
158
|
for key, value in d.items():
|
|
150
159
|
new_key = f"{parent_key}_{key}" if parent_key else key
|
|
151
160
|
new_path: list[str] = current_path + [key]
|
|
152
|
-
|
|
161
|
+
|
|
153
162
|
if isinstance(value, dict):
|
|
154
|
-
self._build_column_structure(
|
|
163
|
+
self._build_column_structure(
|
|
164
|
+
value, columns, path_map, new_key, new_path
|
|
165
|
+
)
|
|
155
166
|
else:
|
|
156
167
|
columns.append(new_key)
|
|
157
168
|
path_map[new_key] = new_path
|
|
158
|
-
|
|
169
|
+
|
|
159
170
|
def _get_value_from_path(self, d: dict[str, Any], path: list[str]) -> Any:
|
|
160
171
|
"""
|
|
161
172
|
Retrieves a value from a nested dictionary using a path list.
|
|
162
|
-
|
|
173
|
+
|
|
163
174
|
Args:
|
|
164
175
|
d: The dictionary to retrieve the value from
|
|
165
176
|
path: List of keys forming the path to the desired value
|
|
166
|
-
|
|
177
|
+
|
|
167
178
|
Returns:
|
|
168
179
|
The value at the specified path, or None if the path doesn't exist
|
|
169
180
|
"""
|
|
@@ -190,10 +201,11 @@ class RapidataResults(dict):
|
|
|
190
201
|
continue
|
|
191
202
|
|
|
192
203
|
assets = [asset for asset in assets if asset not in ["Both", "Neither"]]
|
|
193
|
-
|
|
204
|
+
|
|
194
205
|
# Initialize row with non-comparative fields
|
|
195
206
|
row = {
|
|
196
|
-
key: value
|
|
207
|
+
key: value
|
|
208
|
+
for key, value in result.items()
|
|
197
209
|
if not isinstance(value, dict)
|
|
198
210
|
}
|
|
199
211
|
row["assetA"] = assets[0]
|
|
@@ -203,26 +215,28 @@ class RapidataResults(dict):
|
|
|
203
215
|
for key, values in result.items():
|
|
204
216
|
if isinstance(values, dict) and len(values) >= 2:
|
|
205
217
|
# Add main asset columns
|
|
206
|
-
for i, asset in enumerate(
|
|
218
|
+
for i, asset in enumerate(
|
|
219
|
+
assets[:2]
|
|
220
|
+
): # Limit to first 2 main assets
|
|
207
221
|
column_prefix = "A_" if i == 0 else "B_"
|
|
208
|
-
row[f
|
|
209
|
-
|
|
222
|
+
row[f"{column_prefix}{key}"] = values.get(asset, 0)
|
|
223
|
+
|
|
210
224
|
# Add special option columns if they exist
|
|
211
225
|
if "Both" in values:
|
|
212
|
-
row[f
|
|
226
|
+
row[f"Both_{key}"] = values.get("Both", 0)
|
|
213
227
|
if "Neither" in values:
|
|
214
|
-
row[f
|
|
215
|
-
|
|
228
|
+
row[f"Neither_{key}"] = values.get("Neither", 0)
|
|
229
|
+
|
|
216
230
|
rows.append(row)
|
|
217
|
-
|
|
231
|
+
|
|
218
232
|
return pd.DataFrame(rows)
|
|
219
233
|
|
|
220
|
-
def to_json(self, path: str="./results.json") -> None:
|
|
234
|
+
def to_json(self, path: str = "./results.json") -> None:
|
|
221
235
|
"""
|
|
222
236
|
Saves the results to a JSON file.
|
|
223
|
-
|
|
237
|
+
|
|
224
238
|
Args:
|
|
225
239
|
path: The file path where the JSON should be saved. Defaults to "./results.json".
|
|
226
240
|
"""
|
|
227
|
-
with open(path,
|
|
241
|
+
with open(path, "w") as f:
|
|
228
242
|
json.dump(self, f)
|
|
@@ -15,8 +15,12 @@ from rapidata.rapidata_client.validation.validation_set_manager import (
|
|
|
15
15
|
|
|
16
16
|
from rapidata.rapidata_client.demographic.demographic_manager import DemographicManager
|
|
17
17
|
|
|
18
|
-
from rapidata.rapidata_client.
|
|
19
|
-
|
|
18
|
+
from rapidata.rapidata_client.config import (
|
|
19
|
+
logger,
|
|
20
|
+
tracer,
|
|
21
|
+
managed_print,
|
|
22
|
+
rapidata_config,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
class RapidataClient:
|
|
@@ -48,31 +52,36 @@ class RapidataClient:
|
|
|
48
52
|
order (RapidataOrderManager): The RapidataOrderManager instance.
|
|
49
53
|
validation (ValidationSetManager): The ValidationSetManager instance.
|
|
50
54
|
"""
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
with tracer.start_as_current_span("RapidataClient.__init__"):
|
|
56
|
+
logger.debug("Checking version")
|
|
57
|
+
self._check_version()
|
|
58
|
+
|
|
59
|
+
logger.debug("Initializing OpenAPIService")
|
|
60
|
+
self._openapi_service = OpenAPIService(
|
|
61
|
+
client_id=client_id,
|
|
62
|
+
client_secret=client_secret,
|
|
63
|
+
environment=environment,
|
|
64
|
+
oauth_scope=oauth_scope,
|
|
65
|
+
cert_path=cert_path,
|
|
66
|
+
token=token,
|
|
67
|
+
leeway=leeway,
|
|
68
|
+
)
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
logger.debug("Initializing RapidataOrderManager")
|
|
71
|
+
self.order = RapidataOrderManager(openapi_service=self._openapi_service)
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
logger.debug("Initializing ValidationSetManager")
|
|
74
|
+
self.validation = ValidationSetManager(
|
|
75
|
+
openapi_service=self._openapi_service
|
|
76
|
+
)
|
|
70
77
|
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
logger.debug("Initializing DemographicManager")
|
|
79
|
+
self._demographic = DemographicManager(
|
|
80
|
+
openapi_service=self._openapi_service
|
|
81
|
+
)
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
83
|
+
logger.debug("Initializing RapidataBenchmarkManager")
|
|
84
|
+
self.mri = RapidataBenchmarkManager(openapi_service=self._openapi_service)
|
|
76
85
|
|
|
77
86
|
def reset_credentials(self):
|
|
78
87
|
"""Reset the credentials saved in the configuration file for the current environment."""
|
|
@@ -97,5 +106,9 @@ class RapidataClient:
|
|
|
97
106
|
f"""A new version of the Rapidata SDK is available: {latest_version}
|
|
98
107
|
Your current version is: {__version__}"""
|
|
99
108
|
)
|
|
109
|
+
else:
|
|
110
|
+
logger.debug(
|
|
111
|
+
"Current version is up to date. Version: %s", __version__
|
|
112
|
+
)
|
|
100
113
|
except Exception as e:
|
|
101
114
|
logger.debug("Failed to check for updates: %s", e)
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
from rapidata.api_client.models.static_selection import (
|
|
2
|
+
StaticSelection as StaticSelectionModel,
|
|
3
|
+
)
|
|
3
4
|
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
4
5
|
|
|
6
|
+
|
|
5
7
|
class StaticSelection(RapidataSelection):
|
|
6
8
|
"""StaticSelection Class
|
|
7
9
|
|
|
8
10
|
Given a list of RapidIds, theses specific rapids will be shown in order for every session.
|
|
9
|
-
|
|
11
|
+
|
|
10
12
|
Args:
|
|
11
13
|
rapid_ids (list[str]): List of rapid ids to show.
|
|
12
14
|
"""
|
|
13
15
|
|
|
14
16
|
def __init__(self, rapid_ids: list[str]):
|
|
15
17
|
self.rapid_ids = rapid_ids
|
|
16
|
-
|
|
17
|
-
def _to_model(self) -> StaticSelectionModel:
|
|
18
|
-
return StaticSelectionModel(
|
|
19
|
-
_t="StaticSelection",
|
|
20
|
-
rapidIds=self.rapid_ids
|
|
21
|
-
)
|
|
22
|
-
|
|
@@ -2,10 +2,18 @@ from pydantic import BaseModel
|
|
|
2
2
|
from typing import Any
|
|
3
3
|
from rapidata.api_client.models.feature_flag_model import FeatureFlagModel
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
class RapidataSetting(BaseModel):
|
|
6
7
|
"""Base class for all settings"""
|
|
8
|
+
|
|
7
9
|
key: str
|
|
8
10
|
value: Any
|
|
9
11
|
|
|
10
12
|
def _to_feature_flag(self) -> FeatureFlagModel:
|
|
11
13
|
return FeatureFlagModel(key=self.key, value=str(self.value))
|
|
14
|
+
|
|
15
|
+
def __str__(self) -> str:
|
|
16
|
+
return f"{self.__class__.__name__}(key='{self.key}', value={self.value})"
|
|
17
|
+
|
|
18
|
+
def __repr__(self) -> str:
|
|
19
|
+
return f"{self.__class__.__name__}(key={self.key!r}, value={self.value!r})"
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
-
from rapidata.rapidata_client.
|
|
2
|
+
from rapidata.rapidata_client.config import managed_print
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
class AlertOnFastResponse(RapidataSetting):
|
|
5
6
|
"""
|
|
6
7
|
Gives an alert as a pop up on the UI when the response time is less than the milliseconds.
|
|
7
|
-
|
|
8
|
+
|
|
8
9
|
Args:
|
|
9
10
|
threshold (int): if the user responds in less than this time, an alert will be shown.
|
|
10
11
|
"""
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
def __init__(self, threshold: int):
|
|
13
14
|
if not isinstance(threshold, int):
|
|
14
15
|
raise ValueError("The alert must be an integer.")
|
|
15
16
|
if threshold < 10:
|
|
16
|
-
managed_print(
|
|
17
|
+
managed_print(
|
|
18
|
+
f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?"
|
|
19
|
+
)
|
|
17
20
|
if threshold > 25000:
|
|
18
21
|
raise ValueError("The alert must be less than 25000 milliseconds.")
|
|
19
22
|
if threshold < 0:
|
|
20
23
|
raise ValueError("The alert must be greater than or equal to 0.")
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
super().__init__(key="alert_on_fast_response", value=threshold)
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
2
|
-
from rapidata.rapidata_client.
|
|
2
|
+
from rapidata.rapidata_client.config import managed_print
|
|
3
|
+
|
|
3
4
|
|
|
4
5
|
class FreeTextMinimumCharacters(RapidataSetting):
|
|
5
6
|
"""
|
|
6
7
|
Set the minimum number of characters a user has to type.
|
|
7
|
-
|
|
8
|
+
|
|
8
9
|
Args:
|
|
9
10
|
value (int): The minimum number of characters for free text.
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
13
|
def __init__(self, value: int):
|
|
13
14
|
if value < 1:
|
|
14
|
-
raise ValueError(
|
|
15
|
+
raise ValueError(
|
|
16
|
+
"The minimum number of characters must be greater than or equal to 1."
|
|
17
|
+
)
|
|
15
18
|
if value > 40:
|
|
16
|
-
managed_print(
|
|
19
|
+
managed_print(
|
|
20
|
+
f"Warning: Are you sure you want to set the minimum number of characters at {value}?"
|
|
21
|
+
)
|
|
17
22
|
super().__init__(key="free_text_minimum_characters", value=value)
|
|
@@ -3,7 +3,7 @@ import urllib.parse
|
|
|
3
3
|
from colorama import Fore
|
|
4
4
|
from rapidata.rapidata_client.validation.rapids.rapids import Rapid
|
|
5
5
|
from rapidata.service.openapi_service import OpenAPIService
|
|
6
|
-
from rapidata.rapidata_client.
|
|
6
|
+
from rapidata.rapidata_client.config import logger, managed_print, tracer
|
|
7
7
|
from rapidata.api_client.models.update_dimensions_model import UpdateDimensionsModel
|
|
8
8
|
from rapidata.api_client.models.update_should_alert_model import UpdateShouldAlertModel
|
|
9
9
|
|
|
@@ -34,7 +34,9 @@ class RapidataValidationSet:
|
|
|
34
34
|
Args:
|
|
35
35
|
rapid (Rapid): The Rapid to add to the validation set.
|
|
36
36
|
"""
|
|
37
|
-
|
|
37
|
+
with tracer.start_as_current_span("RapidataValidationSet.add_rapid"):
|
|
38
|
+
logger.debug("Adding rapid %s to validation set %s", rapid, self.id)
|
|
39
|
+
rapid._add_to_validation_set(self.id, self.__openapi_service)
|
|
38
40
|
return self
|
|
39
41
|
|
|
40
42
|
def update_dimensions(self, dimensions: list[str]):
|
|
@@ -43,13 +45,14 @@ class RapidataValidationSet:
|
|
|
43
45
|
Args:
|
|
44
46
|
dimensions (list[str]): The new dimensions of the validation set.
|
|
45
47
|
"""
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
self.
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
with tracer.start_as_current_span("RapidataValidationSet.update_dimensions"):
|
|
49
|
+
logger.debug(
|
|
50
|
+
"Updating dimensions for validation set %s to %s", self.id, dimensions
|
|
51
|
+
)
|
|
52
|
+
self.__openapi_service.validation_api.validation_set_validation_set_id_dimensions_put(
|
|
53
|
+
self.id, UpdateDimensionsModel(dimensions=dimensions)
|
|
54
|
+
)
|
|
55
|
+
return self
|
|
53
56
|
|
|
54
57
|
def update_should_alert(self, should_alert: bool):
|
|
55
58
|
"""Determines whether users should be alerted if they answer incorrectly.
|
|
@@ -60,13 +63,14 @@ class RapidataValidationSet:
|
|
|
60
63
|
Note:
|
|
61
64
|
The userScore dimensions which are updated when a user answers a validation task are updated regardless of the value of `should_alert`.
|
|
62
65
|
"""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
self.
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
with tracer.start_as_current_span("RapidataValidationSet.update_should_alert"):
|
|
67
|
+
logger.debug(
|
|
68
|
+
"Setting shouldAlert for validation set %s to %s", self.id, should_alert
|
|
69
|
+
)
|
|
70
|
+
self.__openapi_service.validation_api.validation_set_validation_set_id_shouldalert_patch(
|
|
71
|
+
self.id, UpdateShouldAlertModel(shouldAlert=should_alert)
|
|
72
|
+
)
|
|
73
|
+
return self
|
|
70
74
|
|
|
71
75
|
def view(self) -> None:
|
|
72
76
|
"""
|
|
@@ -15,7 +15,7 @@ from rapidata.api_client.models.dataset_dataset_id_datapoints_post_request_metad
|
|
|
15
15
|
)
|
|
16
16
|
from rapidata.service.openapi_service import OpenAPIService
|
|
17
17
|
|
|
18
|
-
from rapidata.rapidata_client.
|
|
18
|
+
from rapidata.rapidata_client.config import logger
|
|
19
19
|
from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting
|
|
20
20
|
|
|
21
21
|
|
|
@@ -109,3 +109,9 @@ class Rapid:
|
|
|
109
109
|
else None
|
|
110
110
|
),
|
|
111
111
|
)
|
|
112
|
+
|
|
113
|
+
def __str__(self) -> str:
|
|
114
|
+
return f"Rapid(asset={self.asset}, metadata={self.metadata}, payload={self.payload}, truth={self.truth}, randomCorrectProbability={self.randomCorrectProbability}, explanation={self.explanation}, settings={self.settings})"
|
|
115
|
+
|
|
116
|
+
def __repr__(self) -> str:
|
|
117
|
+
return self.__str__()
|