rapidata 2.37.0__py3-none-any.whl → 2.39.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.

Files changed (117) hide show
  1. rapidata/__init__.py +3 -4
  2. rapidata/api_client/__init__.py +4 -5
  3. rapidata/api_client/api/benchmark_api.py +289 -3
  4. rapidata/api_client/api/leaderboard_api.py +35 -1
  5. rapidata/api_client/api/participant_api.py +289 -3
  6. rapidata/api_client/api/validation_set_api.py +119 -400
  7. rapidata/api_client/models/__init__.py +4 -5
  8. rapidata/api_client/models/ab_test_selection_a_inner.py +1 -1
  9. rapidata/api_client/models/compare_workflow_model1.py +1 -8
  10. rapidata/api_client/models/conditional_validation_selection.py +4 -9
  11. rapidata/api_client/models/confidence_interval.py +98 -0
  12. rapidata/api_client/models/create_simple_pipeline_model_pipeline_steps_inner.py +8 -22
  13. rapidata/api_client/models/get_standing_by_id_result.py +7 -2
  14. rapidata/api_client/models/get_validation_set_by_id_result.py +4 -2
  15. rapidata/api_client/models/simple_workflow_model1.py +1 -8
  16. rapidata/api_client/models/standing_by_leaderboard.py +10 -4
  17. rapidata/api_client/models/update_benchmark_model.py +87 -0
  18. rapidata/api_client/models/update_participant_model.py +87 -0
  19. rapidata/api_client/models/update_validation_set_model.py +93 -0
  20. rapidata/api_client/models/validation_chance.py +20 -3
  21. rapidata/api_client/models/validation_set_model.py +5 -42
  22. rapidata/api_client_README.md +7 -7
  23. rapidata/rapidata_client/__init__.py +1 -4
  24. rapidata/rapidata_client/api/{rapidata_exception.py → rapidata_api_client.py} +119 -2
  25. rapidata/rapidata_client/benchmark/leaderboard/rapidata_leaderboard.py +88 -46
  26. rapidata/rapidata_client/benchmark/participant/_participant.py +26 -9
  27. rapidata/rapidata_client/benchmark/rapidata_benchmark.py +310 -210
  28. rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +134 -75
  29. rapidata/rapidata_client/config/__init__.py +3 -0
  30. rapidata/rapidata_client/config/logger.py +135 -0
  31. rapidata/rapidata_client/config/logging_config.py +58 -0
  32. rapidata/rapidata_client/config/managed_print.py +6 -0
  33. rapidata/rapidata_client/config/order_config.py +14 -0
  34. rapidata/rapidata_client/config/rapidata_config.py +15 -10
  35. rapidata/rapidata_client/config/tracer.py +130 -0
  36. rapidata/rapidata_client/config/upload_config.py +14 -0
  37. rapidata/rapidata_client/datapoints/_datapoint.py +1 -1
  38. rapidata/rapidata_client/datapoints/assets/__init__.py +1 -0
  39. rapidata/rapidata_client/datapoints/assets/_base_asset.py +2 -0
  40. rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
  41. rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
  42. rapidata/rapidata_client/datapoints/assets/_text_asset.py +2 -2
  43. rapidata/rapidata_client/datapoints/assets/data_type_enum.py +1 -1
  44. rapidata/rapidata_client/datapoints/metadata/_media_asset_metadata.py +9 -8
  45. rapidata/rapidata_client/datapoints/metadata/_prompt_metadata.py +1 -2
  46. rapidata/rapidata_client/demographic/demographic_manager.py +16 -14
  47. rapidata/rapidata_client/filter/_base_filter.py +11 -5
  48. rapidata/rapidata_client/filter/age_filter.py +9 -3
  49. rapidata/rapidata_client/filter/and_filter.py +20 -5
  50. rapidata/rapidata_client/filter/campaign_filter.py +7 -1
  51. rapidata/rapidata_client/filter/country_filter.py +8 -2
  52. rapidata/rapidata_client/filter/custom_filter.py +9 -3
  53. rapidata/rapidata_client/filter/gender_filter.py +9 -3
  54. rapidata/rapidata_client/filter/language_filter.py +12 -5
  55. rapidata/rapidata_client/filter/models/age_group.py +4 -4
  56. rapidata/rapidata_client/filter/models/gender.py +4 -2
  57. rapidata/rapidata_client/filter/new_user_filter.py +3 -4
  58. rapidata/rapidata_client/filter/not_filter.py +17 -5
  59. rapidata/rapidata_client/filter/or_filter.py +20 -5
  60. rapidata/rapidata_client/filter/rapidata_filters.py +12 -9
  61. rapidata/rapidata_client/filter/response_count_filter.py +6 -0
  62. rapidata/rapidata_client/filter/user_score_filter.py +17 -5
  63. rapidata/rapidata_client/order/_rapidata_dataset.py +45 -17
  64. rapidata/rapidata_client/order/_rapidata_order_builder.py +19 -13
  65. rapidata/rapidata_client/order/rapidata_order.py +60 -48
  66. rapidata/rapidata_client/order/rapidata_order_manager.py +231 -197
  67. rapidata/rapidata_client/order/rapidata_results.py +71 -57
  68. rapidata/rapidata_client/rapidata_client.py +36 -23
  69. rapidata/rapidata_client/referee/__init__.py +1 -1
  70. rapidata/rapidata_client/referee/_base_referee.py +3 -1
  71. rapidata/rapidata_client/referee/_early_stopping_referee.py +2 -2
  72. rapidata/rapidata_client/selection/_base_selection.py +6 -0
  73. rapidata/rapidata_client/selection/ab_test_selection.py +7 -3
  74. rapidata/rapidata_client/selection/capped_selection.py +2 -2
  75. rapidata/rapidata_client/selection/conditional_validation_selection.py +12 -6
  76. rapidata/rapidata_client/selection/demographic_selection.py +9 -6
  77. rapidata/rapidata_client/selection/rapidata_selections.py +11 -8
  78. rapidata/rapidata_client/selection/shuffling_selection.py +5 -5
  79. rapidata/rapidata_client/selection/static_selection.py +5 -10
  80. rapidata/rapidata_client/selection/validation_selection.py +9 -5
  81. rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
  82. rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
  83. rapidata/rapidata_client/settings/allow_neither_both.py +1 -0
  84. rapidata/rapidata_client/settings/custom_setting.py +3 -2
  85. rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
  86. rapidata/rapidata_client/settings/models/translation_behaviour_options.py +3 -2
  87. rapidata/rapidata_client/settings/no_shuffle.py +4 -2
  88. rapidata/rapidata_client/settings/play_video_until_the_end.py +7 -4
  89. rapidata/rapidata_client/settings/rapidata_settings.py +4 -3
  90. rapidata/rapidata_client/settings/translation_behaviour.py +7 -5
  91. rapidata/rapidata_client/validation/rapidata_validation_set.py +23 -17
  92. rapidata/rapidata_client/validation/rapids/box.py +3 -1
  93. rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
  94. rapidata/rapidata_client/validation/rapids/rapids_manager.py +174 -141
  95. rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
  96. rapidata/rapidata_client/workflow/__init__.py +1 -1
  97. rapidata/rapidata_client/workflow/_base_workflow.py +6 -1
  98. rapidata/rapidata_client/workflow/_classify_workflow.py +6 -0
  99. rapidata/rapidata_client/workflow/_compare_workflow.py +6 -0
  100. rapidata/rapidata_client/workflow/_draw_workflow.py +6 -0
  101. rapidata/rapidata_client/workflow/_evaluation_workflow.py +6 -0
  102. rapidata/rapidata_client/workflow/_free_text_workflow.py +6 -0
  103. rapidata/rapidata_client/workflow/_locate_workflow.py +6 -0
  104. rapidata/rapidata_client/workflow/_ranking_workflow.py +12 -0
  105. rapidata/rapidata_client/workflow/_select_words_workflow.py +6 -0
  106. rapidata/rapidata_client/workflow/_timestamp_workflow.py +6 -0
  107. rapidata/service/__init__.py +1 -1
  108. rapidata/service/credential_manager.py +1 -1
  109. rapidata/service/local_file_service.py +9 -8
  110. rapidata/service/openapi_service.py +2 -2
  111. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/METADATA +4 -1
  112. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/RECORD +114 -107
  113. rapidata/rapidata_client/logging/__init__.py +0 -2
  114. rapidata/rapidata_client/logging/logger.py +0 -122
  115. rapidata/rapidata_client/logging/output_manager.py +0 -20
  116. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/LICENSE +0 -0
  117. {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/WHEEL +0 -0
@@ -23,10 +23,11 @@ from rapidata.api_client.models.filter_operator import FilterOperator
23
23
 
24
24
  from rapidata.rapidata_client.validation.rapids.box import Box
25
25
 
26
- from rapidata.rapidata_client.logging import (
26
+ from rapidata.rapidata_client.config import (
27
27
  logger,
28
28
  managed_print,
29
- RapidataOutputManager,
29
+ rapidata_config,
30
+ tracer,
30
31
  )
31
32
  from tqdm import tqdm
32
33
  from rapidata.rapidata_client.workflow import Workflow
@@ -56,17 +57,20 @@ class ValidationSetManager:
56
57
  datapoints: list[Datapoint],
57
58
  settings: Sequence[RapidataSetting] | None = None,
58
59
  ) -> RapidataValidationSet:
59
- rapids: list[Rapid] = []
60
- for datapoint in datapoints:
61
- rapids.append(
62
- Rapid(
63
- asset=datapoint.asset,
64
- payload=workflow._to_payload(datapoint),
65
- metadata=datapoint.metadata,
66
- settings=settings,
60
+ with tracer.start_as_current_span(
61
+ "ValidationSetManager._create_order_validation_set"
62
+ ):
63
+ rapids: list[Rapid] = []
64
+ for datapoint in datapoints:
65
+ rapids.append(
66
+ Rapid(
67
+ asset=datapoint.asset,
68
+ payload=workflow._to_payload(datapoint),
69
+ metadata=datapoint.metadata,
70
+ settings=settings,
71
+ )
67
72
  )
68
- )
69
- return self._submit(name=order_name, rapids=rapids, dimensions=[])
73
+ return self._submit(name=order_name, rapids=rapids, dimensions=[])
70
74
 
71
75
  def create_classification_set(
72
76
  self,
@@ -111,50 +115,53 @@ class ValidationSetManager:
111
115
  ```
112
116
  This would mean: first datapoint correct answer is "yes", second datapoint is "no" or "maybe"
113
117
  """
114
- if not datapoints:
115
- raise ValueError("Datapoints cannot be empty")
118
+ with tracer.start_as_current_span(
119
+ "ValidationSetManager.create_classification_set"
120
+ ):
121
+ if not datapoints:
122
+ raise ValueError("Datapoints cannot be empty")
116
123
 
117
- if len(datapoints) != len(truths):
118
- raise ValueError("The number of datapoints and truths must be equal")
124
+ if len(datapoints) != len(truths):
125
+ raise ValueError("The number of datapoints and truths must be equal")
119
126
 
120
- if not all([isinstance(truth, (list, tuple)) for truth in truths]):
121
- raise ValueError("Truths must be a list of lists or tuples")
127
+ if not all([isinstance(truth, (list, tuple)) for truth in truths]):
128
+ raise ValueError("Truths must be a list of lists or tuples")
122
129
 
123
- if contexts and len(contexts) != len(datapoints):
124
- raise ValueError("The number of contexts and datapoints must be equal")
130
+ if contexts and len(contexts) != len(datapoints):
131
+ raise ValueError("The number of contexts and datapoints must be equal")
125
132
 
126
- if media_contexts and len(media_contexts) != len(datapoints):
127
- raise ValueError(
128
- "The number of media contexts and datapoints must be equal"
129
- )
133
+ if media_contexts and len(media_contexts) != len(datapoints):
134
+ raise ValueError(
135
+ "The number of media contexts and datapoints must be equal"
136
+ )
130
137
 
131
- if explanations and len(explanations) != len(datapoints):
132
- raise ValueError(
133
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
134
- )
138
+ if explanations and len(explanations) != len(datapoints):
139
+ raise ValueError(
140
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
141
+ )
135
142
 
136
- logger.debug("Creating classification rapids")
137
- rapids: list[Rapid] = []
138
- for i in range(len(datapoints)):
139
- rapid_metadata = []
140
- if contexts:
141
- rapid_metadata.append(PromptMetadata(contexts[i]))
142
- if media_contexts:
143
- rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
144
- rapids.append(
145
- self.rapid.classification_rapid(
146
- instruction=instruction,
147
- answer_options=answer_options,
148
- datapoint=datapoints[i],
149
- truths=truths[i],
150
- data_type=data_type,
151
- metadata=rapid_metadata,
152
- explanation=explanations[i] if explanations != None else None,
143
+ logger.debug("Creating classification rapids")
144
+ rapids: list[Rapid] = []
145
+ for i in range(len(datapoints)):
146
+ rapid_metadata = []
147
+ if contexts:
148
+ rapid_metadata.append(PromptMetadata(contexts[i]))
149
+ if media_contexts:
150
+ rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
151
+ rapids.append(
152
+ self.rapid.classification_rapid(
153
+ instruction=instruction,
154
+ answer_options=answer_options,
155
+ datapoint=datapoints[i],
156
+ truths=truths[i],
157
+ data_type=data_type,
158
+ metadata=rapid_metadata,
159
+ explanation=explanations[i] if explanations != None else None,
160
+ )
153
161
  )
154
- )
155
162
 
156
- logger.debug("Submitting classification rapids")
157
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
163
+ logger.debug("Submitting classification rapids")
164
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
158
165
 
159
166
  def create_compare_set(
160
167
  self,
@@ -198,49 +205,50 @@ class ValidationSetManager:
198
205
  ```
199
206
  This would mean: first comparison image1.jpg has a cat, second comparison image4.jpg has a cat
200
207
  """
201
- if not datapoints:
202
- raise ValueError("Datapoints cannot be empty")
208
+ with tracer.start_as_current_span("ValidationSetManager.create_compare_set"):
209
+ if not datapoints:
210
+ raise ValueError("Datapoints cannot be empty")
203
211
 
204
- if len(datapoints) != len(truths):
205
- raise ValueError("The number of datapoints and truths must be equal")
212
+ if len(datapoints) != len(truths):
213
+ raise ValueError("The number of datapoints and truths must be equal")
206
214
 
207
- if not all([isinstance(truth, str) for truth in truths]):
208
- raise ValueError("Truths must be a list of strings")
215
+ if not all([isinstance(truth, str) for truth in truths]):
216
+ raise ValueError("Truths must be a list of strings")
209
217
 
210
- if contexts and len(contexts) != len(datapoints):
211
- raise ValueError("The number of contexts and datapoints must be equal")
218
+ if contexts and len(contexts) != len(datapoints):
219
+ raise ValueError("The number of contexts and datapoints must be equal")
212
220
 
213
- if media_contexts and len(media_contexts) != len(datapoints):
214
- raise ValueError(
215
- "The number of media contexts and datapoints must be equal"
216
- )
221
+ if media_contexts and len(media_contexts) != len(datapoints):
222
+ raise ValueError(
223
+ "The number of media contexts and datapoints must be equal"
224
+ )
217
225
 
218
- if explanation and len(explanation) != len(datapoints):
219
- raise ValueError(
220
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
221
- )
226
+ if explanation and len(explanation) != len(datapoints):
227
+ raise ValueError(
228
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
229
+ )
222
230
 
223
- logger.debug("Creating comparison rapids")
224
- rapids: list[Rapid] = []
225
- for i in range(len(datapoints)):
226
- rapid_metadata = []
227
- if contexts:
228
- rapid_metadata.append(PromptMetadata(contexts[i]))
229
- if media_contexts:
230
- rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
231
- rapids.append(
232
- self.rapid.compare_rapid(
233
- instruction=instruction,
234
- truth=truths[i],
235
- datapoint=datapoints[i],
236
- data_type=data_type,
237
- metadata=rapid_metadata,
238
- explanation=explanation[i] if explanation != None else None,
231
+ logger.debug("Creating comparison rapids")
232
+ rapids: list[Rapid] = []
233
+ for i in range(len(datapoints)):
234
+ rapid_metadata = []
235
+ if contexts:
236
+ rapid_metadata.append(PromptMetadata(contexts[i]))
237
+ if media_contexts:
238
+ rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
239
+ rapids.append(
240
+ self.rapid.compare_rapid(
241
+ instruction=instruction,
242
+ truth=truths[i],
243
+ datapoint=datapoints[i],
244
+ data_type=data_type,
245
+ metadata=rapid_metadata,
246
+ explanation=explanation[i] if explanation != None else None,
247
+ )
239
248
  )
240
- )
241
249
 
242
- logger.debug("Submitting comparison rapids")
243
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
250
+ logger.debug("Submitting comparison rapids")
251
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
244
252
 
245
253
  def create_select_words_set(
246
254
  self,
@@ -280,39 +288,42 @@ class ValidationSetManager:
280
288
  ```
281
289
  This would mean: first datapoint the correct words are "this" and "example", second datapoint is "with"
282
290
  """
283
- if not datapoints:
284
- raise ValueError("Datapoints cannot be empty")
291
+ with tracer.start_as_current_span(
292
+ "ValidationSetManager.create_select_words_set"
293
+ ):
294
+ if not datapoints:
295
+ raise ValueError("Datapoints cannot be empty")
285
296
 
286
- if not all([isinstance(truth, (list, tuple)) for truth in truths]):
287
- raise ValueError("Truths must be a list of lists or tuples")
297
+ if not all([isinstance(truth, (list, tuple)) for truth in truths]):
298
+ raise ValueError("Truths must be a list of lists or tuples")
288
299
 
289
- if len(datapoints) != len(truths) or len(datapoints) != len(sentences):
290
- raise ValueError(
291
- "The number of datapoints, truths, and sentences must be equal"
292
- )
300
+ if len(datapoints) != len(truths) or len(datapoints) != len(sentences):
301
+ raise ValueError(
302
+ "The number of datapoints, truths, and sentences must be equal"
303
+ )
293
304
 
294
- if explanation and len(explanation) != len(datapoints):
295
- raise ValueError(
296
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
297
- )
305
+ if explanation and len(explanation) != len(datapoints):
306
+ raise ValueError(
307
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
308
+ )
298
309
 
299
- logger.debug("Creating select words rapids")
300
- rapids: list[Rapid] = []
301
- for i in range(len(datapoints)):
302
- rapids.append(
303
- self.rapid.select_words_rapid(
304
- instruction=instruction,
305
- truths=truths[i],
306
- datapoint=datapoints[i],
307
- sentence=sentences[i],
308
- required_precision=required_precision,
309
- required_completeness=required_completeness,
310
- explanation=explanation[i] if explanation != None else None,
310
+ logger.debug("Creating select words rapids")
311
+ rapids: list[Rapid] = []
312
+ for i in range(len(datapoints)):
313
+ rapids.append(
314
+ self.rapid.select_words_rapid(
315
+ instruction=instruction,
316
+ truths=truths[i],
317
+ datapoint=datapoints[i],
318
+ sentence=sentences[i],
319
+ required_precision=required_precision,
320
+ required_completeness=required_completeness,
321
+ explanation=explanation[i] if explanation != None else None,
322
+ )
311
323
  )
312
- )
313
324
 
314
- logger.debug("Submitting select words rapids")
315
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
325
+ logger.debug("Submitting select words rapids")
326
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
316
327
 
317
328
  def create_locate_set(
318
329
  self,
@@ -349,49 +360,50 @@ class ValidationSetManager:
349
360
  ```
350
361
  This would mean: first datapoint the object is in the top left corner, second datapoint the object is in the center
351
362
  """
352
- if not datapoints:
353
- raise ValueError("Datapoints cannot be empty")
363
+ with tracer.start_as_current_span("ValidationSetManager.create_locate_set"):
364
+ if not datapoints:
365
+ raise ValueError("Datapoints cannot be empty")
354
366
 
355
- if len(datapoints) != len(truths):
356
- raise ValueError("The number of datapoints and truths must be equal")
367
+ if len(datapoints) != len(truths):
368
+ raise ValueError("The number of datapoints and truths must be equal")
357
369
 
358
- if not all([isinstance(truth, (list, tuple)) for truth in truths]):
359
- raise ValueError("Truths must be a list of lists or tuples")
370
+ if not all([isinstance(truth, (list, tuple)) for truth in truths]):
371
+ raise ValueError("Truths must be a list of lists or tuples")
360
372
 
361
- if contexts and len(contexts) != len(datapoints):
362
- raise ValueError("The number of contexts and datapoints must be equal")
373
+ if contexts and len(contexts) != len(datapoints):
374
+ raise ValueError("The number of contexts and datapoints must be equal")
363
375
 
364
- if media_contexts and len(media_contexts) != len(datapoints):
365
- raise ValueError(
366
- "The number of media contexts and datapoints must be equal"
367
- )
376
+ if media_contexts and len(media_contexts) != len(datapoints):
377
+ raise ValueError(
378
+ "The number of media contexts and datapoints must be equal"
379
+ )
368
380
 
369
- if explanation and len(explanation) != len(datapoints):
370
- raise ValueError(
371
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
372
- )
381
+ if explanation and len(explanation) != len(datapoints):
382
+ raise ValueError(
383
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
384
+ )
373
385
 
374
- logger.debug("Creating locate rapids")
375
- rapids = []
376
- rapids: list[Rapid] = []
377
- for i in range(len(datapoints)):
378
- rapid_metadata = []
379
- if contexts:
380
- rapid_metadata.append(PromptMetadata(contexts[i]))
381
- if media_contexts:
382
- rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
383
- rapids.append(
384
- self.rapid.locate_rapid(
385
- instruction=instruction,
386
- truths=truths[i],
387
- datapoint=datapoints[i],
388
- metadata=rapid_metadata,
389
- explanation=explanation[i] if explanation != None else None,
386
+ logger.debug("Creating locate rapids")
387
+ rapids = []
388
+ rapids: list[Rapid] = []
389
+ for i in range(len(datapoints)):
390
+ rapid_metadata = []
391
+ if contexts:
392
+ rapid_metadata.append(PromptMetadata(contexts[i]))
393
+ if media_contexts:
394
+ rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
395
+ rapids.append(
396
+ self.rapid.locate_rapid(
397
+ instruction=instruction,
398
+ truths=truths[i],
399
+ datapoint=datapoints[i],
400
+ metadata=rapid_metadata,
401
+ explanation=explanation[i] if explanation != None else None,
402
+ )
390
403
  )
391
- )
392
404
 
393
- logger.debug("Submitting locate rapids")
394
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
405
+ logger.debug("Submitting locate rapids")
406
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
395
407
 
396
408
  def create_draw_set(
397
409
  self,
@@ -428,48 +440,49 @@ class ValidationSetManager:
428
440
  ```
429
441
  This would mean: first datapoint the object is in the top left corner, second datapoint the object is in the center
430
442
  """
431
- if not datapoints:
432
- raise ValueError("Datapoints cannot be empty")
443
+ with tracer.start_as_current_span("ValidationSetManager.create_draw_set"):
444
+ if not datapoints:
445
+ raise ValueError("Datapoints cannot be empty")
433
446
 
434
- if len(datapoints) != len(truths):
435
- raise ValueError("The number of datapoints and truths must be equal")
447
+ if len(datapoints) != len(truths):
448
+ raise ValueError("The number of datapoints and truths must be equal")
436
449
 
437
- if not all([isinstance(truth, (list, tuple)) for truth in truths]):
438
- raise ValueError("Truths must be a list of lists or tuples")
450
+ if not all([isinstance(truth, (list, tuple)) for truth in truths]):
451
+ raise ValueError("Truths must be a list of lists or tuples")
439
452
 
440
- if contexts and len(contexts) != len(datapoints):
441
- raise ValueError("The number of contexts and datapoints must be equal")
453
+ if contexts and len(contexts) != len(datapoints):
454
+ raise ValueError("The number of contexts and datapoints must be equal")
442
455
 
443
- if media_contexts and len(media_contexts) != len(datapoints):
444
- raise ValueError(
445
- "The number of media contexts and datapoints must be equal"
446
- )
456
+ if media_contexts and len(media_contexts) != len(datapoints):
457
+ raise ValueError(
458
+ "The number of media contexts and datapoints must be equal"
459
+ )
447
460
 
448
- if explanation and len(explanation) != len(datapoints):
449
- raise ValueError(
450
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
451
- )
461
+ if explanation and len(explanation) != len(datapoints):
462
+ raise ValueError(
463
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
464
+ )
452
465
 
453
- logger.debug("Creating draw rapids")
454
- rapids: list[Rapid] = []
455
- for i in range(len(datapoints)):
456
- rapid_metadata = []
457
- if contexts:
458
- rapid_metadata.append(PromptMetadata(contexts[i]))
459
- if media_contexts:
460
- rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
461
- rapids.append(
462
- self.rapid.draw_rapid(
463
- instruction=instruction,
464
- truths=truths[i],
465
- datapoint=datapoints[i],
466
- metadata=rapid_metadata,
467
- explanation=explanation[i] if explanation != None else None,
466
+ logger.debug("Creating draw rapids")
467
+ rapids: list[Rapid] = []
468
+ for i in range(len(datapoints)):
469
+ rapid_metadata = []
470
+ if contexts:
471
+ rapid_metadata.append(PromptMetadata(contexts[i]))
472
+ if media_contexts:
473
+ rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
474
+ rapids.append(
475
+ self.rapid.draw_rapid(
476
+ instruction=instruction,
477
+ truths=truths[i],
478
+ datapoint=datapoints[i],
479
+ metadata=rapid_metadata,
480
+ explanation=explanation[i] if explanation != None else None,
481
+ )
468
482
  )
469
- )
470
483
 
471
- logger.debug("Submitting draw rapids")
472
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
484
+ logger.debug("Submitting draw rapids")
485
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
473
486
 
474
487
  def create_timestamp_set(
475
488
  self,
@@ -507,48 +520,49 @@ class ValidationSetManager:
507
520
  ```
508
521
  This would mean: first datapoint the correct interval is from 0 to 10, second datapoint the correct interval is from 20 to 30
509
522
  """
510
- if not datapoints:
511
- raise ValueError("Datapoints cannot be empty")
523
+ with tracer.start_as_current_span("ValidationSetManager.create_timestamp_set"):
524
+ if not datapoints:
525
+ raise ValueError("Datapoints cannot be empty")
512
526
 
513
- if len(datapoints) != len(truths):
514
- raise ValueError("The number of datapoints and truths must be equal")
527
+ if len(datapoints) != len(truths):
528
+ raise ValueError("The number of datapoints and truths must be equal")
515
529
 
516
- if not all([isinstance(truth, (list, tuple)) for truth in truths]):
517
- raise ValueError("Truths must be a list of lists or tuples")
530
+ if not all([isinstance(truth, (list, tuple)) for truth in truths]):
531
+ raise ValueError("Truths must be a list of lists or tuples")
518
532
 
519
- if contexts and len(contexts) != len(datapoints):
520
- raise ValueError("The number of contexts and datapoints must be equal")
533
+ if contexts and len(contexts) != len(datapoints):
534
+ raise ValueError("The number of contexts and datapoints must be equal")
521
535
 
522
- if media_contexts and len(media_contexts) != len(datapoints):
523
- raise ValueError(
524
- "The number of media contexts and datapoints must be equal"
525
- )
536
+ if media_contexts and len(media_contexts) != len(datapoints):
537
+ raise ValueError(
538
+ "The number of media contexts and datapoints must be equal"
539
+ )
526
540
 
527
- if explanation and len(explanation) != len(datapoints):
528
- raise ValueError(
529
- "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
530
- )
541
+ if explanation and len(explanation) != len(datapoints):
542
+ raise ValueError(
543
+ "The number of explanations and datapoints must be equal, the index must align, but can be padded with None"
544
+ )
531
545
 
532
- logger.debug("Creating timestamp rapids")
533
- rapids: list[Rapid] = []
534
- for i in range(len(datapoints)):
535
- rapid_metadata = []
536
- if contexts:
537
- rapid_metadata.append(PromptMetadata(contexts[i]))
538
- if media_contexts:
539
- rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
540
- rapids.append(
541
- self.rapid.timestamp_rapid(
542
- instruction=instruction,
543
- truths=truths[i],
544
- datapoint=datapoints[i],
545
- metadata=rapid_metadata,
546
- explanation=explanation[i] if explanation != None else None,
546
+ logger.debug("Creating timestamp rapids")
547
+ rapids: list[Rapid] = []
548
+ for i in range(len(datapoints)):
549
+ rapid_metadata = []
550
+ if contexts:
551
+ rapid_metadata.append(PromptMetadata(contexts[i]))
552
+ if media_contexts:
553
+ rapid_metadata.append(MediaAssetMetadata(media_contexts[i]))
554
+ rapids.append(
555
+ self.rapid.timestamp_rapid(
556
+ instruction=instruction,
557
+ truths=truths[i],
558
+ datapoint=datapoints[i],
559
+ metadata=rapid_metadata,
560
+ explanation=explanation[i] if explanation != None else None,
561
+ )
547
562
  )
548
- )
549
563
 
550
- logger.debug("Submitting timestamp rapids")
551
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
564
+ logger.debug("Submitting timestamp rapids")
565
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
552
566
 
553
567
  def create_mixed_set(
554
568
  self,
@@ -563,10 +577,11 @@ class ValidationSetManager:
563
577
  rapids (list[Rapid]): The list of rapids to add to the validation set.
564
578
  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.
565
579
  """
566
- if not rapids:
567
- raise ValueError("Rapids cannot be empty")
580
+ with tracer.start_as_current_span("ValidationSetManager.create_mixed_set"):
581
+ if not rapids:
582
+ raise ValueError("Rapids cannot be empty")
568
583
 
569
- return self._submit(name=name, rapids=rapids, dimensions=dimensions)
584
+ return self._submit(name=name, rapids=rapids, dimensions=dimensions)
570
585
 
571
586
  def _submit(
572
587
  self,
@@ -593,28 +608,28 @@ class ValidationSetManager:
593
608
  validation_set_id=validation_set_id,
594
609
  openapi_service=self.__openapi_service,
595
610
  )
596
-
597
- logger.debug("Adding rapids to validation set")
598
- failed_rapids = []
599
- for rapid in tqdm(
600
- rapids,
601
- desc="Uploading validation tasks",
602
- disable=RapidataOutputManager.silent_mode,
603
- ):
604
- try:
605
- validation_set.add_rapid(rapid)
606
- except Exception:
607
- failed_rapids.append(rapid.asset)
608
-
609
- if failed_rapids:
610
- logger.error(
611
- "Failed to add %s datapoints to validation set: %s",
612
- len(failed_rapids),
613
- failed_rapids,
614
- )
615
- raise RuntimeError(
616
- f"Failed to add {len(failed_rapids)} datapoints to validation set: {failed_rapids}"
617
- )
611
+ with tracer.start_as_current_span("Adding rapids to validation set"):
612
+ logger.debug("Adding rapids to validation set")
613
+ failed_rapids = []
614
+ for rapid in tqdm(
615
+ rapids,
616
+ desc="Uploading validation tasks",
617
+ disable=rapidata_config.logging.silent_mode,
618
+ ):
619
+ try:
620
+ validation_set.add_rapid(rapid)
621
+ except Exception:
622
+ failed_rapids.append(rapid.asset)
623
+
624
+ if failed_rapids:
625
+ logger.error(
626
+ "Failed to add %s datapoints to validation set: %s",
627
+ len(failed_rapids),
628
+ failed_rapids,
629
+ )
630
+ raise RuntimeError(
631
+ f"Failed to add {len(failed_rapids)} datapoints to validation set: {failed_rapids}"
632
+ )
618
633
 
619
634
  managed_print()
620
635
  managed_print(
@@ -638,15 +653,16 @@ class ValidationSetManager:
638
653
  RapidataValidationSet: The ValidationSet instance.
639
654
  """
640
655
 
641
- validation_set = (
642
- self.__openapi_service.validation_api.validation_set_validation_set_id_get(
656
+ with tracer.start_as_current_span(
657
+ "ValidationSetManager.get_validation_set_by_id"
658
+ ):
659
+ validation_set = self.__openapi_service.validation_api.validation_set_validation_set_id_get(
643
660
  validation_set_id=validation_set_id
644
661
  )
645
- )
646
662
 
647
- return RapidataValidationSet(
648
- validation_set_id, str(validation_set.name), self.__openapi_service
649
- )
663
+ return RapidataValidationSet(
664
+ validation_set_id, str(validation_set.name), self.__openapi_service
665
+ )
650
666
 
651
667
  def find_validation_sets(
652
668
  self, name: str = "", amount: int = 1
@@ -660,31 +676,32 @@ class ValidationSetManager:
660
676
  Returns:
661
677
  list[RapidataValidationSet]: The list of validation sets.
662
678
  """
663
-
664
- validation_page_result = (
665
- self.__openapi_service.validation_api.validation_sets_get(
666
- QueryModel(
667
- page=PageInfo(index=1, size=amount),
668
- filter=RootFilter(
669
- filters=[
670
- Filter(
671
- field="Name",
672
- operator=FilterOperator.CONTAINS,
673
- value=name,
679
+ with tracer.start_as_current_span("ValidationSetManager.find_validation_sets"):
680
+
681
+ validation_page_result = (
682
+ self.__openapi_service.validation_api.validation_sets_get(
683
+ QueryModel(
684
+ page=PageInfo(index=1, size=amount),
685
+ filter=RootFilter(
686
+ filters=[
687
+ Filter(
688
+ field="Name",
689
+ operator=FilterOperator.CONTAINS,
690
+ value=name,
691
+ )
692
+ ]
693
+ ),
694
+ sortCriteria=[
695
+ SortCriterion(
696
+ direction=SortDirection.DESC, propertyName="CreatedAt"
674
697
  )
675
- ]
676
- ),
677
- sortCriteria=[
678
- SortCriterion(
679
- direction=SortDirection.DESC, propertyName="CreatedAt"
680
- )
681
- ],
698
+ ],
699
+ )
682
700
  )
683
701
  )
684
- )
685
702
 
686
- validation_sets = [
687
- self.get_validation_set_by_id(str(validation_set.id))
688
- for validation_set in validation_page_result.items
689
- ]
690
- return validation_sets
703
+ validation_sets = [
704
+ self.get_validation_set_by_id(str(validation_set.id))
705
+ for validation_set in validation_page_result.items
706
+ ]
707
+ return validation_sets