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.
- rapidata/__init__.py +3 -4
- rapidata/api_client/__init__.py +4 -5
- rapidata/api_client/api/benchmark_api.py +289 -3
- rapidata/api_client/api/leaderboard_api.py +35 -1
- rapidata/api_client/api/participant_api.py +289 -3
- rapidata/api_client/api/validation_set_api.py +119 -400
- rapidata/api_client/models/__init__.py +4 -5
- rapidata/api_client/models/ab_test_selection_a_inner.py +1 -1
- rapidata/api_client/models/compare_workflow_model1.py +1 -8
- rapidata/api_client/models/conditional_validation_selection.py +4 -9
- rapidata/api_client/models/confidence_interval.py +98 -0
- rapidata/api_client/models/create_simple_pipeline_model_pipeline_steps_inner.py +8 -22
- rapidata/api_client/models/get_standing_by_id_result.py +7 -2
- rapidata/api_client/models/get_validation_set_by_id_result.py +4 -2
- rapidata/api_client/models/simple_workflow_model1.py +1 -8
- rapidata/api_client/models/standing_by_leaderboard.py +10 -4
- rapidata/api_client/models/update_benchmark_model.py +87 -0
- rapidata/api_client/models/update_participant_model.py +87 -0
- rapidata/api_client/models/update_validation_set_model.py +93 -0
- rapidata/api_client/models/validation_chance.py +20 -3
- rapidata/api_client/models/validation_set_model.py +5 -42
- rapidata/api_client_README.md +7 -7
- 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 +310 -210
- rapidata/rapidata_client/benchmark/rapidata_benchmark_manager.py +134 -75
- 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 +15 -10
- 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/__init__.py +1 -0
- rapidata/rapidata_client/datapoints/assets/_base_asset.py +2 -0
- rapidata/rapidata_client/datapoints/assets/_media_asset.py +1 -1
- rapidata/rapidata_client/datapoints/assets/_sessions.py +2 -2
- rapidata/rapidata_client/datapoints/assets/_text_asset.py +2 -2
- rapidata/rapidata_client/datapoints/assets/data_type_enum.py +1 -1
- rapidata/rapidata_client/datapoints/metadata/_media_asset_metadata.py +9 -8
- rapidata/rapidata_client/datapoints/metadata/_prompt_metadata.py +1 -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/models/age_group.py +4 -4
- rapidata/rapidata_client/filter/models/gender.py +4 -2
- 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/rapidata_filters.py +12 -9
- 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/referee/__init__.py +1 -1
- rapidata/rapidata_client/referee/_base_referee.py +3 -1
- rapidata/rapidata_client/referee/_early_stopping_referee.py +2 -2
- rapidata/rapidata_client/selection/_base_selection.py +6 -0
- rapidata/rapidata_client/selection/ab_test_selection.py +7 -3
- rapidata/rapidata_client/selection/capped_selection.py +2 -2
- rapidata/rapidata_client/selection/conditional_validation_selection.py +12 -6
- rapidata/rapidata_client/selection/demographic_selection.py +9 -6
- rapidata/rapidata_client/selection/rapidata_selections.py +11 -8
- rapidata/rapidata_client/selection/shuffling_selection.py +5 -5
- rapidata/rapidata_client/selection/static_selection.py +5 -10
- rapidata/rapidata_client/selection/validation_selection.py +9 -5
- rapidata/rapidata_client/settings/_rapidata_setting.py +8 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +8 -5
- rapidata/rapidata_client/settings/allow_neither_both.py +1 -0
- rapidata/rapidata_client/settings/custom_setting.py +3 -2
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +9 -4
- rapidata/rapidata_client/settings/models/translation_behaviour_options.py +3 -2
- rapidata/rapidata_client/settings/no_shuffle.py +4 -2
- rapidata/rapidata_client/settings/play_video_until_the_end.py +7 -4
- rapidata/rapidata_client/settings/rapidata_settings.py +4 -3
- rapidata/rapidata_client/settings/translation_behaviour.py +7 -5
- rapidata/rapidata_client/validation/rapidata_validation_set.py +23 -17
- rapidata/rapidata_client/validation/rapids/box.py +3 -1
- rapidata/rapidata_client/validation/rapids/rapids.py +7 -1
- rapidata/rapidata_client/validation/rapids/rapids_manager.py +174 -141
- rapidata/rapidata_client/validation/validation_set_manager.py +285 -268
- rapidata/rapidata_client/workflow/__init__.py +1 -1
- 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/__init__.py +1 -1
- rapidata/service/credential_manager.py +1 -1
- rapidata/service/local_file_service.py +9 -8
- rapidata/service/openapi_service.py +2 -2
- {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/METADATA +4 -1
- {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/RECORD +114 -107
- 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.39.0.dist-info}/LICENSE +0 -0
- {rapidata-2.37.0.dist-info → rapidata-2.39.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Rapidata.Dataset
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: v1
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
import pprint
|
|
17
|
+
import re # noqa: F401
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
22
|
+
from typing import Optional, Set
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
class UpdateValidationSetModel(BaseModel):
|
|
26
|
+
"""
|
|
27
|
+
Allows for specific updates to a validation set without needing to provide all properties.
|
|
28
|
+
""" # noqa: E501
|
|
29
|
+
name: Optional[StrictStr] = None
|
|
30
|
+
dimensions: Optional[List[StrictStr]] = None
|
|
31
|
+
should_alert: Optional[StrictBool] = Field(default=None, alias="shouldAlert")
|
|
32
|
+
is_public: Optional[StrictBool] = Field(default=None, alias="isPublic")
|
|
33
|
+
__properties: ClassVar[List[str]] = ["name", "dimensions", "shouldAlert", "isPublic"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
populate_by_name=True,
|
|
37
|
+
validate_assignment=True,
|
|
38
|
+
protected_namespaces=(),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def to_str(self) -> str:
|
|
43
|
+
"""Returns the string representation of the model using alias"""
|
|
44
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
45
|
+
|
|
46
|
+
def to_json(self) -> str:
|
|
47
|
+
"""Returns the JSON representation of the model using alias"""
|
|
48
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
49
|
+
return json.dumps(self.to_dict())
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
53
|
+
"""Create an instance of UpdateValidationSetModel from a JSON string"""
|
|
54
|
+
return cls.from_dict(json.loads(json_str))
|
|
55
|
+
|
|
56
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
57
|
+
"""Return the dictionary representation of the model using alias.
|
|
58
|
+
|
|
59
|
+
This has the following differences from calling pydantic's
|
|
60
|
+
`self.model_dump(by_alias=True)`:
|
|
61
|
+
|
|
62
|
+
* `None` is only added to the output dict for nullable fields that
|
|
63
|
+
were set at model initialization. Other fields with value `None`
|
|
64
|
+
are ignored.
|
|
65
|
+
"""
|
|
66
|
+
excluded_fields: Set[str] = set([
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
_dict = self.model_dump(
|
|
70
|
+
by_alias=True,
|
|
71
|
+
exclude=excluded_fields,
|
|
72
|
+
exclude_none=True,
|
|
73
|
+
)
|
|
74
|
+
return _dict
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
78
|
+
"""Create an instance of UpdateValidationSetModel from a dict"""
|
|
79
|
+
if obj is None:
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
if not isinstance(obj, dict):
|
|
83
|
+
return cls.model_validate(obj)
|
|
84
|
+
|
|
85
|
+
_obj = cls.model_validate({
|
|
86
|
+
"name": obj.get("name"),
|
|
87
|
+
"dimensions": obj.get("dimensions"),
|
|
88
|
+
"shouldAlert": obj.get("shouldAlert"),
|
|
89
|
+
"isPublic": obj.get("isPublic")
|
|
90
|
+
})
|
|
91
|
+
return _obj
|
|
92
|
+
|
|
93
|
+
|
|
@@ -18,7 +18,7 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
|
|
21
|
-
from typing import Any, ClassVar, Dict, List, Union
|
|
21
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
|
22
22
|
from typing import Optional, Set
|
|
23
23
|
from typing_extensions import Self
|
|
24
24
|
|
|
@@ -29,7 +29,8 @@ class ValidationChance(BaseModel):
|
|
|
29
29
|
user_score_threshold: Union[StrictFloat, StrictInt] = Field(alias="userScoreThreshold")
|
|
30
30
|
chance: Union[StrictFloat, StrictInt]
|
|
31
31
|
rapid_count: StrictInt = Field(alias="rapidCount")
|
|
32
|
-
|
|
32
|
+
selections: Optional[List[AbTestSelectionAInner]] = None
|
|
33
|
+
__properties: ClassVar[List[str]] = ["userScoreThreshold", "chance", "rapidCount", "selections"]
|
|
33
34
|
|
|
34
35
|
model_config = ConfigDict(
|
|
35
36
|
populate_by_name=True,
|
|
@@ -70,6 +71,18 @@ class ValidationChance(BaseModel):
|
|
|
70
71
|
exclude=excluded_fields,
|
|
71
72
|
exclude_none=True,
|
|
72
73
|
)
|
|
74
|
+
# override the default output from pydantic by calling `to_dict()` of each item in selections (list)
|
|
75
|
+
_items = []
|
|
76
|
+
if self.selections:
|
|
77
|
+
for _item_selections in self.selections:
|
|
78
|
+
if _item_selections:
|
|
79
|
+
_items.append(_item_selections.to_dict())
|
|
80
|
+
_dict['selections'] = _items
|
|
81
|
+
# set to None if selections (nullable) is None
|
|
82
|
+
# and model_fields_set contains the field
|
|
83
|
+
if self.selections is None and "selections" in self.model_fields_set:
|
|
84
|
+
_dict['selections'] = None
|
|
85
|
+
|
|
73
86
|
return _dict
|
|
74
87
|
|
|
75
88
|
@classmethod
|
|
@@ -84,8 +97,12 @@ class ValidationChance(BaseModel):
|
|
|
84
97
|
_obj = cls.model_validate({
|
|
85
98
|
"userScoreThreshold": obj.get("userScoreThreshold"),
|
|
86
99
|
"chance": obj.get("chance"),
|
|
87
|
-
"rapidCount": obj.get("rapidCount")
|
|
100
|
+
"rapidCount": obj.get("rapidCount"),
|
|
101
|
+
"selections": [AbTestSelectionAInner.from_dict(_item) for _item in obj["selections"]] if obj.get("selections") is not None else None
|
|
88
102
|
})
|
|
89
103
|
return _obj
|
|
90
104
|
|
|
105
|
+
from rapidata.api_client.models.ab_test_selection_a_inner import AbTestSelectionAInner
|
|
106
|
+
# TODO: Rewrite to not use raise_errors
|
|
107
|
+
ValidationChance.model_rebuild(raise_errors=False)
|
|
91
108
|
|
|
@@ -18,8 +18,8 @@ import re # noqa: F401
|
|
|
18
18
|
import json
|
|
19
19
|
|
|
20
20
|
from datetime import datetime
|
|
21
|
-
from pydantic import BaseModel, ConfigDict, Field,
|
|
22
|
-
from typing import Any, ClassVar, Dict, List
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
23
|
from typing import Optional, Set
|
|
24
24
|
from typing_extensions import Self
|
|
25
25
|
|
|
@@ -29,46 +29,11 @@ class ValidationSetModel(BaseModel):
|
|
|
29
29
|
""" # noqa: E501
|
|
30
30
|
id: StrictStr
|
|
31
31
|
name: StrictStr
|
|
32
|
-
|
|
33
|
-
modality: Optional[List[StrictStr]] = None
|
|
34
|
-
prompt_type: Optional[List[StrictStr]] = Field(default=None, alias="promptType")
|
|
32
|
+
is_public: StrictBool = Field(alias="isPublic")
|
|
35
33
|
owner_id: StrictStr = Field(alias="ownerId")
|
|
36
34
|
owner_mail: StrictStr = Field(alias="ownerMail")
|
|
37
35
|
created_at: datetime = Field(alias="createdAt")
|
|
38
|
-
__properties: ClassVar[List[str]] = ["id", "name", "
|
|
39
|
-
|
|
40
|
-
@field_validator('asset_type')
|
|
41
|
-
def asset_type_validate_enum(cls, value):
|
|
42
|
-
"""Validates the enum"""
|
|
43
|
-
if value is None:
|
|
44
|
-
return value
|
|
45
|
-
|
|
46
|
-
for i in value:
|
|
47
|
-
if i not in set(['None', 'Image', 'Video', 'Audio', 'Text']):
|
|
48
|
-
raise ValueError("each list item must be one of ('None', 'Image', 'Video', 'Audio', 'Text')")
|
|
49
|
-
return value
|
|
50
|
-
|
|
51
|
-
@field_validator('modality')
|
|
52
|
-
def modality_validate_enum(cls, value):
|
|
53
|
-
"""Validates the enum"""
|
|
54
|
-
if value is None:
|
|
55
|
-
return value
|
|
56
|
-
|
|
57
|
-
for i in value:
|
|
58
|
-
if i not in set(['None', 'BoundingBox', 'Classify', 'Compare', 'FreeText', 'Line', 'Locate', 'NamedEntity', 'Polygon', 'Scrub', 'Transcription']):
|
|
59
|
-
raise ValueError("each list item must be one of ('None', 'BoundingBox', 'Classify', 'Compare', 'FreeText', 'Line', 'Locate', 'NamedEntity', 'Polygon', 'Scrub', 'Transcription')")
|
|
60
|
-
return value
|
|
61
|
-
|
|
62
|
-
@field_validator('prompt_type')
|
|
63
|
-
def prompt_type_validate_enum(cls, value):
|
|
64
|
-
"""Validates the enum"""
|
|
65
|
-
if value is None:
|
|
66
|
-
return value
|
|
67
|
-
|
|
68
|
-
for i in value:
|
|
69
|
-
if i not in set(['None', 'Text', 'Asset']):
|
|
70
|
-
raise ValueError("each list item must be one of ('None', 'Text', 'Asset')")
|
|
71
|
-
return value
|
|
36
|
+
__properties: ClassVar[List[str]] = ["id", "name", "isPublic", "ownerId", "ownerMail", "createdAt"]
|
|
72
37
|
|
|
73
38
|
model_config = ConfigDict(
|
|
74
39
|
populate_by_name=True,
|
|
@@ -123,9 +88,7 @@ class ValidationSetModel(BaseModel):
|
|
|
123
88
|
_obj = cls.model_validate({
|
|
124
89
|
"id": obj.get("id"),
|
|
125
90
|
"name": obj.get("name"),
|
|
126
|
-
"
|
|
127
|
-
"modality": obj.get("modality"),
|
|
128
|
-
"promptType": obj.get("promptType"),
|
|
91
|
+
"isPublic": obj.get("isPublic"),
|
|
129
92
|
"ownerId": obj.get("ownerId"),
|
|
130
93
|
"ownerMail": obj.get("ownerMail"),
|
|
131
94
|
"createdAt": obj.get("createdAt")
|
rapidata/api_client_README.md
CHANGED
|
@@ -79,6 +79,7 @@ Class | Method | HTTP request | Description
|
|
|
79
79
|
*BenchmarkApi* | [**benchmark_benchmark_id_participants_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participants_get) | **GET** /benchmark/{benchmarkId}/participants | Query all participants within a benchmark
|
|
80
80
|
*BenchmarkApi* | [**benchmark_benchmark_id_participants_participant_id_submit_post**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participants_participant_id_submit_post) | **POST** /benchmark/{benchmarkId}/participants/{participantId}/submit | Submits a participant to a benchmark.
|
|
81
81
|
*BenchmarkApi* | [**benchmark_benchmark_id_participants_post**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_participants_post) | **POST** /benchmark/{benchmarkId}/participants | Creates a participant in a benchmark.
|
|
82
|
+
*BenchmarkApi* | [**benchmark_benchmark_id_patch**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_patch) | **PATCH** /benchmark/{benchmarkId} | Updates a benchmark using patch semantics.
|
|
82
83
|
*BenchmarkApi* | [**benchmark_benchmark_id_prompt_post**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_prompt_post) | **POST** /benchmark/{benchmarkId}/prompt | Adds a new prompt to a benchmark.
|
|
83
84
|
*BenchmarkApi* | [**benchmark_benchmark_id_prompts_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_prompts_get) | **GET** /benchmark/{benchmarkId}/prompts | Returns the paged prompts of a benchmark by its ID.
|
|
84
85
|
*BenchmarkApi* | [**benchmark_benchmark_id_samples_identifier_get**](rapidata/api_client/docs/BenchmarkApi.md#benchmark_benchmark_id_samples_identifier_get) | **GET** /benchmark/{benchmarkId}/samples/{identifier} | Returns the paged prompts of a benchmark by its ID.
|
|
@@ -170,6 +171,7 @@ Class | Method | HTTP request | Description
|
|
|
170
171
|
*ParticipantApi* | [**participant_participant_id_disable_post**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_disable_post) | **POST** /participant/{participantId}/disable | This endpoint disables a participant in a benchmark. this means that the participant will no longer actively be matched up against other participants and not collect further results. It will still be visible in the leaderboard.
|
|
171
172
|
*ParticipantApi* | [**participant_participant_id_get**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_get) | **GET** /participant/{participantId} | Gets a participant by it's Id.
|
|
172
173
|
*ParticipantApi* | [**participant_participant_id_name_put**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_name_put) | **PUT** /participant/{participantId}/name | Updates the name of a participant
|
|
174
|
+
*ParticipantApi* | [**participant_participant_id_patch**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_patch) | **PATCH** /participant/{participantId} | Updates a participant using patch semantics.
|
|
173
175
|
*ParticipantApi* | [**participant_participant_id_sample_post**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_sample_post) | **POST** /participant/{participantId}/sample | Adds a sample to a participant.
|
|
174
176
|
*ParticipantApi* | [**participant_participant_id_samples_get**](rapidata/api_client/docs/ParticipantApi.md#participant_participant_id_samples_get) | **GET** /participant/{participantId}/samples | Queries all samples of a participant.
|
|
175
177
|
*ParticipantApi* | [**participant_sample_sample_id_delete**](rapidata/api_client/docs/ParticipantApi.md#participant_sample_sample_id_delete) | **DELETE** /participant-sample/{sampleId} | Deletes a sample.
|
|
@@ -193,13 +195,12 @@ Class | Method | HTTP request | Description
|
|
|
193
195
|
*ValidationSetApi* | [**validation_set_recommended_get**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_recommended_get) | **GET** /validation-set/recommended | Gets a validation set that is available to the user and best matches the provided parameters.
|
|
194
196
|
*ValidationSetApi* | [**validation_set_validation_set_id_delete**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_delete) | **DELETE** /validation-set/{validationSetId} | Gets a validation set by the id.
|
|
195
197
|
*ValidationSetApi* | [**validation_set_validation_set_id_dimensions_patch**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_dimensions_patch) | **PATCH** /validation-set/{validationSetId}/dimensions | Updates the dimensions of all rapids within a validation set.
|
|
196
|
-
*ValidationSetApi* | [**validation_set_validation_set_id_dimensions_put**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_dimensions_put) | **PUT** /validation-set/{validationSetId}/dimensions | Updates the dimensions of all rapids within a validation set.
|
|
197
198
|
*ValidationSetApi* | [**validation_set_validation_set_id_export_get**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_export_get) | **GET** /validation-set/{validationSetId}/export | Exports all rapids of a validation-set to a file.
|
|
198
199
|
*ValidationSetApi* | [**validation_set_validation_set_id_get**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_get) | **GET** /validation-set/{validationSetId} | Gets a validation set by the id.
|
|
200
|
+
*ValidationSetApi* | [**validation_set_validation_set_id_patch**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_patch) | **PATCH** /validation-set/{validationSetId} | Updates different characteristics of a validation set.
|
|
199
201
|
*ValidationSetApi* | [**validation_set_validation_set_id_rapid_post**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_rapid_post) | **POST** /validation-set/{validationSetId}/rapid | Adds a new validation rapid to the specified validation set using files to create the assets.
|
|
200
202
|
*ValidationSetApi* | [**validation_set_validation_set_id_rapids_get**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_rapids_get) | **GET** /validation-set/{validationSetId}/rapids | Queries the validation rapids for a specific validation set.
|
|
201
203
|
*ValidationSetApi* | [**validation_set_validation_set_id_shouldalert_patch**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_shouldalert_patch) | **PATCH** /validation-set/{validationSetId}/shouldalert | Updates the dimensions of all rapids within a validation set.
|
|
202
|
-
*ValidationSetApi* | [**validation_set_validation_set_id_shouldalert_put**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_shouldalert_put) | **PUT** /validation-set/{validationSetId}/shouldalert | Updates the of all rapshouldAlert property of all rapids within a validation set.
|
|
203
204
|
*ValidationSetApi* | [**validation_set_validation_set_id_update_labeling_hints_post**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_update_labeling_hints_post) | **POST** /validation-set/{validationSetId}/update-labeling-hints | Refreshes the labeling hints for a validation set.
|
|
204
205
|
*ValidationSetApi* | [**validation_set_validation_set_id_visibility_patch**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_validation_set_id_visibility_patch) | **PATCH** /validation-set/{validationSetId}/visibility | Updates the visibility of a validation set.
|
|
205
206
|
*ValidationSetApi* | [**validation_set_zip_compare_post**](rapidata/api_client/docs/ValidationSetApi.md#validation_set_zip_compare_post) | **POST** /validation-set/zip/compare | Imports a compare validation set from a zip file.
|
|
@@ -257,7 +258,6 @@ Class | Method | HTTP request | Description
|
|
|
257
258
|
- [CappedSelection](rapidata/api_client/docs/CappedSelection.md)
|
|
258
259
|
- [ChangeBoostModel](rapidata/api_client/docs/ChangeBoostModel.md)
|
|
259
260
|
- [ClassificationMetadata](rapidata/api_client/docs/ClassificationMetadata.md)
|
|
260
|
-
- [ClassificationMetadataFilterConfig](rapidata/api_client/docs/ClassificationMetadataFilterConfig.md)
|
|
261
261
|
- [ClassificationMetadataModel](rapidata/api_client/docs/ClassificationMetadataModel.md)
|
|
262
262
|
- [ClassifyPayload](rapidata/api_client/docs/ClassifyPayload.md)
|
|
263
263
|
- [ClientModel](rapidata/api_client/docs/ClientModel.md)
|
|
@@ -282,8 +282,8 @@ Class | Method | HTTP request | Description
|
|
|
282
282
|
- [CompareWorkflowModelPairMakerConfig](rapidata/api_client/docs/CompareWorkflowModelPairMakerConfig.md)
|
|
283
283
|
- [ComparisonOperator](rapidata/api_client/docs/ComparisonOperator.md)
|
|
284
284
|
- [ConditionalValidationSelection](rapidata/api_client/docs/ConditionalValidationSelection.md)
|
|
285
|
+
- [ConfidenceInterval](rapidata/api_client/docs/ConfidenceInterval.md)
|
|
285
286
|
- [Coordinate](rapidata/api_client/docs/Coordinate.md)
|
|
286
|
-
- [CountClassificationMetadataFilterConfig](rapidata/api_client/docs/CountClassificationMetadataFilterConfig.md)
|
|
287
287
|
- [CountMetadata](rapidata/api_client/docs/CountMetadata.md)
|
|
288
288
|
- [CountMetadataModel](rapidata/api_client/docs/CountMetadataModel.md)
|
|
289
289
|
- [CountryFilter](rapidata/api_client/docs/CountryFilter.md)
|
|
@@ -427,7 +427,6 @@ Class | Method | HTTP request | Description
|
|
|
427
427
|
- [LocateRapidBlueprint](rapidata/api_client/docs/LocateRapidBlueprint.md)
|
|
428
428
|
- [LocateResult](rapidata/api_client/docs/LocateResult.md)
|
|
429
429
|
- [LocationMetadata](rapidata/api_client/docs/LocationMetadata.md)
|
|
430
|
-
- [LocationMetadataExistsFilterConfig](rapidata/api_client/docs/LocationMetadataExistsFilterConfig.md)
|
|
431
430
|
- [LocationMetadataModel](rapidata/api_client/docs/LocationMetadataModel.md)
|
|
432
431
|
- [LogicOperator](rapidata/api_client/docs/LogicOperator.md)
|
|
433
432
|
- [MultiAsset](rapidata/api_client/docs/MultiAsset.md)
|
|
@@ -577,6 +576,7 @@ Class | Method | HTTP request | Description
|
|
|
577
576
|
- [TranslatedPromptMetadataModel](rapidata/api_client/docs/TranslatedPromptMetadataModel.md)
|
|
578
577
|
- [TranslatedString](rapidata/api_client/docs/TranslatedString.md)
|
|
579
578
|
- [UnlockOrderResult](rapidata/api_client/docs/UnlockOrderResult.md)
|
|
579
|
+
- [UpdateBenchmarkModel](rapidata/api_client/docs/UpdateBenchmarkModel.md)
|
|
580
580
|
- [UpdateBenchmarkNameModel](rapidata/api_client/docs/UpdateBenchmarkNameModel.md)
|
|
581
581
|
- [UpdateDatasetNameModel](rapidata/api_client/docs/UpdateDatasetNameModel.md)
|
|
582
582
|
- [UpdateDimensionsModel](rapidata/api_client/docs/UpdateDimensionsModel.md)
|
|
@@ -584,11 +584,13 @@ Class | Method | HTTP request | Description
|
|
|
584
584
|
- [UpdateLeaderboardNameModel](rapidata/api_client/docs/UpdateLeaderboardNameModel.md)
|
|
585
585
|
- [UpdateLeaderboardResponseConfigModel](rapidata/api_client/docs/UpdateLeaderboardResponseConfigModel.md)
|
|
586
586
|
- [UpdateOrderNameModel](rapidata/api_client/docs/UpdateOrderNameModel.md)
|
|
587
|
+
- [UpdateParticipantModel](rapidata/api_client/docs/UpdateParticipantModel.md)
|
|
587
588
|
- [UpdateParticipantNameModel](rapidata/api_client/docs/UpdateParticipantNameModel.md)
|
|
588
589
|
- [UpdatePromptTagsModel](rapidata/api_client/docs/UpdatePromptTagsModel.md)
|
|
589
590
|
- [UpdateShouldAlertModel](rapidata/api_client/docs/UpdateShouldAlertModel.md)
|
|
590
591
|
- [UpdateValidationRapidModel](rapidata/api_client/docs/UpdateValidationRapidModel.md)
|
|
591
592
|
- [UpdateValidationRapidModelTruth](rapidata/api_client/docs/UpdateValidationRapidModelTruth.md)
|
|
593
|
+
- [UpdateValidationSetModel](rapidata/api_client/docs/UpdateValidationSetModel.md)
|
|
592
594
|
- [UploadCocoResult](rapidata/api_client/docs/UploadCocoResult.md)
|
|
593
595
|
- [UploadFromS3Result](rapidata/api_client/docs/UploadFromS3Result.md)
|
|
594
596
|
- [UrlAssetInput](rapidata/api_client/docs/UrlAssetInput.md)
|
|
@@ -609,8 +611,6 @@ Class | Method | HTTP request | Description
|
|
|
609
611
|
- [WorkflowConfigArtifactModel](rapidata/api_client/docs/WorkflowConfigArtifactModel.md)
|
|
610
612
|
- [WorkflowConfigArtifactModelWorkflowConfig](rapidata/api_client/docs/WorkflowConfigArtifactModelWorkflowConfig.md)
|
|
611
613
|
- [WorkflowLabelingStepModel](rapidata/api_client/docs/WorkflowLabelingStepModel.md)
|
|
612
|
-
- [WorkflowSplitModel](rapidata/api_client/docs/WorkflowSplitModel.md)
|
|
613
|
-
- [WorkflowSplitModelFilterConfigsInner](rapidata/api_client/docs/WorkflowSplitModelFilterConfigsInner.md)
|
|
614
614
|
- [WorkflowState](rapidata/api_client/docs/WorkflowState.md)
|
|
615
615
|
- [ZipEntryFileWrapper](rapidata/api_client/docs/ZipEntryFileWrapper.md)
|
|
616
616
|
|
|
@@ -43,9 +43,6 @@ from .filter import (
|
|
|
43
43
|
OrFilter,
|
|
44
44
|
ResponseCountFilter,
|
|
45
45
|
)
|
|
46
|
-
|
|
47
|
-
from .logging import configure_logger, logger, RapidataOutputManager
|
|
48
|
-
|
|
49
46
|
from .validation import Box
|
|
50
47
|
from .exceptions import FailedUploadException
|
|
51
|
-
from .config import rapidata_config
|
|
48
|
+
from .config import rapidata_config, logger, managed_print
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
from typing import Optional, Any
|
|
2
|
-
from rapidata.api_client.api_client import
|
|
2
|
+
from rapidata.api_client.api_client import (
|
|
3
|
+
ApiClient,
|
|
4
|
+
rest,
|
|
5
|
+
ApiResponse,
|
|
6
|
+
ApiResponseT,
|
|
7
|
+
)
|
|
3
8
|
from rapidata.api_client.exceptions import ApiException
|
|
4
9
|
import json
|
|
5
10
|
import threading
|
|
6
11
|
from contextlib import contextmanager
|
|
7
|
-
from rapidata.rapidata_client.
|
|
12
|
+
from rapidata.rapidata_client.config import logger, tracer
|
|
13
|
+
from opentelemetry import trace
|
|
14
|
+
from opentelemetry.trace import format_trace_id, format_span_id, Link, SpanContext
|
|
15
|
+
from opentelemetry.sdk.trace.id_generator import RandomIdGenerator
|
|
16
|
+
|
|
8
17
|
|
|
9
18
|
# Thread-local storage for controlling error logging
|
|
10
19
|
_thread_local = threading.local()
|
|
@@ -91,6 +100,114 @@ class RapidataError(Exception):
|
|
|
91
100
|
class RapidataApiClient(ApiClient):
|
|
92
101
|
"""Custom API client that wraps errors in RapidataError."""
|
|
93
102
|
|
|
103
|
+
def __init__(self, *args, **kwargs):
|
|
104
|
+
super().__init__(*args, **kwargs)
|
|
105
|
+
self.id_generator = RandomIdGenerator()
|
|
106
|
+
|
|
107
|
+
def call_api(
|
|
108
|
+
self,
|
|
109
|
+
method,
|
|
110
|
+
url,
|
|
111
|
+
header_params=None,
|
|
112
|
+
body=None,
|
|
113
|
+
post_params=None,
|
|
114
|
+
_request_timeout=None,
|
|
115
|
+
) -> rest.RESTResponse:
|
|
116
|
+
# Get the current span from OpenTelemetry
|
|
117
|
+
current_span = trace.get_current_span()
|
|
118
|
+
|
|
119
|
+
# Initialize header_params if it's None
|
|
120
|
+
if header_params is None:
|
|
121
|
+
header_params = {}
|
|
122
|
+
|
|
123
|
+
# Add tracing headers if we have a valid span
|
|
124
|
+
if not current_span.is_recording():
|
|
125
|
+
return super().call_api(
|
|
126
|
+
method,
|
|
127
|
+
url,
|
|
128
|
+
header_params,
|
|
129
|
+
body,
|
|
130
|
+
post_params,
|
|
131
|
+
_request_timeout,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
current_span_context = current_span.get_span_context()
|
|
135
|
+
|
|
136
|
+
# Generate a new trace ID for backend communication
|
|
137
|
+
# This separates the backend trace from the SDK trace
|
|
138
|
+
backend_trace_id = self.id_generator.generate_trace_id()
|
|
139
|
+
backend_span_id = self.id_generator.generate_span_id()
|
|
140
|
+
|
|
141
|
+
# Create a new span context for the backend trace
|
|
142
|
+
backend_span_context = SpanContext(
|
|
143
|
+
trace_id=backend_trace_id,
|
|
144
|
+
span_id=backend_span_id,
|
|
145
|
+
is_remote=True,
|
|
146
|
+
trace_flags=current_span_context.trace_flags,
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# Create a link from current SDK span to the backend trace
|
|
150
|
+
link_to_backend = Link(backend_span_context)
|
|
151
|
+
|
|
152
|
+
# Create a link from backend trace back to the original SDK span
|
|
153
|
+
link_back_to_sdk = Link(current_span_context)
|
|
154
|
+
|
|
155
|
+
# Create a span in the current SDK trace that links to the backend
|
|
156
|
+
with tracer.start_span(
|
|
157
|
+
f"sdk_request_{method}_{url.replace('/', '_')}",
|
|
158
|
+
links=[link_to_backend],
|
|
159
|
+
) as sdk_request_span:
|
|
160
|
+
# Set attributes on the SDK span
|
|
161
|
+
sdk_request_span.set_attribute("http.method", method)
|
|
162
|
+
sdk_request_span.set_attribute("http.target", url)
|
|
163
|
+
sdk_request_span.set_attribute(
|
|
164
|
+
"rapidata.backend_trace_id", format_trace_id(backend_trace_id)
|
|
165
|
+
)
|
|
166
|
+
sdk_request_span.set_attribute(
|
|
167
|
+
"rapidata.original_trace_id",
|
|
168
|
+
format_trace_id(current_span_context.trace_id),
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
# Now create the initial span for the backend trace that will be sent
|
|
172
|
+
# This span will be the starting point for the backend trace
|
|
173
|
+
with tracer.start_span(
|
|
174
|
+
f"backend_trace_start_{method}_{url.replace('/', '_')}",
|
|
175
|
+
context=trace.set_span_in_context(
|
|
176
|
+
trace.NonRecordingSpan(backend_span_context)
|
|
177
|
+
),
|
|
178
|
+
links=[link_back_to_sdk],
|
|
179
|
+
) as backend_initial_span:
|
|
180
|
+
# Set attributes on the backend initial span
|
|
181
|
+
backend_initial_span.set_attribute("http.method", method)
|
|
182
|
+
backend_initial_span.set_attribute("http.target", url)
|
|
183
|
+
backend_initial_span.set_attribute(
|
|
184
|
+
"rapidata.trace_type", "backend_start"
|
|
185
|
+
)
|
|
186
|
+
backend_initial_span.set_attribute(
|
|
187
|
+
"rapidata.sdk_trace_id",
|
|
188
|
+
format_trace_id(current_span_context.trace_id),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# Format the traceparent header with the backend trace ID
|
|
192
|
+
# The backend will receive this and continue the trace
|
|
193
|
+
header_params["traceparent"] = (
|
|
194
|
+
"00-"
|
|
195
|
+
+ format_trace_id(backend_trace_id)
|
|
196
|
+
+ "-"
|
|
197
|
+
+ format_span_id(backend_span_id)
|
|
198
|
+
+ "-"
|
|
199
|
+
+ f"{backend_span_context.trace_flags:02x}"
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
return super().call_api(
|
|
203
|
+
method,
|
|
204
|
+
url,
|
|
205
|
+
header_params,
|
|
206
|
+
body,
|
|
207
|
+
post_params,
|
|
208
|
+
_request_timeout,
|
|
209
|
+
)
|
|
210
|
+
|
|
94
211
|
def response_deserialize(
|
|
95
212
|
self,
|
|
96
213
|
response_data: rest.RESTResponse,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import urllib.parse
|
|
2
|
+
import webbrowser
|
|
3
|
+
from colorama import Fore
|
|
1
4
|
import pandas as pd
|
|
2
5
|
from typing import Literal, Optional
|
|
3
6
|
|
|
4
|
-
from rapidata.rapidata_client.
|
|
7
|
+
from rapidata.rapidata_client.config import logger, managed_print, tracer
|
|
5
8
|
from rapidata.rapidata_client.benchmark._detail_mapper import DetailMapper
|
|
6
9
|
from rapidata.service.openapi_service import OpenAPIService
|
|
7
|
-
from rapidata.api_client.models.
|
|
8
|
-
UpdateLeaderboardResponseConfigModel,
|
|
9
|
-
)
|
|
10
|
+
from rapidata.api_client.models.update_leaderboard_model import UpdateLeaderboardModel
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class RapidataLeaderboard:
|
|
@@ -32,6 +33,7 @@ class RapidataLeaderboard:
|
|
|
32
33
|
inverse_ranking: bool,
|
|
33
34
|
response_budget: int,
|
|
34
35
|
min_responses_per_matchup: int,
|
|
36
|
+
benchmark_id: str,
|
|
35
37
|
id: str,
|
|
36
38
|
openapi_service: OpenAPIService,
|
|
37
39
|
):
|
|
@@ -43,7 +45,9 @@ class RapidataLeaderboard:
|
|
|
43
45
|
self.__inverse_ranking = inverse_ranking
|
|
44
46
|
self.__response_budget = response_budget
|
|
45
47
|
self.__min_responses_per_matchup = min_responses_per_matchup
|
|
48
|
+
self.__benchmark_id = benchmark_id
|
|
46
49
|
self.id = id
|
|
50
|
+
self.__leaderboard_page = f"https://app.{self.__openapi_service.environment}/mri/benchmarks/{self.__benchmark_id}/leaderboard/{self.id}"
|
|
47
51
|
|
|
48
52
|
@property
|
|
49
53
|
def level_of_detail(self) -> Literal["low", "medium", "high", "very high"]:
|
|
@@ -59,15 +63,10 @@ class RapidataLeaderboard:
|
|
|
59
63
|
"""
|
|
60
64
|
Sets the level of detail of the leaderboard.
|
|
61
65
|
"""
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
responseBudget=DetailMapper.get_budget(level_of_detail),
|
|
67
|
-
minResponses=self.__min_responses_per_matchup,
|
|
68
|
-
),
|
|
69
|
-
)
|
|
70
|
-
self.__response_budget = DetailMapper.get_budget(level_of_detail)
|
|
66
|
+
with tracer.start_as_current_span("RapidataLeaderboard.level_of_detail.setter"):
|
|
67
|
+
logger.debug(f"Setting level of detail to {level_of_detail}")
|
|
68
|
+
self.__response_budget = DetailMapper.get_budget(level_of_detail)
|
|
69
|
+
self._update_config()
|
|
71
70
|
|
|
72
71
|
@property
|
|
73
72
|
def min_responses_per_matchup(self) -> int:
|
|
@@ -81,23 +80,20 @@ class RapidataLeaderboard:
|
|
|
81
80
|
"""
|
|
82
81
|
Sets the minimum number of responses required to be considered for the leaderboard.
|
|
83
82
|
"""
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
with tracer.start_as_current_span(
|
|
84
|
+
"RapidataLeaderboard.min_responses_per_matchup.setter"
|
|
85
|
+
):
|
|
86
|
+
if not isinstance(min_responses, int):
|
|
87
|
+
raise ValueError("Min responses per matchup must be an integer")
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
if min_responses < 3:
|
|
90
|
+
raise ValueError("Min responses per matchup must be at least 3")
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
update_leaderboard_response_config_model=UpdateLeaderboardResponseConfigModel(
|
|
96
|
-
responseBudget=self.__response_budget,
|
|
97
|
-
minResponses=min_responses,
|
|
98
|
-
),
|
|
99
|
-
)
|
|
100
|
-
self.__min_responses_per_matchup = min_responses
|
|
92
|
+
logger.debug(
|
|
93
|
+
f"Setting min responses per matchup to {min_responses} for leaderboard {self.name}"
|
|
94
|
+
)
|
|
95
|
+
self.__min_responses_per_matchup = min_responses
|
|
96
|
+
self._update_config()
|
|
101
97
|
|
|
102
98
|
@property
|
|
103
99
|
def show_prompt_asset(self) -> bool:
|
|
@@ -134,6 +130,20 @@ class RapidataLeaderboard:
|
|
|
134
130
|
"""
|
|
135
131
|
return self.__name
|
|
136
132
|
|
|
133
|
+
@name.setter
|
|
134
|
+
def name(self, name: str):
|
|
135
|
+
"""
|
|
136
|
+
Sets the name of the leaderboard.
|
|
137
|
+
"""
|
|
138
|
+
with tracer.start_as_current_span("RapidataLeaderboard.name.setter"):
|
|
139
|
+
if not isinstance(name, str):
|
|
140
|
+
raise ValueError("Name must be a string")
|
|
141
|
+
if len(name) < 1:
|
|
142
|
+
raise ValueError("Name must be at least 1 character long")
|
|
143
|
+
|
|
144
|
+
self.__name = name
|
|
145
|
+
self._update_config()
|
|
146
|
+
|
|
137
147
|
def get_standings(self, tags: Optional[list[str]] = None) -> pd.DataFrame:
|
|
138
148
|
"""
|
|
139
149
|
Returns the standings of the leaderboard.
|
|
@@ -146,27 +156,59 @@ class RapidataLeaderboard:
|
|
|
146
156
|
Returns:
|
|
147
157
|
A pandas DataFrame containing the standings of the leaderboard.
|
|
148
158
|
"""
|
|
159
|
+
with tracer.start_as_current_span("RapidataLeaderboard.get_standings"):
|
|
160
|
+
participants = self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_standings_get(
|
|
161
|
+
leaderboard_id=self.id, tags=tags
|
|
162
|
+
)
|
|
149
163
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
standings = []
|
|
165
|
+
for participant in participants.items:
|
|
166
|
+
standings.append(
|
|
167
|
+
{
|
|
168
|
+
"name": participant.name,
|
|
169
|
+
"wins": participant.wins,
|
|
170
|
+
"total_matches": participant.total_matches,
|
|
171
|
+
"score": (
|
|
172
|
+
round(participant.score, 2)
|
|
173
|
+
if participant.score is not None
|
|
174
|
+
else None
|
|
175
|
+
),
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return pd.DataFrame(standings)
|
|
180
|
+
|
|
181
|
+
def view(self) -> None:
|
|
182
|
+
"""
|
|
183
|
+
Views the leaderboard.
|
|
184
|
+
"""
|
|
185
|
+
logger.info("Opening leaderboard page in browser...")
|
|
186
|
+
could_open_browser = webbrowser.open(self.__leaderboard_page)
|
|
187
|
+
if not could_open_browser:
|
|
188
|
+
encoded_url = urllib.parse.quote(
|
|
189
|
+
self.__leaderboard_page, safe="%/:=&?~#+!$,;'@()*[]"
|
|
190
|
+
)
|
|
191
|
+
managed_print(
|
|
192
|
+
Fore.RED
|
|
193
|
+
+ f"Please open this URL in your browser: '{encoded_url}'"
|
|
194
|
+
+ Fore.RESET
|
|
167
195
|
)
|
|
168
196
|
|
|
169
|
-
|
|
197
|
+
def _custom_config(self, response_budget: int, min_responses_per_matchup: int):
|
|
198
|
+
self.__response_budget = response_budget
|
|
199
|
+
self.__min_responses_per_matchup = min_responses_per_matchup
|
|
200
|
+
self._update_config()
|
|
201
|
+
|
|
202
|
+
def _update_config(self):
|
|
203
|
+
with tracer.start_as_current_span("RapidataLeaderboard._update_config"):
|
|
204
|
+
self.__openapi_service.leaderboard_api.leaderboard_leaderboard_id_patch(
|
|
205
|
+
leaderboard_id=self.id,
|
|
206
|
+
update_leaderboard_model=UpdateLeaderboardModel(
|
|
207
|
+
name=self.__name,
|
|
208
|
+
responseBudget=self.__response_budget,
|
|
209
|
+
minResponses=self.__min_responses_per_matchup,
|
|
210
|
+
),
|
|
211
|
+
)
|
|
170
212
|
|
|
171
213
|
def __str__(self) -> str:
|
|
172
214
|
return f"RapidataLeaderboard(name={self.name}, instruction={self.instruction}, show_prompt={self.show_prompt}, leaderboard_id={self.id})"
|