rapidata 2.27.0__py3-none-any.whl → 2.27.2__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.
- rapidata/__init__.py +1 -1
- rapidata/rapidata_client/filter/rapidata_filters.py +7 -7
- rapidata/rapidata_client/logging/logger.py +78 -3
- rapidata/rapidata_client/logging/output_manager.py +11 -7
- rapidata/rapidata_client/order/rapidata_order_manager.py +3 -0
- rapidata/rapidata_client/selection/rapidata_selections.py +8 -7
- rapidata/rapidata_client/settings/rapidata_settings.py +5 -8
- rapidata/rapidata_client/validation/validation_set_manager.py +67 -6
- rapidata/service/credential_manager.py +6 -6
- {rapidata-2.27.0.dist-info → rapidata-2.27.2.dist-info}/METADATA +1 -1
- {rapidata-2.27.0.dist-info → rapidata-2.27.2.dist-info}/RECORD +13 -13
- {rapidata-2.27.0.dist-info → rapidata-2.27.2.dist-info}/LICENSE +0 -0
- {rapidata-2.27.0.dist-info → rapidata-2.27.2.dist-info}/WHEEL +0 -0
rapidata/__init__.py
CHANGED
|
@@ -18,13 +18,13 @@ class RapidataFilters:
|
|
|
18
18
|
This might significantly slow down the number of responses you receive.
|
|
19
19
|
|
|
20
20
|
Attributes:
|
|
21
|
-
user_score (UserScoreFilter):
|
|
22
|
-
age (AgeFilter):
|
|
23
|
-
country (CountryFilter):
|
|
24
|
-
gender (GenderFilter):
|
|
25
|
-
language (LanguageFilter):
|
|
26
|
-
not_filter (NotFilter):
|
|
27
|
-
or_filter (OrFilter):
|
|
21
|
+
user_score (UserScoreFilter): Filters for users with a specific user score.
|
|
22
|
+
age (AgeFilter): Filters for users with a specific age.
|
|
23
|
+
country (CountryFilter): Filters for users with a specific country.
|
|
24
|
+
gender (GenderFilter): Filters for users with a specific gender.
|
|
25
|
+
language (LanguageFilter): Filters for users with a specific language.
|
|
26
|
+
not_filter (NotFilter): Inverts the filter.
|
|
27
|
+
or_filter (OrFilter): Combines multiple filters with a logical OR operation.
|
|
28
28
|
|
|
29
29
|
Example:
|
|
30
30
|
```python
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Provides centralized logging configuration for the Rapidata Python SDK.
|
|
3
|
+
It sets up a logger instance that is used throughout the SDK to provide
|
|
4
|
+
consistent logging behavior and formatting.
|
|
5
|
+
|
|
6
|
+
The logger is configured with sensible defaults but can be customized using the
|
|
7
|
+
`configure_logger` function to adjust log levels, output destinations, and formatting.
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
Basic usage with default configuration:
|
|
11
|
+
```python
|
|
12
|
+
from rapidata import logger
|
|
13
|
+
|
|
14
|
+
logger.info("This is an info message")
|
|
15
|
+
logger.error("This is an error message")
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Custom configuration:
|
|
19
|
+
```python
|
|
20
|
+
from rapidata import configure_logger
|
|
21
|
+
|
|
22
|
+
# Configure with DEBUG level and file output
|
|
23
|
+
configure_logger(
|
|
24
|
+
level="DEBUG",
|
|
25
|
+
log_file="/path/to/logs/rapidata.log"
|
|
26
|
+
)
|
|
27
|
+
```
|
|
28
|
+
"""
|
|
1
29
|
import logging
|
|
2
30
|
import os
|
|
3
31
|
from typing import Optional
|
|
@@ -9,9 +37,56 @@ def configure_logger(
|
|
|
9
37
|
level: str = "WARNING",
|
|
10
38
|
log_file: Optional[str] = None,
|
|
11
39
|
format_string: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
12
|
-
):
|
|
13
|
-
"""
|
|
14
|
-
|
|
40
|
+
) -> None:
|
|
41
|
+
"""
|
|
42
|
+
Configure the logger with custom settings.
|
|
43
|
+
|
|
44
|
+
This function allows you to customize the logging behavior for the entire SDK.
|
|
45
|
+
You can set the log level, specify a file for log output, and customize the log message format.
|
|
46
|
+
|
|
47
|
+
Note:
|
|
48
|
+
This function removes any existing handlers before adding new ones,
|
|
49
|
+
so it's safe to call multiple times to reconfigure logging.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
level: The logging level to set. Must be one of:\n
|
|
53
|
+
- "DEBUG": Detailed information for diagnosing problems
|
|
54
|
+
- "INFO": General information about program execution
|
|
55
|
+
- "WARNING": Something unexpected happened (default)
|
|
56
|
+
- "ERROR": A serious problem occurred
|
|
57
|
+
- "CRITICAL": A very serious error occurred
|
|
58
|
+
|
|
59
|
+
log_file: Optional path to a file where logs should be written.
|
|
60
|
+
If provided, logs will be written to both console and file.
|
|
61
|
+
The directory will be created if it doesn't exist.
|
|
62
|
+
|
|
63
|
+
format_string: Custom format string for log messages.
|
|
64
|
+
Uses Python logging format specifications.
|
|
65
|
+
Default includes timestamp, logger name, level, and message.
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
Configure for development with debug logging:
|
|
69
|
+
```python
|
|
70
|
+
configure_logger(level="DEBUG")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Configure for production with file logging:
|
|
74
|
+
```python
|
|
75
|
+
configure_logger(
|
|
76
|
+
level="INFO",
|
|
77
|
+
log_file="/var/log/rapidata/app.log"
|
|
78
|
+
)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Configure with custom format:
|
|
82
|
+
```python
|
|
83
|
+
configure_logger(
|
|
84
|
+
level="INFO",
|
|
85
|
+
format_string="[%(levelname)s] %(message)s"
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
"""
|
|
89
|
+
# Map string levels to logging constants for validation and conversion
|
|
15
90
|
level_map = {
|
|
16
91
|
"DEBUG": logging.DEBUG,
|
|
17
92
|
"INFO": logging.INFO,
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
class RapidataOutputManager:
|
|
2
|
-
|
|
2
|
+
"""Manages print outputs and progress bars for the Rapidata module."""
|
|
3
3
|
|
|
4
|
+
silent_mode: bool = False
|
|
5
|
+
|
|
4
6
|
@classmethod
|
|
5
|
-
def enable_silent_mode(cls):
|
|
7
|
+
def enable_silent_mode(cls) -> None:
|
|
8
|
+
"""Enable silent mode, suppressing all print outputs and progress bars, not logging."""
|
|
6
9
|
cls.silent_mode = True
|
|
7
|
-
|
|
10
|
+
|
|
8
11
|
@classmethod
|
|
9
|
-
def disable_silent_mode(cls):
|
|
12
|
+
def disable_silent_mode(cls) -> None:
|
|
13
|
+
"""Disable silent mode, allowing outputs to be printed.
|
|
14
|
+
This is the default behavior.
|
|
15
|
+
"""
|
|
10
16
|
cls.silent_mode = False
|
|
11
17
|
|
|
12
|
-
def managed_print(*args, **kwargs):
|
|
18
|
+
def managed_print(*args, **kwargs) -> None:
|
|
13
19
|
if not RapidataOutputManager.silent_mode:
|
|
14
20
|
print(*args, **kwargs)
|
|
15
|
-
|
|
16
|
-
|
|
@@ -77,6 +77,9 @@ class RapidataOrderManager:
|
|
|
77
77
|
private_notes: list[str] | None = None,
|
|
78
78
|
default_labeling_amount: int = 3
|
|
79
79
|
) -> RapidataOrder:
|
|
80
|
+
|
|
81
|
+
if not assets:
|
|
82
|
+
raise ValueError("No datapoints provided")
|
|
80
83
|
|
|
81
84
|
if contexts and len(contexts) != len(assets):
|
|
82
85
|
raise ValueError("Number of contexts must match number of datapoints")
|
|
@@ -10,15 +10,16 @@ class RapidataSelections:
|
|
|
10
10
|
"""RapidataSelections Classes
|
|
11
11
|
|
|
12
12
|
Selections are used to define what type of tasks and in what order they are shown to the user.
|
|
13
|
-
All
|
|
13
|
+
All selections combined are called a "Session". A session can contain multiple tasks of different types of tasks.
|
|
14
|
+
As an example, a session might be 1 validation task, 2 labeling tasks.
|
|
14
15
|
|
|
15
16
|
Attributes:
|
|
16
|
-
labeling (LabelingSelection):
|
|
17
|
-
validation (ValidationSelection):
|
|
18
|
-
conditional_validation (ConditionalValidationSelection):
|
|
19
|
-
demographic (DemographicSelection):
|
|
20
|
-
capped (CappedSelection):
|
|
21
|
-
shuffling (ShufflingSelection):
|
|
17
|
+
labeling (LabelingSelection): Decides how many actual datapoints you want to show per session.
|
|
18
|
+
validation (ValidationSelection): Decides how many validation rapids you want to show per session.
|
|
19
|
+
conditional_validation (ConditionalValidationSelection): Probabilistically decides how many validation rapids you want to show per session based on the user score.
|
|
20
|
+
demographic (DemographicSelection): Decides if and how many demographic questions you want to show per session.
|
|
21
|
+
capped (CappedSelection): Takes in different selections and caps the amount of rapids that can be shown.
|
|
22
|
+
shuffling (ShufflingSelection): Shuffles the selections provided in the list.
|
|
22
23
|
|
|
23
24
|
Example:
|
|
24
25
|
```python
|
|
@@ -4,7 +4,6 @@ from rapidata.rapidata_client.settings import (
|
|
|
4
4
|
FreeTextMinimumCharacters,
|
|
5
5
|
NoShuffle,
|
|
6
6
|
PlayVideoUntilTheEnd,
|
|
7
|
-
CustomSetting,
|
|
8
7
|
)
|
|
9
8
|
|
|
10
9
|
class RapidataSettings:
|
|
@@ -14,12 +13,11 @@ class RapidataSettings:
|
|
|
14
13
|
Settings can be added to an order to determine the behaviour of the task.
|
|
15
14
|
|
|
16
15
|
Attributes:
|
|
17
|
-
alert_on_fast_response (AlertOnFastResponse):
|
|
18
|
-
translation_behaviour (TranslationBehaviour):
|
|
19
|
-
free_text_minimum_characters (FreeTextMinimumCharacters):
|
|
20
|
-
no_shuffle (NoShuffle):
|
|
21
|
-
play_video_until_the_end (PlayVideoUntilTheEnd):
|
|
22
|
-
custom_setting (CustomSetting): The CustomSetting instance.
|
|
16
|
+
alert_on_fast_response (AlertOnFastResponse): Gives an alert as a pop up on the UI when the response time is less than the milliseconds.
|
|
17
|
+
translation_behaviour (TranslationBehaviour): Defines what's the behaviour of the translation in the UI.
|
|
18
|
+
free_text_minimum_characters (FreeTextMinimumCharacters): Only for free text tasks. Set the minimum number of characters a user has to type.
|
|
19
|
+
no_shuffle (NoShuffle): Only for classification and compare tasks. If true, the order of the categories / images will not be shuffled and presented in the same order as specified.
|
|
20
|
+
play_video_until_the_end (PlayVideoUntilTheEnd): Allows users to only answer once the video has finished playing.
|
|
23
21
|
|
|
24
22
|
Example:
|
|
25
23
|
```python
|
|
@@ -35,5 +33,4 @@ class RapidataSettings:
|
|
|
35
33
|
free_text_minimum_characters = FreeTextMinimumCharacters
|
|
36
34
|
no_shuffle = NoShuffle
|
|
37
35
|
play_video_until_the_end = PlayVideoUntilTheEnd
|
|
38
|
-
custom_setting = CustomSetting
|
|
39
36
|
|
|
@@ -5,7 +5,7 @@ from rapidata.service.openapi_service import OpenAPIService
|
|
|
5
5
|
from rapidata.rapidata_client.assets.data_type_enum import RapidataDataTypes
|
|
6
6
|
from rapidata.rapidata_client.validation.rapids.rapids_manager import RapidsManager
|
|
7
7
|
from rapidata.rapidata_client.validation.rapids.rapids import Rapid
|
|
8
|
-
from rapidata.rapidata_client.metadata import PromptMetadata
|
|
8
|
+
from rapidata.rapidata_client.metadata import PromptMetadata, MediaAssetMetadata
|
|
9
9
|
|
|
10
10
|
from rapidata.api_client.models.page_info import PageInfo
|
|
11
11
|
from rapidata.api_client.models.root_filter import RootFilter
|
|
@@ -39,6 +39,7 @@ class ValidationSetManager:
|
|
|
39
39
|
truths: list[list[str]],
|
|
40
40
|
data_type: str = RapidataDataTypes.MEDIA,
|
|
41
41
|
contexts: list[str] | None = None,
|
|
42
|
+
media_contexts: list[str] | None = None,
|
|
42
43
|
explanations: list[str | None] | None = None,
|
|
43
44
|
dimensions: list[str] = [],
|
|
44
45
|
) -> RapidataValidationSet:
|
|
@@ -58,6 +59,9 @@ class ValidationSetManager:
|
|
|
58
59
|
contexts (list[str], optional): The contexts for each datapoint. Defaults to None.\n
|
|
59
60
|
If provided has to be the same length as datapoints and will be shown in addition to the instruction and answer options. (Therefore will be different for each datapoint)
|
|
60
61
|
Will be match up with the datapoints using the list index.
|
|
62
|
+
media_contexts (list[str], optional): The list of media contexts i.e. links to the images / videos for the comparison. Defaults to None.\n
|
|
63
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
64
|
+
Will be matched up with the datapoints using the list index.
|
|
61
65
|
explanations (list[str | None], optional): The explanations for each datapoint. Will be given to the annotators in case the answer is wrong. Defaults to None.
|
|
62
66
|
dimensions (list[str], optional): The dimensions to add to the validation set accross which users will be tracked. Defaults to [] which is the default dimension.
|
|
63
67
|
|
|
@@ -79,12 +83,21 @@ class ValidationSetManager:
|
|
|
79
83
|
if contexts and len(contexts) != len(datapoints):
|
|
80
84
|
raise ValueError("The number of contexts and datapoints must be equal")
|
|
81
85
|
|
|
86
|
+
if media_contexts and len(media_contexts) != len(datapoints):
|
|
87
|
+
raise ValueError("The number of media contexts and datapoints must be equal")
|
|
88
|
+
|
|
82
89
|
if(explanations and len(explanations) != len(datapoints)):
|
|
83
90
|
raise ValueError("The number of explanations and datapoints must be equal, the index must align, but can be padded with None")
|
|
91
|
+
|
|
84
92
|
|
|
85
93
|
logger.debug("Creating classification rapids")
|
|
86
94
|
rapids: list[Rapid] = []
|
|
87
95
|
for i in range(len(datapoints)):
|
|
96
|
+
rapid_metadata = []
|
|
97
|
+
if contexts:
|
|
98
|
+
rapid_metadata.append(PromptMetadata(contexts[i]))
|
|
99
|
+
if media_contexts:
|
|
100
|
+
rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
|
|
88
101
|
rapids.append(
|
|
89
102
|
self.rapid.classification_rapid(
|
|
90
103
|
instruction=instruction,
|
|
@@ -92,7 +105,7 @@ class ValidationSetManager:
|
|
|
92
105
|
datapoint=datapoints[i],
|
|
93
106
|
truths=truths[i],
|
|
94
107
|
data_type=data_type,
|
|
95
|
-
metadata=
|
|
108
|
+
metadata=rapid_metadata,
|
|
96
109
|
explanation=explanations[i] if explanations != None else None
|
|
97
110
|
)
|
|
98
111
|
)
|
|
@@ -107,6 +120,7 @@ class ValidationSetManager:
|
|
|
107
120
|
truths: list[str],
|
|
108
121
|
data_type: str = RapidataDataTypes.MEDIA,
|
|
109
122
|
contexts: list[str] | None = None,
|
|
123
|
+
media_contexts: list[str] | None = None,
|
|
110
124
|
explanation: list[str | None] | None = None,
|
|
111
125
|
dimensions: list[str] = [],
|
|
112
126
|
) -> RapidataValidationSet:
|
|
@@ -126,6 +140,9 @@ class ValidationSetManager:
|
|
|
126
140
|
contexts (list[str], optional): The contexts for each datapoint. Defaults to None.\n
|
|
127
141
|
If provided has to be the same length as datapoints and will be shown in addition to the instruction and truth. (Therefore will be different for each datapoint)
|
|
128
142
|
Will be match up with the datapoints using the list index.
|
|
143
|
+
media_contexts (list[str], optional): The list of media contexts i.e. links to the images / videos for the comparison. Defaults to None.\n
|
|
144
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
145
|
+
Will be matched up with the datapoints using the list index.
|
|
129
146
|
explanation (list[str | None], optional): The explanations for each datapoint. Will be given to the annotators in case the answer is wrong. Defaults to None.
|
|
130
147
|
dimensions (list[str], optional): The dimensions to add to the validation set accross which users will be tracked. Defaults to [] which is the default dimension.
|
|
131
148
|
|
|
@@ -146,6 +163,9 @@ class ValidationSetManager:
|
|
|
146
163
|
|
|
147
164
|
if contexts and len(contexts) != len(datapoints):
|
|
148
165
|
raise ValueError("The number of contexts and datapoints must be equal")
|
|
166
|
+
|
|
167
|
+
if media_contexts and len(media_contexts) != len(datapoints):
|
|
168
|
+
raise ValueError("The number of media contexts and datapoints must be equal")
|
|
149
169
|
|
|
150
170
|
if(explanation and len(explanation) != len(datapoints)):
|
|
151
171
|
raise ValueError("The number of explanations and datapoints must be equal, the index must align, but can be padded with None")
|
|
@@ -153,13 +173,18 @@ class ValidationSetManager:
|
|
|
153
173
|
logger.debug("Creating comparison rapids")
|
|
154
174
|
rapids: list[Rapid] = []
|
|
155
175
|
for i in range(len(datapoints)):
|
|
176
|
+
rapid_metadata = []
|
|
177
|
+
if contexts:
|
|
178
|
+
rapid_metadata.append(PromptMetadata(contexts[i]))
|
|
179
|
+
if media_contexts:
|
|
180
|
+
rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
|
|
156
181
|
rapids.append(
|
|
157
182
|
self.rapid.compare_rapid(
|
|
158
183
|
instruction=instruction,
|
|
159
184
|
truth=truths[i],
|
|
160
185
|
datapoint=datapoints[i],
|
|
161
186
|
data_type=data_type,
|
|
162
|
-
metadata=
|
|
187
|
+
metadata=rapid_metadata,
|
|
163
188
|
explanation=explanation[i] if explanation != None else None
|
|
164
189
|
)
|
|
165
190
|
)
|
|
@@ -238,6 +263,7 @@ class ValidationSetManager:
|
|
|
238
263
|
truths: list[list[Box]],
|
|
239
264
|
datapoints: list[str],
|
|
240
265
|
contexts: list[str] | None = None,
|
|
266
|
+
media_contexts: list[str] | None = None,
|
|
241
267
|
explanation: list[str | None] | None = None,
|
|
242
268
|
dimensions: list[str] = [],
|
|
243
269
|
) -> RapidataValidationSet:
|
|
@@ -252,6 +278,9 @@ class ValidationSetManager:
|
|
|
252
278
|
truths: [[Box(0, 0, 100, 100)], [Box(50, 50, 150, 150)]] -> first datapoint the object is in the top left corner, second datapoint the object is in the center
|
|
253
279
|
datapoints (list[str]): The datapoints that will be used for validation.
|
|
254
280
|
contexts (list[str], optional): The contexts for each datapoint. Defaults to None.
|
|
281
|
+
media_contexts (list[str], optional): The list of media contexts i.e. links to the images / videos for the comparison. Defaults to None.\n
|
|
282
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
283
|
+
Will be matched up with the datapoints using the list index.
|
|
255
284
|
explanation (list[str | None], optional): The explanations for each datapoint. Will be given to the annotators in case the answer is wrong. Defaults to None.
|
|
256
285
|
dimensions (list[str], optional): The dimensions to add to the validation set accross which users will be tracked. Defaults to [] which is the default dimension.
|
|
257
286
|
|
|
@@ -272,6 +301,9 @@ class ValidationSetManager:
|
|
|
272
301
|
if contexts and len(contexts) != len(datapoints):
|
|
273
302
|
raise ValueError("The number of contexts and datapoints must be equal")
|
|
274
303
|
|
|
304
|
+
if media_contexts and len(media_contexts) != len(datapoints):
|
|
305
|
+
raise ValueError("The number of media contexts and datapoints must be equal")
|
|
306
|
+
|
|
275
307
|
if(explanation and len(explanation) != len(datapoints)):
|
|
276
308
|
raise ValueError("The number of explanations and datapoints must be equal, the index must align, but can be padded with None")
|
|
277
309
|
|
|
@@ -279,12 +311,17 @@ class ValidationSetManager:
|
|
|
279
311
|
rapids = []
|
|
280
312
|
rapids: list[Rapid] = []
|
|
281
313
|
for i in range(len(datapoints)):
|
|
314
|
+
rapid_metadata = []
|
|
315
|
+
if contexts:
|
|
316
|
+
rapid_metadata.append(PromptMetadata(contexts[i]))
|
|
317
|
+
if media_contexts:
|
|
318
|
+
rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
|
|
282
319
|
rapids.append(
|
|
283
320
|
self.rapid.locate_rapid(
|
|
284
321
|
instruction=instruction,
|
|
285
322
|
truths=truths[i],
|
|
286
323
|
datapoint=datapoints[i],
|
|
287
|
-
metadata=
|
|
324
|
+
metadata=rapid_metadata,
|
|
288
325
|
explanation=explanation[i] if explanation != None else None
|
|
289
326
|
|
|
290
327
|
)
|
|
@@ -299,6 +336,7 @@ class ValidationSetManager:
|
|
|
299
336
|
truths: list[list[Box]],
|
|
300
337
|
datapoints: list[str],
|
|
301
338
|
contexts: list[str] | None = None,
|
|
339
|
+
media_contexts: list[str] | None = None,
|
|
302
340
|
explanation: list[str | None] | None = None,
|
|
303
341
|
dimensions: list[str] = [],
|
|
304
342
|
) -> RapidataValidationSet:
|
|
@@ -313,6 +351,9 @@ class ValidationSetManager:
|
|
|
313
351
|
truths: [[Box(0, 0, 100, 100)], [Box(50, 50, 150, 150)]] -> first datapoint the object is in the top left corner, second datapoint the object is in the center
|
|
314
352
|
datapoints (list[str]): The datapoints that will be used for validation.
|
|
315
353
|
contexts (list[str], optional): The contexts for each datapoint. Defaults to None.
|
|
354
|
+
media_contexts (list[str], optional): The list of media contexts i.e. links to the images / videos for the comparison. Defaults to None.\n
|
|
355
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
356
|
+
Will be matched up with the datapoints using the list index.
|
|
316
357
|
explanation (list[str | None], optional): The explanations for each datapoint. Will be given to the annotators in case the answer is wrong. Defaults to None.
|
|
317
358
|
dimensions (list[str], optional): The dimensions to add to the validation set accross which users will be tracked. Defaults to [] which is the default dimension.
|
|
318
359
|
|
|
@@ -333,18 +374,26 @@ class ValidationSetManager:
|
|
|
333
374
|
if contexts and len(contexts) != len(datapoints):
|
|
334
375
|
raise ValueError("The number of contexts and datapoints must be equal")
|
|
335
376
|
|
|
377
|
+
if media_contexts and len(media_contexts) != len(datapoints):
|
|
378
|
+
raise ValueError("The number of media contexts and datapoints must be equal")
|
|
379
|
+
|
|
336
380
|
if(explanation and len(explanation) != len(datapoints)):
|
|
337
381
|
raise ValueError("The number of explanations and datapoints must be equal, the index must align, but can be padded with None")
|
|
338
382
|
|
|
339
383
|
logger.debug("Creating draw rapids")
|
|
340
384
|
rapids: list[Rapid] = []
|
|
341
385
|
for i in range(len(datapoints)):
|
|
386
|
+
rapid_metadata = []
|
|
387
|
+
if contexts:
|
|
388
|
+
rapid_metadata.append(PromptMetadata(contexts[i]))
|
|
389
|
+
if media_contexts:
|
|
390
|
+
rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
|
|
342
391
|
rapids.append(
|
|
343
392
|
self.rapid.draw_rapid(
|
|
344
393
|
instruction=instruction,
|
|
345
394
|
truths=truths[i],
|
|
346
395
|
datapoint=datapoints[i],
|
|
347
|
-
metadata=
|
|
396
|
+
metadata=rapid_metadata,
|
|
348
397
|
explanation=explanation[i] if explanation != None else None
|
|
349
398
|
|
|
350
399
|
)
|
|
@@ -359,6 +408,7 @@ class ValidationSetManager:
|
|
|
359
408
|
truths: list[list[tuple[int, int]]],
|
|
360
409
|
datapoints: list[str],
|
|
361
410
|
contexts: list[str] | None = None,
|
|
411
|
+
media_contexts: list[str] | None = None,
|
|
362
412
|
explanation: list[str | None] | None = None,
|
|
363
413
|
dimensions: list[str] = [],
|
|
364
414
|
) -> RapidataValidationSet:
|
|
@@ -374,6 +424,9 @@ class ValidationSetManager:
|
|
|
374
424
|
truths: [[(0, 10)], [(20, 30)]] -> first datapoint the correct interval is from 0 to 10, second datapoint the correct interval is from 20 to 30
|
|
375
425
|
datapoints (list[str]): The datapoints that will be used for validation.
|
|
376
426
|
contexts (list[str], optional): The contexts for each datapoint. Defaults to None.
|
|
427
|
+
media_contexts (list[str], optional): The list of media contexts i.e. links to the images / videos for the comparison. Defaults to None.\n
|
|
428
|
+
If provided has to be the same length as datapoints and will be shown in addition to the instruction. (Therefore will be different for each datapoint)
|
|
429
|
+
Will be matched up with the datapoints using the list index.
|
|
377
430
|
explanation (list[str | None], optional): The explanations for each datapoint. Will be given to the annotators in case the answer is wrong. Defaults to None.
|
|
378
431
|
dimensions (list[str], optional): The dimensions to add to the validation set accross which users will be tracked. Defaults to [] which is the default dimension.
|
|
379
432
|
|
|
@@ -394,18 +447,26 @@ class ValidationSetManager:
|
|
|
394
447
|
if contexts and len(contexts) != len(datapoints):
|
|
395
448
|
raise ValueError("The number of contexts and datapoints must be equal")
|
|
396
449
|
|
|
450
|
+
if media_contexts and len(media_contexts) != len(datapoints):
|
|
451
|
+
raise ValueError("The number of media contexts and datapoints must be equal")
|
|
452
|
+
|
|
397
453
|
if(explanation and len(explanation) != len(datapoints)):
|
|
398
454
|
raise ValueError("The number of explanations and datapoints must be equal, the index must align, but can be padded with None")
|
|
399
455
|
|
|
400
456
|
logger.debug("Creating timestamp rapids")
|
|
401
457
|
rapids: list[Rapid] = []
|
|
402
458
|
for i in range(len(datapoints)):
|
|
459
|
+
rapid_metadata = []
|
|
460
|
+
if contexts:
|
|
461
|
+
rapid_metadata.append(PromptMetadata(contexts[i]))
|
|
462
|
+
if media_contexts:
|
|
463
|
+
rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
|
|
403
464
|
rapids.append(
|
|
404
465
|
self.rapid.timestamp_rapid(
|
|
405
466
|
instruction=instruction,
|
|
406
467
|
truths=truths[i],
|
|
407
468
|
datapoint=datapoints[i],
|
|
408
|
-
metadata=
|
|
469
|
+
metadata=rapid_metadata,
|
|
409
470
|
explanation=explanation[i] if explanation != None else None
|
|
410
471
|
)
|
|
411
472
|
)
|
|
@@ -81,7 +81,9 @@ class CredentialManager:
|
|
|
81
81
|
|
|
82
82
|
# Ensure file is only readable by the user
|
|
83
83
|
os.chmod(self.config_path, 0o600)
|
|
84
|
-
logger.debug(
|
|
84
|
+
logger.debug(
|
|
85
|
+
f"Set permissions for {self.config_path} to read/write for user only."
|
|
86
|
+
)
|
|
85
87
|
|
|
86
88
|
def _store_credential(self, credential: ClientCredential) -> None:
|
|
87
89
|
credentials = self._read_credentials()
|
|
@@ -128,16 +130,14 @@ class CredentialManager:
|
|
|
128
130
|
if self.endpoint in credentials:
|
|
129
131
|
del credentials[self.endpoint]
|
|
130
132
|
self._write_credentials(credentials)
|
|
131
|
-
logger.info(
|
|
132
|
-
f"Credentials for {self.endpoint} have been reset."
|
|
133
|
-
)
|
|
133
|
+
logger.info(f"Credentials for {self.endpoint} have been reset.")
|
|
134
134
|
|
|
135
135
|
def _get_bridge_tokens(self) -> Optional[BridgeToken]:
|
|
136
136
|
"""Get bridge tokens from the identity endpoint."""
|
|
137
137
|
logger.debug("Getting bridge tokens")
|
|
138
138
|
try:
|
|
139
139
|
bridge_endpoint = (
|
|
140
|
-
f"{self.endpoint}/
|
|
140
|
+
f"{self.endpoint}/identity/bridge-token?clientId=rapidata-cli"
|
|
141
141
|
)
|
|
142
142
|
response = requests.post(bridge_endpoint, verify=self.cert_path)
|
|
143
143
|
if not response.ok:
|
|
@@ -152,7 +152,7 @@ class CredentialManager:
|
|
|
152
152
|
|
|
153
153
|
def _poll_read_key(self, read_key: str) -> Optional[str]:
|
|
154
154
|
"""Poll the read key endpoint until we get an access token."""
|
|
155
|
-
read_endpoint = f"{self.endpoint}/
|
|
155
|
+
read_endpoint = f"{self.endpoint}/identity/bridge-token"
|
|
156
156
|
start_time = time.time()
|
|
157
157
|
|
|
158
158
|
while time.time() - start_time < self.poll_timeout:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
rapidata/__init__.py,sha256=
|
|
1
|
+
rapidata/__init__.py,sha256=0A-rK2cFy_EMgk4ttIgRtoG7B_9uJ317yYEdrmgpP-k,812
|
|
2
2
|
rapidata/api_client/__init__.py,sha256=OKVtwJHhPEDMHcdwyS0T5ly3puaJL8jr3X6xUH48cSY,28120
|
|
3
3
|
rapidata/api_client/api/__init__.py,sha256=Dv6v1tCJS4BLVM5BN9k5iRMNMyglhqZ4n8vyoqkLZZw,1292
|
|
4
4
|
rapidata/api_client/api/campaign_api.py,sha256=1ajX0hSnA4O5GacJLIGkAgorPlNDRVaEZY029Pkutl4,71353
|
|
@@ -465,12 +465,12 @@ rapidata/rapidata_client/filter/models/gender.py,sha256=aXg6Kql2BIy8d5d1lCVi1axM
|
|
|
465
465
|
rapidata/rapidata_client/filter/new_user_filter.py,sha256=qU7d6cSslGEO_N1tYPS4Ru3cGbQYH2_I5dJPNPHvtCM,369
|
|
466
466
|
rapidata/rapidata_client/filter/not_filter.py,sha256=I7crEyOCs53uS0VI48s9EqC6PAFfV9EZG3upwFBJwZo,1189
|
|
467
467
|
rapidata/rapidata_client/filter/or_filter.py,sha256=u6vkXMTG_j15SbY3bkbnXbxJMDgEsH5rdoFLbuoLQmo,1345
|
|
468
|
-
rapidata/rapidata_client/filter/rapidata_filters.py,sha256=
|
|
468
|
+
rapidata/rapidata_client/filter/rapidata_filters.py,sha256=aHl8bjvL0wJLhzm6BCHy7mPGYYYKTLZhY0WZVeHx0ZA,2014
|
|
469
469
|
rapidata/rapidata_client/filter/response_count_filter.py,sha256=sDv9Dvy0FbnIQRSAxFGrUf9SIMISTNxnlAQcrFKBjXE,1989
|
|
470
470
|
rapidata/rapidata_client/filter/user_score_filter.py,sha256=2C78zkWm5TnfkxGbV1ER2xB7s9ynpacaibzyRZKG8Cc,1566
|
|
471
471
|
rapidata/rapidata_client/logging/__init__.py,sha256=4gLxePW8TvgYDZmPWMcf6fA8bEyu35vMKOmlPj5oXNE,110
|
|
472
|
-
rapidata/rapidata_client/logging/logger.py,sha256=
|
|
473
|
-
rapidata/rapidata_client/logging/output_manager.py,sha256=
|
|
472
|
+
rapidata/rapidata_client/logging/logger.py,sha256=9vULXUizGObQeqMY-CryiAQsq8xDZw0ChLhvV8oa99s,3907
|
|
473
|
+
rapidata/rapidata_client/logging/output_manager.py,sha256=AmSVZ2emVW5UWgOiNqkXNVRItsvd5Ox0hsIoZQhYYYo,653
|
|
474
474
|
rapidata/rapidata_client/metadata/__init__.py,sha256=G_mnLo2q4S_V9BjTCTJVNZZqnmwU6OaHNkuxNSNnRQA,302
|
|
475
475
|
rapidata/rapidata_client/metadata/_base_metadata.py,sha256=t2kFqaz5BkEaYYj93Pw3h7zWVDq_S5ZkDxjDIRd21_I,189
|
|
476
476
|
rapidata/rapidata_client/metadata/_media_asset_metadata.py,sha256=muyWV9QAdz_8s6N0Zp8qzqDXiNI0N54HS-3K5hDRG5c,529
|
|
@@ -482,7 +482,7 @@ rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
|
482
482
|
rapidata/rapidata_client/order/_rapidata_dataset.py,sha256=JVGsiBa_BL0E7UZOHZ4uABr1jDVpbTiAQFO9pF2isVA,18891
|
|
483
483
|
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=x-2lpW6Jwlq-9XRz91beWNv2TgdEA-q4b_RhOSr7vhQ,14405
|
|
484
484
|
rapidata/rapidata_client/order/rapidata_order.py,sha256=s-UslcdNqhVgZc38cFXFuJMXsRbMHgXOB7XO4dYQzd0,12476
|
|
485
|
-
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=
|
|
485
|
+
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=6UmqD8k8Q0M4_w1G-Jzn1LNFokC3o43LQNdiKSbW2f0,38291
|
|
486
486
|
rapidata/rapidata_client/order/rapidata_results.py,sha256=UllYpuqpm2inKdRNhClaUwApuxsMLrvrGDsrHA5KqbY,8111
|
|
487
487
|
rapidata/rapidata_client/rapidata_client.py,sha256=iAycSS8Dyt0_xnILpU5N9DoeGlB3v2UtlinmxcFh-eo,4029
|
|
488
488
|
rapidata/rapidata_client/referee/__init__.py,sha256=q0Hv9nmfEpyChejtyMLT8hWKL0vTTf_UgUXPYNJ-H6M,153
|
|
@@ -496,7 +496,7 @@ rapidata/rapidata_client/selection/capped_selection.py,sha256=iWhbM1LcayhgFm7oKA
|
|
|
496
496
|
rapidata/rapidata_client/selection/conditional_validation_selection.py,sha256=OcNYSBi19vIcy2bLDmj9cv-gg5LFSvdjc3tooV0Z7Oc,2842
|
|
497
497
|
rapidata/rapidata_client/selection/demographic_selection.py,sha256=l4vnNbzlf9ED6BKqN4k5cZXShkXu9L1C5DtO78Vwr5M,1454
|
|
498
498
|
rapidata/rapidata_client/selection/labeling_selection.py,sha256=0X8DJHgwvgwekEbzVxWPyzZ1QAPcULZNDjfLQYUlcLM,1348
|
|
499
|
-
rapidata/rapidata_client/selection/rapidata_selections.py,sha256=
|
|
499
|
+
rapidata/rapidata_client/selection/rapidata_selections.py,sha256=lgwRivdzSnCri3K-Z-ngqR5RXwTl7iYuKTRpuyl5UMY,1853
|
|
500
500
|
rapidata/rapidata_client/selection/retrieval_modes.py,sha256=J2jzPEJ4wdllm_RnU_FYPh3eO3xeZS7QUk-NXgTB2u4,668
|
|
501
501
|
rapidata/rapidata_client/selection/shuffling_selection.py,sha256=FzOp7mnBLxNzM5at_-935wd77IHyWnFR1f8uqokiMOg,1201
|
|
502
502
|
rapidata/rapidata_client/selection/static_selection.py,sha256=-RWD3ChPe7-J31Shmah9JBNCgc5a16C5NOUl1f8tZCM,680
|
|
@@ -510,7 +510,7 @@ rapidata/rapidata_client/settings/models/__init__.py,sha256=IW7OuWg7xWIwFYrMAOX5
|
|
|
510
510
|
rapidata/rapidata_client/settings/models/translation_behaviour_options.py,sha256=7eR_Tk_WouW2g466dXdwuDuYdSxSAeaVP4KR3mW9q7A,479
|
|
511
511
|
rapidata/rapidata_client/settings/no_shuffle.py,sha256=9LNx4LptHZsQxamNYeY6lz9uakefyzVWM09tr76yx18,684
|
|
512
512
|
rapidata/rapidata_client/settings/play_video_until_the_end.py,sha256=LLHx2_72k5ZqqG4opdlOS0HpiVmqbq0Inuxb5iVvrW8,747
|
|
513
|
-
rapidata/rapidata_client/settings/rapidata_settings.py,sha256=
|
|
513
|
+
rapidata/rapidata_client/settings/rapidata_settings.py,sha256=wXsF5VIJmD2gq7j86rGXp2ck1ucz9jh7UGJXAyMZ7AM,1594
|
|
514
514
|
rapidata/rapidata_client/settings/translation_behaviour.py,sha256=i9n_H0eKJyKW6m3MKH_Cm1XEKWVEWsAV_79xGmGIC-4,742
|
|
515
515
|
rapidata/rapidata_client/validation/__init__.py,sha256=s5wHVtcJkncXSFuL9I0zNwccNOKpWAqxqUjkeohzi2E,24
|
|
516
516
|
rapidata/rapidata_client/validation/rapidata_validation_set.py,sha256=PgsutRTpzJ_e_H-xJxibSKHTskcM43aNwnm9dFhpMpw,1812
|
|
@@ -518,7 +518,7 @@ rapidata/rapidata_client/validation/rapids/__init__.py,sha256=WU5PPwtTJlte6U90MD
|
|
|
518
518
|
rapidata/rapidata_client/validation/rapids/box.py,sha256=t3_Kn6doKXdnJdtbwefXnYKPiTKHneJl9E2inkDSqL8,589
|
|
519
519
|
rapidata/rapidata_client/validation/rapids/rapids.py,sha256=xcCPTTiWS-1TK_Bd0Qpt916dSdvEs3j6XeY_Xddo39k,4968
|
|
520
520
|
rapidata/rapidata_client/validation/rapids/rapids_manager.py,sha256=s5VAq8H5CKACWfmIQuz9kHC8t2nd-xEHGGUj9pIfXKI,14386
|
|
521
|
-
rapidata/rapidata_client/validation/validation_set_manager.py,sha256=
|
|
521
|
+
rapidata/rapidata_client/validation/validation_set_manager.py,sha256=jfVRM1Ofb2GuWxpvAA1oP1SNZSnKgKBldtAJYqMZm0k,29729
|
|
522
522
|
rapidata/rapidata_client/workflow/__init__.py,sha256=7nXcY91xkxjHudBc9H0fP35eBBtgwHGWTQKbb-M4h7Y,477
|
|
523
523
|
rapidata/rapidata_client/workflow/_base_workflow.py,sha256=XyIZFKS_RxAuwIHS848S3AyLEHqd07oTD_5jm2oUbsw,762
|
|
524
524
|
rapidata/rapidata_client/workflow/_classify_workflow.py,sha256=9bT54wxVJgxC-zLk6MVNbseFpzYrvFPjt7DHvxqYfnk,1736
|
|
@@ -531,10 +531,10 @@ rapidata/rapidata_client/workflow/_ranking_workflow.py,sha256=Qn15Y3BlrA735v5prO
|
|
|
531
531
|
rapidata/rapidata_client/workflow/_select_words_workflow.py,sha256=juTW4TPnnSeBWP3K2QfO092t0u1W8I1ksY6aAtPZOi0,1225
|
|
532
532
|
rapidata/rapidata_client/workflow/_timestamp_workflow.py,sha256=tPi2zu1-SlE_ppbGbMz6MM_2LUSWxM-GA0CZRlB0qFo,1176
|
|
533
533
|
rapidata/service/__init__.py,sha256=s9bS1AJZaWIhLtJX_ZA40_CK39rAAkwdAmymTMbeWl4,68
|
|
534
|
-
rapidata/service/credential_manager.py,sha256=
|
|
534
|
+
rapidata/service/credential_manager.py,sha256=pUEEtp6VrFWYhfUUtyqmS0AlRqe2Y0kFkY6o22IT4KM,8682
|
|
535
535
|
rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5AnfY14BW8,877
|
|
536
536
|
rapidata/service/openapi_service.py,sha256=J07TB4P3cz9KCU7k_fwuMQwGXlq_nJx_m1_xHbZoCg0,4867
|
|
537
|
-
rapidata-2.27.
|
|
538
|
-
rapidata-2.27.
|
|
539
|
-
rapidata-2.27.
|
|
540
|
-
rapidata-2.27.
|
|
537
|
+
rapidata-2.27.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
538
|
+
rapidata-2.27.2.dist-info/METADATA,sha256=4fmRjXH9vClT-pVf9oKi2CTcfZOodsOf8jRURZoKHTM,1268
|
|
539
|
+
rapidata-2.27.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
540
|
+
rapidata-2.27.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|