rapidata 1.10.0__py3-none-any.whl → 2.0.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 +21 -17
- rapidata/api_client/__init__.py +15 -5
- rapidata/api_client/api/coco_api.py +14 -29
- rapidata/api_client/api/dataset_api.py +6 -6
- rapidata/api_client/api/identity_api.py +3 -3
- rapidata/api_client/api/pipeline_api.py +1008 -95
- rapidata/api_client/api/rapid_api.py +6 -6
- rapidata/api_client/api/validation_api.py +12 -42
- rapidata/api_client/models/__init__.py +15 -5
- rapidata/api_client/models/add_campaign_model.py +1 -3
- rapidata/api_client/models/add_validation_text_rapid_model.py +1 -1
- rapidata/api_client/models/age_group.py +5 -4
- rapidata/api_client/models/base_error.py +1 -4
- rapidata/api_client/models/compare_workflow_config.py +9 -24
- rapidata/api_client/models/compare_workflow_config_model.py +9 -29
- rapidata/api_client/models/compare_workflow_config_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_config_pair_maker_config.py +140 -0
- rapidata/api_client/models/compare_workflow_model.py +7 -3
- rapidata/api_client/models/compare_workflow_model1.py +7 -3
- rapidata/api_client/models/compare_workflow_model1_pair_maker_information.py +140 -0
- rapidata/api_client/models/compare_workflow_model_pair_maker_config.py +140 -0
- rapidata/api_client/models/file_asset_model_metadata_inner.py +8 -22
- rapidata/api_client/models/get_classify_workflow_result_overview_result.py +144 -0
- rapidata/api_client/models/get_pipeline_by_id_result.py +13 -3
- rapidata/api_client/models/identity_read_bridge_token_get202_response.py +140 -0
- rapidata/api_client/models/not_available_yet_result.py +96 -0
- rapidata/api_client/models/online_pair_maker_config.py +98 -0
- rapidata/api_client/models/online_pair_maker_config_model.py +98 -0
- rapidata/api_client/models/online_pair_maker_information.py +100 -0
- rapidata/api_client/models/pipeline_id_workflow_put_request.py +140 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config.py +100 -0
- rapidata/api_client/models/pre_arranged_pair_maker_config_model.py +96 -0
- rapidata/api_client/models/pre_arranged_pair_maker_information.py +102 -0
- rapidata/api_client/models/read_bridge_token_keys_result.py +11 -2
- rapidata/api_client/models/simple_workflow_config.py +7 -26
- rapidata/api_client/models/simple_workflow_config_model.py +4 -28
- rapidata/api_client/models/simple_workflow_get_result_overview_get200_response.py +16 -16
- rapidata/api_client/models/simple_workflow_model1.py +3 -3
- rapidata/api_client/models/update_campaign_model.py +99 -0
- rapidata/api_client/models/validation_import_post_request_blueprint.py +1 -1
- rapidata/api_client_README.md +20 -7
- rapidata/rapidata_client/__init__.py +18 -9
- rapidata/rapidata_client/assets/__init__.py +5 -4
- rapidata/rapidata_client/assets/{media_asset.py → _media_asset.py} +32 -11
- rapidata/rapidata_client/assets/{multi_asset.py → _multi_asset.py} +1 -1
- rapidata/rapidata_client/assets/{text_asset.py → _text_asset.py} +1 -1
- rapidata/rapidata_client/assets/data_type_enum.py +7 -0
- rapidata/rapidata_client/filter/__init__.py +1 -1
- rapidata/rapidata_client/filter/_base_filter.py +10 -0
- rapidata/rapidata_client/filter/age_filter.py +12 -5
- rapidata/rapidata_client/filter/campaign_filter.py +12 -3
- rapidata/rapidata_client/filter/country_filter.py +10 -3
- rapidata/rapidata_client/filter/gender_filter.py +12 -5
- rapidata/rapidata_client/filter/language_filter.py +14 -3
- rapidata/rapidata_client/filter/models/age_group.py +26 -0
- rapidata/rapidata_client/filter/models/gender.py +19 -0
- rapidata/rapidata_client/filter/rapidata_filters.py +31 -0
- rapidata/rapidata_client/filter/user_score_filter.py +20 -4
- rapidata/rapidata_client/metadata/__init__.py +5 -5
- rapidata/rapidata_client/metadata/{base_metadata.py → _base_metadata.py} +2 -1
- rapidata/rapidata_client/metadata/{private_text_metadata.py → _private_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{prompt_metadata.py → _prompt_metadata.py} +3 -2
- rapidata/rapidata_client/metadata/{public_text_metadata.py → _public_text_metadata.py} +2 -2
- rapidata/rapidata_client/metadata/{select_words_metadata.py → _select_words_metadata.py} +3 -2
- rapidata/rapidata_client/{dataset/rapidata_dataset.py → order/_rapidata_dataset.py} +7 -8
- rapidata/rapidata_client/order/_rapidata_order_builder.py +365 -0
- rapidata/rapidata_client/order/rapidata_order.py +49 -31
- rapidata/rapidata_client/order/rapidata_order_manager.py +461 -0
- rapidata/rapidata_client/rapidata_client.py +12 -201
- rapidata/rapidata_client/referee/__init__.py +3 -3
- rapidata/rapidata_client/referee/{base_referee.py → _base_referee.py} +3 -3
- rapidata/rapidata_client/referee/{early_stopping_referee.py → _early_stopping_referee.py} +14 -11
- rapidata/rapidata_client/referee/{naive_referee.py → _naive_referee.py} +9 -9
- rapidata/rapidata_client/selection/__init__.py +1 -1
- rapidata/rapidata_client/{filter/base_filter.py → selection/_base_selection.py} +2 -2
- rapidata/rapidata_client/selection/capped_selection.py +15 -5
- rapidata/rapidata_client/selection/conditional_validation_selection.py +17 -4
- rapidata/rapidata_client/selection/demographic_selection.py +18 -7
- rapidata/rapidata_client/selection/labeling_selection.py +10 -3
- rapidata/rapidata_client/selection/rapidata_selections.py +21 -0
- rapidata/rapidata_client/selection/validation_selection.py +11 -4
- rapidata/rapidata_client/settings/__init__.py +9 -2
- rapidata/rapidata_client/settings/_rapidata_setting.py +11 -0
- rapidata/rapidata_client/settings/alert_on_fast_response.py +21 -0
- rapidata/rapidata_client/settings/custom_setting.py +16 -0
- rapidata/rapidata_client/settings/free_text_minimum_characters.py +16 -0
- rapidata/rapidata_client/settings/models/__init__.py +1 -0
- rapidata/rapidata_client/settings/models/translation_behaviour_options.py +14 -0
- rapidata/rapidata_client/settings/no_shuffle.py +16 -0
- rapidata/rapidata_client/settings/play_video_until_the_end.py +16 -0
- rapidata/rapidata_client/settings/rapidata_settings.py +31 -0
- rapidata/rapidata_client/settings/translation_behaviour.py +18 -0
- rapidata/rapidata_client/validation/__init__.py +1 -0
- rapidata/rapidata_client/{dataset/validation_rapid_parts.py → validation/_validation_rapid_parts.py} +7 -6
- rapidata/rapidata_client/validation/_validation_set_builder.py +371 -0
- rapidata/rapidata_client/{dataset → validation}/rapidata_validation_set.py +54 -50
- rapidata/rapidata_client/validation/rapids/__init__.py +1 -0
- rapidata/rapidata_client/validation/rapids/box.py +17 -0
- rapidata/rapidata_client/validation/rapids/rapids.py +94 -0
- rapidata/rapidata_client/validation/rapids/rapids_manager.py +163 -0
- rapidata/rapidata_client/validation/validation_set_manager.py +335 -0
- rapidata/rapidata_client/workflow/__init__.py +8 -6
- rapidata/rapidata_client/workflow/_base_workflow.py +25 -0
- rapidata/rapidata_client/workflow/{classify_workflow.py → _classify_workflow.py} +6 -6
- rapidata/rapidata_client/workflow/{compare_workflow.py → _compare_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_draw_workflow.py +22 -0
- rapidata/rapidata_client/workflow/_evaluation_workflow.py +26 -0
- rapidata/rapidata_client/workflow/{free_text_workflow.py → _free_text_workflow.py} +10 -16
- rapidata/rapidata_client/workflow/_locate_workflow.py +22 -0
- rapidata/rapidata_client/workflow/{select_words_workflow.py → _select_words_workflow.py} +2 -8
- rapidata/service/credential_manager.py +11 -1
- rapidata/service/openapi_service.py +23 -4
- {rapidata-1.10.0.dist-info → rapidata-2.0.0.dist-info}/METADATA +2 -1
- {rapidata-1.10.0.dist-info → rapidata-2.0.0.dist-info}/RECORD +118 -94
- rapidata/constants.py +0 -1
- rapidata/rapidata_client/dataset/rapid_builders/__init__.py +0 -4
- rapidata/rapidata_client/dataset/rapid_builders/base_rapid_builder.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/classify_rapid_builders.py +0 -166
- rapidata/rapidata_client/dataset/rapid_builders/compare_rapid_builders.py +0 -145
- rapidata/rapidata_client/dataset/rapid_builders/rapids.py +0 -33
- rapidata/rapidata_client/dataset/rapid_builders/select_words_rapid_builders.py +0 -124
- rapidata/rapidata_client/dataset/validation_set_builder.py +0 -336
- rapidata/rapidata_client/order/order_builder.py +0 -25
- rapidata/rapidata_client/order/rapidata_order_builder.py +0 -463
- rapidata/rapidata_client/selection/base_selection.py +0 -9
- rapidata/rapidata_client/settings/feature_flags.py +0 -125
- rapidata/rapidata_client/settings/settings.py +0 -124
- rapidata/rapidata_client/simple_builders/__init__.py +0 -0
- rapidata/rapidata_client/simple_builders/simple_classification_builders.py +0 -271
- rapidata/rapidata_client/simple_builders/simple_compare_builders.py +0 -267
- rapidata/rapidata_client/simple_builders/simple_free_text_builders.py +0 -192
- rapidata/rapidata_client/simple_builders/simple_select_words_builders.py +0 -196
- rapidata/rapidata_client/workflow/base_workflow.py +0 -42
- rapidata/rapidata_client/workflow/evaluation_workflow.py +0 -15
- /rapidata/rapidata_client/assets/{base_asset.py → _base_asset.py} +0 -0
- /rapidata/rapidata_client/{dataset → filter/models}/__init__.py +0 -0
- {rapidata-1.10.0.dist-info → rapidata-2.0.0.dist-info}/LICENSE +0 -0
- {rapidata-1.10.0.dist-info → rapidata-2.0.0.dist-info}/WHEEL +0 -0
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.age_user_filter_model import AgeUserFilterModel
|
|
4
|
-
from rapidata.
|
|
4
|
+
from rapidata.rapidata_client.filter.models.age_group import AgeGroup
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class AgeFilter(
|
|
7
|
+
class AgeFilter(RapidataFilter):
|
|
8
|
+
"""AgeFilter Class
|
|
9
|
+
|
|
10
|
+
Can be used to filter who to target based on age groups.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
age_groups (list[AgeGroup]): List of age groups to filter by."""
|
|
8
15
|
|
|
9
16
|
def __init__(self, age_groups: list[AgeGroup]):
|
|
10
17
|
self.age_groups = age_groups
|
|
11
18
|
|
|
12
|
-
def
|
|
19
|
+
def _to_model(self):
|
|
13
20
|
return AgeUserFilterModel(
|
|
14
21
|
_t="AgeFilter",
|
|
15
|
-
ageGroups=self.age_groups,
|
|
22
|
+
ageGroups=[age_group._to_backend_model() for age_group in self.age_groups],
|
|
16
23
|
)
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.campaign_user_filter_model import (
|
|
4
4
|
CampaignUserFilterModel,
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class CampaignFilter(
|
|
8
|
+
class CampaignFilter(RapidataFilter):
|
|
9
|
+
"""CampaignFilter Class
|
|
10
|
+
|
|
11
|
+
Can be used to filter who to target based on campaign IDs.
|
|
12
|
+
|
|
13
|
+
This filter can only be used when directly in contact with Rapidata.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
campaign_ids (list[str]): List of campaign IDs to filter by.
|
|
17
|
+
"""
|
|
9
18
|
|
|
10
19
|
def __init__(self, campaign_ids: list[str]):
|
|
11
20
|
self.campaign_ids = campaign_ids
|
|
12
21
|
|
|
13
|
-
def
|
|
22
|
+
def _to_model(self):
|
|
14
23
|
return CampaignUserFilterModel(
|
|
15
24
|
_t="CampaignFilter",
|
|
16
25
|
campaignIds=self.campaign_ids,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.country_user_filter_model import CountryUserFilterModel
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class CountryFilter(
|
|
6
|
+
class CountryFilter(RapidataFilter):
|
|
7
|
+
"""CountryFilter Class
|
|
8
|
+
|
|
9
|
+
Can be used to filter who to target based on country codes.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
country_codes (list[str]): List of country codes (capizalized) to filter by.
|
|
13
|
+
"""
|
|
7
14
|
|
|
8
15
|
def __init__(self, country_codes: list[str]):
|
|
9
16
|
# check that all characters in the country codes are uppercase
|
|
@@ -15,5 +22,5 @@ class CountryFilter(Filter):
|
|
|
15
22
|
|
|
16
23
|
self.country_codes = country_codes
|
|
17
24
|
|
|
18
|
-
def
|
|
25
|
+
def _to_model(self):
|
|
19
26
|
return CountryUserFilterModel(_t="CountryFilter", countries=self.country_codes)
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.gender_user_filter_model import GenderUserFilterModel
|
|
4
|
-
from rapidata.
|
|
4
|
+
from rapidata.rapidata_client.filter.models.gender import Gender
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class GenderFilter(
|
|
7
|
+
class GenderFilter(RapidataFilter):
|
|
8
|
+
"""GenderFilter Class
|
|
9
|
+
|
|
10
|
+
Can be used to filter who to target based on their gender.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
genders (list[Gender]): List of genders to filter by."""
|
|
8
15
|
|
|
9
16
|
def __init__(self, genders: list[Gender]):
|
|
10
17
|
self.genders = genders
|
|
11
18
|
|
|
12
|
-
def
|
|
19
|
+
def _to_model(self):
|
|
13
20
|
return GenderUserFilterModel(
|
|
14
21
|
_t="GenderFilter",
|
|
15
|
-
genders=self.genders,
|
|
22
|
+
genders=[gender._to_backend_model() for gender in self.genders],
|
|
16
23
|
)
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.language_user_filter_model import (
|
|
4
4
|
LanguageUserFilterModel,
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class LanguageFilter(
|
|
8
|
+
class LanguageFilter(RapidataFilter):
|
|
9
|
+
"""LanguageFilter Class
|
|
10
|
+
|
|
11
|
+
Can be used to filter who to target based on language codes.
|
|
12
|
+
|
|
13
|
+
example: LanguageFilter(["en", "de"]) -> will limit the order to be shown to only people who have their phone set to english or german
|
|
9
14
|
|
|
15
|
+
Args:
|
|
16
|
+
language_codes (list[str]): List of language codes to filter by."""
|
|
10
17
|
def __init__(self, language_codes: list[str]):
|
|
11
18
|
if not isinstance(language_codes, list):
|
|
12
19
|
raise ValueError("Language codes must be a list")
|
|
@@ -14,8 +21,12 @@ class LanguageFilter(Filter):
|
|
|
14
21
|
# check that all characters in the language codes are lowercase
|
|
15
22
|
if not all([code.islower() for code in language_codes]):
|
|
16
23
|
raise ValueError("Language codes must be lowercase")
|
|
24
|
+
|
|
25
|
+
for code in language_codes:
|
|
26
|
+
if not len(code) == 2:
|
|
27
|
+
raise ValueError("Language codes must be two characters long")
|
|
17
28
|
|
|
18
29
|
self.languages = language_codes
|
|
19
30
|
|
|
20
|
-
def
|
|
31
|
+
def _to_model(self):
|
|
21
32
|
return LanguageUserFilterModel(_t="LanguageFilter", languages=self.languages)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from rapidata.api_client.models.age_group import AgeGroup as BackendAgeGroupModel
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
class AgeGroup(Enum):
|
|
5
|
+
"""AgeGroup Enum
|
|
6
|
+
|
|
7
|
+
Represents the age group of a user. Used to filter who to target based on age groups.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
UNDER_18 (AgeGroup): Represents the age group of users under 18.
|
|
11
|
+
BETWEEN_18_29 (AgeGroup): Represents the age group of users between 18 and 29.
|
|
12
|
+
BETWEEN_30_39 (AgeGroup): Represents the age group of users between 30 and 39.
|
|
13
|
+
BETWEEN_40_49 (AgeGroup): Represents the age group of users between 40 and 49.
|
|
14
|
+
BETWEEN_50_64 (AgeGroup): Represents the age group of users between 50 and 64.
|
|
15
|
+
OVER_65 (AgeGroup): Represents the age group of users over 65."""
|
|
16
|
+
|
|
17
|
+
UNDER_18 = BackendAgeGroupModel.ENUM_0_MINUS_17
|
|
18
|
+
BETWEEN_18_29 = BackendAgeGroupModel.ENUM_18_MINUS_29
|
|
19
|
+
BETWEEN_30_39 = BackendAgeGroupModel.ENUM_30_MINUS_39
|
|
20
|
+
BETWEEN_40_49 = BackendAgeGroupModel.ENUM_40_MINUS_49
|
|
21
|
+
BETWEEN_50_64 = BackendAgeGroupModel.ENUM_50_MINUS_64
|
|
22
|
+
OVER_65 = BackendAgeGroupModel.ENUM_65_PLUS
|
|
23
|
+
|
|
24
|
+
def _to_backend_model(self) -> BackendAgeGroupModel:
|
|
25
|
+
return BackendAgeGroupModel(self.value)
|
|
26
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from rapidata.api_client.models.gender import Gender as BackendGenderModel
|
|
3
|
+
|
|
4
|
+
class Gender(Enum):
|
|
5
|
+
"""Gender Enum
|
|
6
|
+
|
|
7
|
+
Represents the gender of a user. Used to filter who to target based on genders.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
MALE (Gender): Represents the Male gender.
|
|
11
|
+
FEMALE (Gender): Represents the Female gender.
|
|
12
|
+
OTHER (Gender): Represents any other gender.
|
|
13
|
+
"""
|
|
14
|
+
MALE = BackendGenderModel.MALE
|
|
15
|
+
FEMALE = BackendGenderModel.FEMALE
|
|
16
|
+
OTHER = BackendGenderModel.OTHER
|
|
17
|
+
|
|
18
|
+
def _to_backend_model(self) -> BackendGenderModel:
|
|
19
|
+
return BackendGenderModel(self.value)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from rapidata.rapidata_client.filter import (
|
|
2
|
+
AgeFilter,
|
|
3
|
+
CampaignFilter,
|
|
4
|
+
CountryFilter,
|
|
5
|
+
GenderFilter,
|
|
6
|
+
LanguageFilter,
|
|
7
|
+
UserScoreFilter)
|
|
8
|
+
|
|
9
|
+
class RapidataFilters:
|
|
10
|
+
"""RapidataFilters Classes
|
|
11
|
+
|
|
12
|
+
These filters can be added to the order to specifically target a certain group of users.
|
|
13
|
+
|
|
14
|
+
Note that adding multiple filters to the same order will result in a logical AND operation between the filters.
|
|
15
|
+
|
|
16
|
+
Warning: this might significantly slow down the number of responses you receive.
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
user_score (UserScoreFilter): The UserScoreFilter instance.
|
|
20
|
+
age (AgeFilter): The AgeFilter instance.
|
|
21
|
+
campaign (CampaignFilter): The CampaignFilter instance.
|
|
22
|
+
country (CountryFilter): The CountryFilter instance.
|
|
23
|
+
campaign (CampaignFilter): The CampaignFilter instance
|
|
24
|
+
gender (GenderFilter): The GenderFilter instance.
|
|
25
|
+
language (LanguageFilter): The LanguageFilter instance."""
|
|
26
|
+
user_score = UserScoreFilter
|
|
27
|
+
age = AgeFilter
|
|
28
|
+
campaign = CampaignFilter
|
|
29
|
+
country = CountryFilter
|
|
30
|
+
gender = GenderFilter
|
|
31
|
+
language = LanguageFilter
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
-
from rapidata.rapidata_client.filter.
|
|
2
|
+
from rapidata.rapidata_client.filter._base_filter import RapidataFilter
|
|
3
3
|
from rapidata.api_client.models.user_score_user_filter_model import (
|
|
4
4
|
UserScoreUserFilterModel,
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class UserScoreFilter(
|
|
8
|
+
class UserScoreFilter(RapidataFilter):
|
|
9
|
+
"""UserScoreFilter Class
|
|
10
|
+
|
|
11
|
+
Can be used to filter who to target based on their user score.
|
|
12
|
+
|
|
13
|
+
example: UserScoreFilter(0.5, 0.9) -> will only show the order to users that have a UserScore of >=0.5 and <=0.9
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
Args:
|
|
16
|
+
lower_bound (float): The lower bound of the user score.
|
|
17
|
+
upper_bound (float): The upper bound of the user score.
|
|
18
|
+
"""
|
|
19
|
+
def __init__(self, lower_bound: float = 0.0, upper_bound: float = 1.0):
|
|
20
|
+
if lower_bound < 0 or lower_bound > 1:
|
|
21
|
+
raise ValueError("The lower bound must be between 0 and 1.")
|
|
22
|
+
if upper_bound < 0 or upper_bound > 1:
|
|
23
|
+
raise ValueError("The upper bound must be between 0 and 1.")
|
|
24
|
+
if lower_bound >= upper_bound:
|
|
25
|
+
raise ValueError("The lower bound must be less than the upper bound.")
|
|
26
|
+
|
|
11
27
|
self.upper_bound = upper_bound
|
|
12
28
|
self.lower_bound = lower_bound
|
|
13
29
|
|
|
14
|
-
def
|
|
30
|
+
def _to_model(self):
|
|
15
31
|
return UserScoreUserFilterModel(
|
|
16
32
|
_t="UserScoreFilter",
|
|
17
33
|
upperbound=self.upper_bound,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from .
|
|
2
|
-
from .
|
|
3
|
-
from .
|
|
4
|
-
from .
|
|
5
|
-
from .
|
|
1
|
+
from ._base_metadata import Metadata
|
|
2
|
+
from ._private_text_metadata import PrivateTextMetadata
|
|
3
|
+
from ._public_text_metadata import PublicTextMetadata
|
|
4
|
+
from ._prompt_metadata import PromptMetadata
|
|
5
|
+
from ._select_words_metadata import SelectWordsMetadata
|
|
@@ -3,10 +3,11 @@ from typing import Any
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class Metadata:
|
|
6
|
+
"""The base class for all Rapidata Metadata."""
|
|
6
7
|
|
|
7
8
|
def __init__(self, identifier: str):
|
|
8
9
|
self._identifier = identifier
|
|
9
10
|
|
|
10
11
|
@abstractmethod
|
|
11
|
-
def
|
|
12
|
+
def _to_model(self) -> Any:
|
|
12
13
|
pass
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from rapidata.api_client.models.private_text_metadata_input import (
|
|
2
2
|
PrivateTextMetadataInput,
|
|
3
3
|
)
|
|
4
|
-
from rapidata.rapidata_client.metadata.
|
|
4
|
+
from rapidata.rapidata_client.metadata._base_metadata import Metadata
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class PrivateTextMetadata(Metadata):
|
|
@@ -10,7 +10,7 @@ class PrivateTextMetadata(Metadata):
|
|
|
10
10
|
super().__init__(identifier=identifier)
|
|
11
11
|
self._text = text
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def _to_model(self):
|
|
14
14
|
return PrivateTextMetadataInput(
|
|
15
15
|
_t="PrivateTextMetadataInput", identifier=self._identifier, text=self._text
|
|
16
16
|
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
from rapidata.rapidata_client.metadata.
|
|
1
|
+
from rapidata.rapidata_client.metadata._base_metadata import Metadata
|
|
2
2
|
from rapidata.api_client.models.prompt_metadata_input import PromptMetadataInput
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
class PromptMetadata(Metadata):
|
|
6
|
+
"""The PromptMetadata class is used to display a prompt to the user."""
|
|
6
7
|
|
|
7
8
|
def __init__(self, prompt: str, identifier: str = "prompt"):
|
|
8
9
|
super().__init__(identifier=identifier)
|
|
@@ -13,5 +14,5 @@ class PromptMetadata(Metadata):
|
|
|
13
14
|
self._prompt = prompt
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
def
|
|
17
|
+
def _to_model(self):
|
|
17
18
|
return PromptMetadataInput(_t="PromptMetadataInput", identifier=self._identifier, prompt=self._prompt)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from rapidata.api_client.models.public_text_metadata_input import (
|
|
2
2
|
PublicTextMetadataInput,
|
|
3
3
|
)
|
|
4
|
-
from rapidata.rapidata_client.metadata.
|
|
4
|
+
from rapidata.rapidata_client.metadata._base_metadata import Metadata
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class PublicTextMetadata(Metadata):
|
|
@@ -10,7 +10,7 @@ class PublicTextMetadata(Metadata):
|
|
|
10
10
|
super().__init__(identifier=identifier)
|
|
11
11
|
self._text = text
|
|
12
12
|
|
|
13
|
-
def
|
|
13
|
+
def _to_model(self):
|
|
14
14
|
return PublicTextMetadataInput(
|
|
15
15
|
_t="PublicTextMetadataInput", identifier=self._identifier, text=self._text
|
|
16
16
|
)
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
from rapidata.api_client.models.transcription_metadata_input import (
|
|
2
2
|
TranscriptionMetadataInput,
|
|
3
3
|
)
|
|
4
|
-
from rapidata.rapidata_client.metadata.
|
|
4
|
+
from rapidata.rapidata_client.metadata._base_metadata import Metadata
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class SelectWordsMetadata(Metadata):
|
|
8
|
+
"""SelectWordsMetadata Class is used to define the Sentence that will be display to the user."""
|
|
8
9
|
|
|
9
10
|
def __init__(self, select_words: str, identifier: str = "transcription"):
|
|
10
11
|
super().__init__(identifier=identifier)
|
|
11
12
|
self.identifier = identifier
|
|
12
13
|
self.select_words = select_words
|
|
13
14
|
|
|
14
|
-
def
|
|
15
|
+
def _to_model(self):
|
|
15
16
|
return TranscriptionMetadataInput(
|
|
16
17
|
_t="TranscriptionMetadataInput",
|
|
17
18
|
identifier=self.identifier,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from itertools import zip_longest
|
|
2
|
-
import os
|
|
3
2
|
|
|
4
3
|
from rapidata.api_client.models.datapoint_metadata_model import DatapointMetadataModel
|
|
5
4
|
from rapidata.api_client.models.datapoint_metadata_model_metadata_inner import (
|
|
@@ -8,14 +7,14 @@ from rapidata.api_client.models.datapoint_metadata_model_metadata_inner import (
|
|
|
8
7
|
from rapidata.api_client.models.upload_text_sources_to_dataset_model import (
|
|
9
8
|
UploadTextSourcesToDatasetModel,
|
|
10
9
|
)
|
|
11
|
-
from rapidata.rapidata_client.metadata.
|
|
10
|
+
from rapidata.rapidata_client.metadata._base_metadata import Metadata
|
|
12
11
|
from rapidata.rapidata_client.assets import TextAsset, MediaAsset, MultiAsset
|
|
13
12
|
from rapidata.service import LocalFileService
|
|
14
13
|
from rapidata.service.openapi_service import OpenAPIService
|
|
15
14
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
16
15
|
from tqdm import tqdm
|
|
17
16
|
|
|
18
|
-
from typing import cast
|
|
17
|
+
from typing import cast, Sequence
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
class RapidataDataset:
|
|
@@ -25,7 +24,7 @@ class RapidataDataset:
|
|
|
25
24
|
self.openapi_service = openapi_service
|
|
26
25
|
self.local_file_service = LocalFileService()
|
|
27
26
|
|
|
28
|
-
def
|
|
27
|
+
def _add_texts(
|
|
29
28
|
self,
|
|
30
29
|
text_assets: list[TextAsset] | list[MultiAsset],
|
|
31
30
|
max_workers: int = 10,
|
|
@@ -63,17 +62,17 @@ class RapidataDataset:
|
|
|
63
62
|
future.result() # This will raise any exceptions that occurred during execution
|
|
64
63
|
pbar.update(1)
|
|
65
64
|
|
|
66
|
-
def
|
|
65
|
+
def _add_media_from_paths(
|
|
67
66
|
self,
|
|
68
67
|
media_paths: list[MediaAsset] | list[MultiAsset], # where multiasset is a list of media assets
|
|
69
|
-
metadata:
|
|
68
|
+
metadata: Sequence[Metadata] | None = None,
|
|
70
69
|
max_workers: int = 10,
|
|
71
70
|
):
|
|
72
71
|
if metadata is not None and len(metadata) != len(media_paths):
|
|
73
72
|
raise ValueError(
|
|
74
73
|
"metadata must be None or have the same length as media_paths"
|
|
75
74
|
)
|
|
76
|
-
|
|
75
|
+
|
|
77
76
|
for media_path in media_paths:
|
|
78
77
|
if isinstance(media_path, MultiAsset):
|
|
79
78
|
assert all(
|
|
@@ -88,7 +87,7 @@ class RapidataDataset:
|
|
|
88
87
|
else:
|
|
89
88
|
raise ValueError(f"Unsupported asset type: {type(media_asset)}")
|
|
90
89
|
|
|
91
|
-
meta_model = meta.
|
|
90
|
+
meta_model = meta._to_model() if meta else None
|
|
92
91
|
model = DatapointMetadataModel(
|
|
93
92
|
datasetId=self.dataset_id,
|
|
94
93
|
metadata=(
|