rapidata 0.1.2__py3-none-any.whl → 0.1.5__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.
- openapi/openapi-client/openapi_client/__init__.py +215 -0
- openapi/openapi-client/openapi_client/api/__init__.py +11 -0
- openapi/openapi-client/openapi_client/api/coco_api.py +619 -0
- openapi/openapi-client/openapi_client/api/datapoint_api.py +817 -0
- openapi/openapi-client/openapi_client/api/dataset_api.py +2290 -0
- openapi/openapi-client/openapi_client/api/identity_api.py +3181 -0
- openapi/openapi-client/openapi_client/api/newsletter_api.py +571 -0
- openapi/openapi-client/openapi_client/api/order_api.py +5390 -0
- openapi/openapi-client/openapi_client/api/validation_api.py +1670 -0
- openapi/openapi-client/openapi_client/api_client.py +797 -0
- openapi/openapi-client/openapi_client/api_response.py +21 -0
- openapi/openapi-client/openapi_client/configuration.py +479 -0
- openapi/openapi-client/openapi_client/exceptions.py +199 -0
- openapi/openapi-client/openapi_client/models/__init__.py +192 -0
- openapi/openapi-client/openapi_client/models/add_validation_rapid_model.py +116 -0
- openapi/openapi-client/openapi_client/models/add_validation_rapid_model_payload.py +238 -0
- openapi/openapi-client/openapi_client/models/add_validation_rapid_model_truth.py +238 -0
- openapi/openapi-client/openapi_client/models/admin_order_model.py +103 -0
- openapi/openapi-client/openapi_client/models/admin_order_model_paged_result.py +105 -0
- openapi/openapi-client/openapi_client/models/age_group.py +40 -0
- openapi/openapi-client/openapi_client/models/age_user_filter_model.py +97 -0
- openapi/openapi-client/openapi_client/models/aggregator_type.py +46 -0
- openapi/openapi-client/openapi_client/models/attach_category_rapid_blueprint.py +98 -0
- openapi/openapi-client/openapi_client/models/attach_category_truth.py +96 -0
- openapi/openapi-client/openapi_client/models/base_error.py +90 -0
- openapi/openapi-client/openapi_client/models/bounding_box_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/bounding_box_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/bounding_box_truth.py +102 -0
- openapi/openapi-client/openapi_client/models/box_shape.py +122 -0
- openapi/openapi-client/openapi_client/models/classification_metadata.py +110 -0
- openapi/openapi-client/openapi_client/models/classification_metadata_filter_config.py +96 -0
- openapi/openapi-client/openapi_client/models/classify_payload.py +98 -0
- openapi/openapi-client/openapi_client/models/clone_dataset_model.py +98 -0
- openapi/openapi-client/openapi_client/models/clone_order_model.py +89 -0
- openapi/openapi-client/openapi_client/models/clone_order_result.py +89 -0
- openapi/openapi-client/openapi_client/models/compare_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/compare_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/compare_truth.py +96 -0
- openapi/openapi-client/openapi_client/models/compare_workflow_config.py +143 -0
- openapi/openapi-client/openapi_client/models/compare_workflow_config_rapid_selection_configs_inner.py +210 -0
- openapi/openapi-client/openapi_client/models/compare_workflow_config_referee.py +154 -0
- openapi/openapi-client/openapi_client/models/compare_workflow_model.py +106 -0
- openapi/openapi-client/openapi_client/models/conditional_validation_rapid_selection_config.py +113 -0
- openapi/openapi-client/openapi_client/models/correlated_rapid_selection_config.py +98 -0
- openapi/openapi-client/openapi_client/models/count_classification_metadata_filter_config.py +94 -0
- openapi/openapi-client/openapi_client/models/count_metadata.py +110 -0
- openapi/openapi-client/openapi_client/models/country_user_filter_model.py +96 -0
- openapi/openapi-client/openapi_client/models/create_client_model.py +89 -0
- openapi/openapi-client/openapi_client/models/create_complex_order_model.py +95 -0
- openapi/openapi-client/openapi_client/models/create_complex_order_model_pipeline.py +126 -0
- openapi/openapi-client/openapi_client/models/create_complex_order_result.py +96 -0
- openapi/openapi-client/openapi_client/models/create_dataset_artifact_model.py +102 -0
- openapi/openapi-client/openapi_client/models/create_dataset_artifact_model_dataset.py +126 -0
- openapi/openapi-client/openapi_client/models/create_default_order_model.py +109 -0
- openapi/openapi-client/openapi_client/models/create_default_order_model_workflow_config.py +140 -0
- openapi/openapi-client/openapi_client/models/create_empty_validation_set_result.py +87 -0
- openapi/openapi-client/openapi_client/models/create_legacy_order_result.py +89 -0
- openapi/openapi-client/openapi_client/models/create_order_model.py +163 -0
- openapi/openapi-client/openapi_client/models/create_order_model_referee.py +126 -0
- openapi/openapi-client/openapi_client/models/create_order_model_selections_inner.py +154 -0
- openapi/openapi-client/openapi_client/models/create_order_model_user_filters_inner.py +154 -0
- openapi/openapi-client/openapi_client/models/create_order_model_workflow.py +140 -0
- openapi/openapi-client/openapi_client/models/create_order_result.py +96 -0
- openapi/openapi-client/openapi_client/models/create_simple_pipeline_model.py +116 -0
- openapi/openapi-client/openapi_client/models/create_simple_pipeline_model_artifacts_inner.py +126 -0
- openapi/openapi-client/openapi_client/models/create_simple_pipeline_model_pipeline_steps_inner.py +182 -0
- openapi/openapi-client/openapi_client/models/create_unsupported_order_model.py +91 -0
- openapi/openapi-client/openapi_client/models/customer_order_model.py +101 -0
- openapi/openapi-client/openapi_client/models/customer_order_model_paged_result.py +105 -0
- openapi/openapi-client/openapi_client/models/datapoint.py +121 -0
- openapi/openapi-client/openapi_client/models/datapoint_asset.py +170 -0
- openapi/openapi-client/openapi_client/models/datapoint_get_by_id_get200_response.py +126 -0
- openapi/openapi-client/openapi_client/models/datapoint_metadata_model.py +97 -0
- openapi/openapi-client/openapi_client/models/datapoint_metadata_model_metadata_inner.py +168 -0
- openapi/openapi-client/openapi_client/models/datapoint_model.py +95 -0
- openapi/openapi-client/openapi_client/models/datapoint_model_asset.py +170 -0
- openapi/openapi-client/openapi_client/models/dataset_evaluation_step_model.py +102 -0
- openapi/openapi-client/openapi_client/models/demographic_rapid_selection_config.py +96 -0
- openapi/openapi-client/openapi_client/models/demographic_selection.py +96 -0
- openapi/openapi-client/openapi_client/models/empty_validation_truth.py +94 -0
- openapi/openapi-client/openapi_client/models/error_type.py +40 -0
- openapi/openapi-client/openapi_client/models/feature_flag.py +89 -0
- openapi/openapi-client/openapi_client/models/feature_flag_model.py +89 -0
- openapi/openapi-client/openapi_client/models/feedback_model.py +94 -0
- openapi/openapi-client/openapi_client/models/file_asset.py +108 -0
- openapi/openapi-client/openapi_client/models/file_asset_metadata_inner.py +224 -0
- openapi/openapi-client/openapi_client/models/file_asset_model.py +108 -0
- openapi/openapi-client/openapi_client/models/filter.py +134 -0
- openapi/openapi-client/openapi_client/models/filter_operator.py +44 -0
- openapi/openapi-client/openapi_client/models/free_text_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/free_text_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/gender.py +38 -0
- openapi/openapi-client/openapi_client/models/gender_user_filter_model.py +97 -0
- openapi/openapi-client/openapi_client/models/get_available_validation_sets_result.py +95 -0
- openapi/openapi-client/openapi_client/models/get_datapoints_by_dataset_id_result.py +95 -0
- openapi/openapi-client/openapi_client/models/get_dataset_by_id_result.py +87 -0
- openapi/openapi-client/openapi_client/models/get_order_by_id_result.py +98 -0
- openapi/openapi-client/openapi_client/models/get_order_results_result.py +91 -0
- openapi/openapi-client/openapi_client/models/get_public_orders_result.py +95 -0
- openapi/openapi-client/openapi_client/models/get_workflow_config_result.py +91 -0
- openapi/openapi-client/openapi_client/models/get_workflow_config_result_workflow_config.py +140 -0
- openapi/openapi-client/openapi_client/models/image_dimension_metadata.py +112 -0
- openapi/openapi-client/openapi_client/models/import_from_file_result.py +87 -0
- openapi/openapi-client/openapi_client/models/import_validation_set_from_file_result.py +87 -0
- openapi/openapi-client/openapi_client/models/issue_auth_token_result.py +87 -0
- openapi/openapi-client/openapi_client/models/issue_client_auth_token_result.py +87 -0
- openapi/openapi-client/openapi_client/models/labeling_selection.py +96 -0
- openapi/openapi-client/openapi_client/models/line_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/line_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/line_truth.py +94 -0
- openapi/openapi-client/openapi_client/models/locate_box_truth.py +104 -0
- openapi/openapi-client/openapi_client/models/locate_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/locate_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/location_metadata.py +112 -0
- openapi/openapi-client/openapi_client/models/location_metadata_exists_filter_config.py +94 -0
- openapi/openapi-client/openapi_client/models/logic_operator.py +37 -0
- openapi/openapi-client/openapi_client/models/login_model.py +89 -0
- openapi/openapi-client/openapi_client/models/metadata_visibilities.py +40 -0
- openapi/openapi-client/openapi_client/models/multi_asset.py +116 -0
- openapi/openapi-client/openapi_client/models/multi_asset_model.py +118 -0
- openapi/openapi-client/openapi_client/models/naive_referee_config.py +96 -0
- openapi/openapi-client/openapi_client/models/naive_referee_model.py +96 -0
- openapi/openapi-client/openapi_client/models/named_classification.py +100 -0
- openapi/openapi-client/openapi_client/models/named_entity_payload.py +98 -0
- openapi/openapi-client/openapi_client/models/named_entity_rapid_blueprint.py +98 -0
- openapi/openapi-client/openapi_client/models/named_entity_truth.py +104 -0
- openapi/openapi-client/openapi_client/models/never_ending_referee_config.py +94 -0
- openapi/openapi-client/openapi_client/models/newsletter_model.py +89 -0
- openapi/openapi-client/openapi_client/models/no_validation_workflow_rapid_selection_config.py +101 -0
- openapi/openapi-client/openapi_client/models/null_asset.py +104 -0
- openapi/openapi-client/openapi_client/models/null_asset_model.py +106 -0
- openapi/openapi-client/openapi_client/models/only_validation_workflow_rapid_selection_config.py +96 -0
- openapi/openapi-client/openapi_client/models/order_model.py +91 -0
- openapi/openapi-client/openapi_client/models/order_query_get200_response.py +137 -0
- openapi/openapi-client/openapi_client/models/original_filename_metadata.py +110 -0
- openapi/openapi-client/openapi_client/models/page_info.py +94 -0
- openapi/openapi-client/openapi_client/models/polygon_payload.py +96 -0
- openapi/openapi-client/openapi_client/models/polygon_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/polygon_truth.py +94 -0
- openapi/openapi-client/openapi_client/models/private_text_metadata_input.py +98 -0
- openapi/openapi-client/openapi_client/models/probabilistic_attach_category_referee_config.py +98 -0
- openapi/openapi-client/openapi_client/models/prompt_metadata.py +110 -0
- openapi/openapi-client/openapi_client/models/prompt_metadata_input.py +98 -0
- openapi/openapi-client/openapi_client/models/public_text_metadata_input.py +98 -0
- openapi/openapi-client/openapi_client/models/query_orders_model.py +112 -0
- openapi/openapi-client/openapi_client/models/query_validation_set_model.py +112 -0
- openapi/openapi-client/openapi_client/models/request_password_reset_command.py +98 -0
- openapi/openapi-client/openapi_client/models/root_filter.py +107 -0
- openapi/openapi-client/openapi_client/models/send_completion_mail_step_model.py +98 -0
- openapi/openapi-client/openapi_client/models/signup_customer_model.py +93 -0
- openapi/openapi-client/openapi_client/models/signup_shadow_customer_model.py +87 -0
- openapi/openapi-client/openapi_client/models/simple_workflow_config.py +137 -0
- openapi/openapi-client/openapi_client/models/simple_workflow_config_blueprint.py +238 -0
- openapi/openapi-client/openapi_client/models/simple_workflow_model.py +100 -0
- openapi/openapi-client/openapi_client/models/simple_workflow_model_blueprint.py +238 -0
- openapi/openapi-client/openapi_client/models/sort_criterion.py +96 -0
- openapi/openapi-client/openapi_client/models/sort_direction.py +37 -0
- openapi/openapi-client/openapi_client/models/static_rapid_selection_config.py +96 -0
- openapi/openapi-client/openapi_client/models/submit_coco_model.py +91 -0
- openapi/openapi-client/openapi_client/models/submit_coco_result.py +87 -0
- openapi/openapi-client/openapi_client/models/submit_password_reset_command.py +102 -0
- openapi/openapi-client/openapi_client/models/text_asset.py +106 -0
- openapi/openapi-client/openapi_client/models/text_asset_model.py +108 -0
- openapi/openapi-client/openapi_client/models/text_metadata.py +107 -0
- openapi/openapi-client/openapi_client/models/transcription_metadata.py +107 -0
- openapi/openapi-client/openapi_client/models/transcription_metadata_input.py +98 -0
- openapi/openapi-client/openapi_client/models/transcription_payload.py +106 -0
- openapi/openapi-client/openapi_client/models/transcription_rapid_blueprint.py +96 -0
- openapi/openapi-client/openapi_client/models/transcription_truth.py +106 -0
- openapi/openapi-client/openapi_client/models/transcription_word.py +89 -0
- openapi/openapi-client/openapi_client/models/unlock_order_result.py +87 -0
- openapi/openapi-client/openapi_client/models/update_access_model.py +87 -0
- openapi/openapi-client/openapi_client/models/update_order_model.py +87 -0
- openapi/openapi-client/openapi_client/models/update_workflow_config_model.py +100 -0
- openapi/openapi-client/openapi_client/models/update_workflow_config_model_workflow_config.py +140 -0
- openapi/openapi-client/openapi_client/models/upload_coco_result.py +91 -0
- openapi/openapi-client/openapi_client/models/upload_datapoints_result.py +97 -0
- openapi/openapi-client/openapi_client/models/upload_files_from_s3_bucket_model.py +116 -0
- openapi/openapi-client/openapi_client/models/upload_text_sources_to_dataset_model.py +89 -0
- openapi/openapi-client/openapi_client/models/validation_chance.py +91 -0
- openapi/openapi-client/openapi_client/models/validation_import_post_request_blueprint.py +238 -0
- openapi/openapi-client/openapi_client/models/validation_rapid_selection_config.py +98 -0
- openapi/openapi-client/openapi_client/models/validation_selection.py +98 -0
- openapi/openapi-client/openapi_client/models/validation_set.py +105 -0
- openapi/openapi-client/openapi_client/models/validation_set_overview_model.py +91 -0
- openapi/openapi-client/openapi_client/models/validation_set_paged_result.py +105 -0
- openapi/openapi-client/openapi_client/models/workflow_aggregation_step_model.py +112 -0
- openapi/openapi-client/openapi_client/models/workflow_labeling_step_model.py +96 -0
- openapi/openapi-client/openapi_client/models/workflow_split_model.py +110 -0
- openapi/openapi-client/openapi_client/models/workflow_split_model_filter_configs_inner.py +154 -0
- openapi/openapi-client/openapi_client/rest.py +257 -0
- rapidata/rapidata_client/{workflow/feature_flags → feature_flags}/feature_flags.py +5 -3
- rapidata/rapidata_client/metadata/__init__.py +0 -0
- rapidata/rapidata_client/metadata/base_metadata.py +12 -0
- rapidata/rapidata_client/metadata/transcription_metadata.py +19 -0
- rapidata/rapidata_client/order/dataset/rapidata_dataset.py +42 -16
- rapidata/rapidata_client/order/dataset/validation_set_builder.py +187 -0
- rapidata/rapidata_client/order/rapidata_order.py +49 -23
- rapidata/rapidata_client/order/rapidata_order_builder.py +126 -8
- rapidata/rapidata_client/rapidata_client.py +17 -5
- rapidata/rapidata_client/{workflow/referee → referee}/base_referee.py +8 -2
- rapidata/rapidata_client/{workflow/referee → referee}/classify_early_stopping_referee.py +1 -1
- rapidata/rapidata_client/{workflow/referee → referee}/naive_referee.py +5 -1
- rapidata/rapidata_client/workflow/__init__.py +0 -2
- rapidata/rapidata_client/workflow/base_workflow.py +9 -5
- rapidata/rapidata_client/workflow/classify_workflow.py +18 -3
- rapidata/rapidata_client/workflow/compare_workflow.py +13 -14
- rapidata/rapidata_client/workflow/free_text_workflow.py +14 -0
- rapidata/rapidata_client/workflow/transcription_workflow.py +22 -0
- rapidata/service/__init__.py +0 -1
- rapidata/service/openapi_service.py +43 -0
- {rapidata-0.1.2.dist-info → rapidata-0.1.5.dist-info}/METADATA +1 -1
- rapidata-0.1.5.dist-info/RECORD +227 -0
- rapidata/service/rapidata_api_services/base_service.py +0 -76
- rapidata/service/rapidata_api_services/dataset_service.py +0 -82
- rapidata/service/rapidata_api_services/order_service.py +0 -49
- rapidata/service/rapidata_api_services/rapidata_service.py +0 -18
- rapidata-0.1.2.dist-info/RECORD +0 -34
- /rapidata/service/rapidata_api_services/__init__.py → /openapi/openapi-client/openapi_client/py.typed +0 -0
- /rapidata/rapidata_client/{workflow/country_codes → country_codes}/__init__.py +0 -0
- /rapidata/rapidata_client/{workflow/country_codes → country_codes}/country_codes.py +0 -0
- /rapidata/rapidata_client/{workflow/feature_flags → feature_flags}/__init__.py +0 -0
- /rapidata/rapidata_client/{workflow/referee → referee}/__init__.py +0 -0
- {rapidata-0.1.2.dist-info → rapidata-0.1.5.dist-info}/LICENSE +0 -0
- {rapidata-0.1.2.dist-info → rapidata-0.1.5.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
import os
|
|
3
|
+
from typing import Any, Union
|
|
4
|
+
from openapi_client.models.add_validation_rapid_model import AddValidationRapidModel
|
|
5
|
+
from openapi_client.models.add_validation_rapid_model_payload import (
|
|
6
|
+
AddValidationRapidModelPayload,
|
|
7
|
+
)
|
|
8
|
+
from openapi_client.models.add_validation_rapid_model_truth import (
|
|
9
|
+
AddValidationRapidModelTruth,
|
|
10
|
+
)
|
|
11
|
+
from openapi_client.models.attach_category_truth import AttachCategoryTruth
|
|
12
|
+
from openapi_client.models.bounding_box_payload import BoundingBoxPayload
|
|
13
|
+
from openapi_client.models.bounding_box_truth import BoundingBoxTruth
|
|
14
|
+
from openapi_client.models.classify_payload import ClassifyPayload
|
|
15
|
+
from openapi_client.models.compare_payload import ComparePayload
|
|
16
|
+
from openapi_client.models.compare_truth import CompareTruth
|
|
17
|
+
from openapi_client.models.empty_validation_truth import EmptyValidationTruth
|
|
18
|
+
from openapi_client.models.free_text_payload import FreeTextPayload
|
|
19
|
+
from openapi_client.models.line_payload import LinePayload
|
|
20
|
+
from openapi_client.models.line_truth import LineTruth
|
|
21
|
+
from openapi_client.models.locate_box_truth import LocateBoxTruth
|
|
22
|
+
from openapi_client.models.locate_payload import LocatePayload
|
|
23
|
+
from openapi_client.models.named_entity_payload import NamedEntityPayload
|
|
24
|
+
from openapi_client.models.named_entity_truth import NamedEntityTruth
|
|
25
|
+
from openapi_client.models.polygon_payload import PolygonPayload
|
|
26
|
+
from openapi_client.models.polygon_truth import PolygonTruth
|
|
27
|
+
from openapi_client.models.transcription_payload import TranscriptionPayload
|
|
28
|
+
from openapi_client.models.transcription_truth import TranscriptionTruth
|
|
29
|
+
from openapi_client.models.transcription_word import TranscriptionWord
|
|
30
|
+
from rapidata.service.openapi_service import OpenAPIService
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class ValidatioRapidParts:
|
|
35
|
+
question: str
|
|
36
|
+
media_paths: str | list[str]
|
|
37
|
+
payload: Union[
|
|
38
|
+
BoundingBoxPayload,
|
|
39
|
+
ClassifyPayload,
|
|
40
|
+
ComparePayload,
|
|
41
|
+
FreeTextPayload,
|
|
42
|
+
LinePayload,
|
|
43
|
+
LocatePayload,
|
|
44
|
+
NamedEntityPayload,
|
|
45
|
+
PolygonPayload,
|
|
46
|
+
TranscriptionPayload,
|
|
47
|
+
]
|
|
48
|
+
truths: Union[
|
|
49
|
+
AttachCategoryTruth,
|
|
50
|
+
BoundingBoxTruth,
|
|
51
|
+
CompareTruth,
|
|
52
|
+
EmptyValidationTruth,
|
|
53
|
+
LineTruth,
|
|
54
|
+
LocateBoxTruth,
|
|
55
|
+
NamedEntityTruth,
|
|
56
|
+
PolygonTruth,
|
|
57
|
+
TranscriptionTruth,
|
|
58
|
+
]
|
|
59
|
+
metadata: Any
|
|
60
|
+
randomCorrectProbability: float
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ValidationSetBuilder:
|
|
64
|
+
|
|
65
|
+
def __init__(self, name: str, openapi_service: OpenAPIService):
|
|
66
|
+
self.name = name
|
|
67
|
+
self.openapi_service = openapi_service
|
|
68
|
+
self.validation_set_id: str | None = None
|
|
69
|
+
self._rapid_parts: list[ValidatioRapidParts] = []
|
|
70
|
+
|
|
71
|
+
def create(self):
|
|
72
|
+
result = (
|
|
73
|
+
self.openapi_service.validation_api.validation_create_validation_set_post(
|
|
74
|
+
name=self.name
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
self.validation_set_id = result.validation_set_id
|
|
78
|
+
|
|
79
|
+
if self.validation_set_id is None:
|
|
80
|
+
raise ValueError("Failed to create validation set")
|
|
81
|
+
|
|
82
|
+
for rapid_part in self._rapid_parts:
|
|
83
|
+
model = AddValidationRapidModel(
|
|
84
|
+
validationSetId=self.validation_set_id,
|
|
85
|
+
payload=AddValidationRapidModelPayload(rapid_part.payload),
|
|
86
|
+
truth=AddValidationRapidModelTruth(rapid_part.truths),
|
|
87
|
+
metadata=rapid_part.metadata or [],
|
|
88
|
+
randomCorrectProbability=rapid_part.randomCorrectProbability,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
self.openapi_service.validation_api.validation_add_validation_rapid_post(
|
|
92
|
+
model=model, files=rapid_part.media_paths if isinstance(rapid_part.media_paths, list) else [rapid_part.media_paths] # type: ignore
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return str(self.validation_set_id)
|
|
96
|
+
|
|
97
|
+
def add_classify_rapid(
|
|
98
|
+
self, media_path: str, question: str, categories: list[str], truths: list[str]
|
|
99
|
+
):
|
|
100
|
+
payload = ClassifyPayload(
|
|
101
|
+
_t="ClassifyPaylod", possibleCategories=categories, title=question
|
|
102
|
+
)
|
|
103
|
+
model_truth = AttachCategoryTruth(
|
|
104
|
+
correctCategories=truths, _t="AttachCategoryTruth"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
self._rapid_parts.append(
|
|
108
|
+
ValidatioRapidParts(
|
|
109
|
+
question=question,
|
|
110
|
+
media_paths=media_path,
|
|
111
|
+
payload=payload,
|
|
112
|
+
truths=model_truth,
|
|
113
|
+
metadata=None,
|
|
114
|
+
randomCorrectProbability=len(truths) / len(categories),
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
return self
|
|
119
|
+
|
|
120
|
+
def add_compare_rapid(self, media_paths: list[str], question: str, truth: str):
|
|
121
|
+
payload = ComparePayload(_t="ComparePayload", criteria=question)
|
|
122
|
+
model_truth = CompareTruth(_t="CompareTruth", winnerId=truth)
|
|
123
|
+
|
|
124
|
+
if len(media_paths) != 2:
|
|
125
|
+
raise ValueError("Compare rapid requires exactly two media paths")
|
|
126
|
+
|
|
127
|
+
# check that files exist
|
|
128
|
+
for media_path in media_paths:
|
|
129
|
+
if not os.path.exists(media_path):
|
|
130
|
+
raise FileNotFoundError(f"File not found: {media_path}")
|
|
131
|
+
|
|
132
|
+
self._rapid_parts.append(
|
|
133
|
+
ValidatioRapidParts(
|
|
134
|
+
question=question,
|
|
135
|
+
media_paths=media_paths,
|
|
136
|
+
payload=payload,
|
|
137
|
+
truths=model_truth,
|
|
138
|
+
metadata=None,
|
|
139
|
+
randomCorrectProbability=1 / len(media_paths),
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
return self
|
|
144
|
+
|
|
145
|
+
def add_transcription_rapid(
|
|
146
|
+
self,
|
|
147
|
+
media_path: str,
|
|
148
|
+
question: str,
|
|
149
|
+
transcription: list[str],
|
|
150
|
+
correct_words: list[str],
|
|
151
|
+
strict_grading: bool | None = None,
|
|
152
|
+
):
|
|
153
|
+
transcription_words = [
|
|
154
|
+
TranscriptionWord(word=word, wordIndex=i)
|
|
155
|
+
for i, word in enumerate(transcription)
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
correct_transcription_words = []
|
|
159
|
+
for word in correct_words:
|
|
160
|
+
if word not in transcription:
|
|
161
|
+
raise ValueError(f"Correct word '{word}' not found in transcription")
|
|
162
|
+
correct_transcription_words.append(
|
|
163
|
+
TranscriptionWord(word=word, wordIndex=transcription.index(word))
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
payload = TranscriptionPayload(
|
|
167
|
+
_t="TranscriptionPayload", title=question, transcription=transcription_words
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
model_truth = TranscriptionTruth(
|
|
171
|
+
_t="TranscriptionTruth",
|
|
172
|
+
correctWords=correct_transcription_words,
|
|
173
|
+
strictGrading=strict_grading,
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
self._rapid_parts.append(
|
|
177
|
+
ValidatioRapidParts(
|
|
178
|
+
question=question,
|
|
179
|
+
media_paths=media_path,
|
|
180
|
+
payload=payload,
|
|
181
|
+
truths=model_truth,
|
|
182
|
+
metadata=None,
|
|
183
|
+
randomCorrectProbability=1 / len(transcription),
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
return self
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import time
|
|
2
|
+
from openapi_client.models.create_order_model_referee import CreateOrderModelReferee
|
|
3
|
+
from openapi_client.models.create_order_model_workflow import CreateOrderModelWorkflow
|
|
1
4
|
from rapidata.rapidata_client.order.dataset.rapidata_dataset import RapidataDataset
|
|
2
5
|
from rapidata.rapidata_client.workflow import Workflow
|
|
3
|
-
from
|
|
6
|
+
from openapi_client.models.create_order_model import CreateOrderModel
|
|
7
|
+
from rapidata.rapidata_client.referee import Referee
|
|
8
|
+
from rapidata.service.openapi_service import OpenAPIService
|
|
4
9
|
|
|
5
10
|
|
|
6
11
|
class RapidataOrder:
|
|
@@ -16,13 +21,14 @@ class RapidataOrder:
|
|
|
16
21
|
"""
|
|
17
22
|
|
|
18
23
|
def __init__(
|
|
19
|
-
self,
|
|
24
|
+
self,
|
|
25
|
+
order_id: str,
|
|
26
|
+
dataset: RapidataDataset,
|
|
27
|
+
openapi_service: OpenAPIService,
|
|
20
28
|
):
|
|
21
|
-
self.
|
|
22
|
-
self.
|
|
23
|
-
self.
|
|
24
|
-
self.order_id = None
|
|
25
|
-
self._dataset = None
|
|
29
|
+
self.openapi_service = openapi_service
|
|
30
|
+
self.order_id = order_id
|
|
31
|
+
self._dataset = dataset
|
|
26
32
|
|
|
27
33
|
def create(self):
|
|
28
34
|
"""
|
|
@@ -31,41 +37,61 @@ class RapidataOrder:
|
|
|
31
37
|
:return: The created RapidataOrder instance.
|
|
32
38
|
:rtype: RapidataOrder
|
|
33
39
|
"""
|
|
34
|
-
self.order_id, dataset_id = self.rapidata_service.order.create_order(self.name, self.workflow.to_dict())
|
|
35
|
-
self._dataset = RapidataDataset(dataset_id, self.rapidata_service)
|
|
36
|
-
return self
|
|
37
40
|
|
|
38
41
|
def submit(self):
|
|
39
42
|
"""
|
|
40
43
|
Submits the order for processing.
|
|
41
|
-
|
|
42
|
-
:raises ValueError: If the order has not been created.
|
|
43
44
|
"""
|
|
44
|
-
if self.order_id is None:
|
|
45
|
-
raise ValueError("You must create the order before submitting it.")
|
|
46
45
|
|
|
47
|
-
self.
|
|
46
|
+
self.openapi_service.order_api.order_submit_post(self.order_id)
|
|
48
47
|
|
|
49
48
|
def approve(self):
|
|
50
49
|
"""
|
|
51
50
|
Approves the order for execution.
|
|
51
|
+
"""
|
|
52
|
+
self.openapi_service.order_api.order_approve_post(self.order_id)
|
|
53
|
+
|
|
54
|
+
def get_status(self):
|
|
55
|
+
"""
|
|
56
|
+
Gets the status of the order.
|
|
57
|
+
|
|
58
|
+
:return: The status of the order.
|
|
59
|
+
:rtype: str
|
|
60
|
+
"""
|
|
61
|
+
return self.openapi_service.order_api.order_get_by_id_get(self.order_id)
|
|
52
62
|
|
|
53
|
-
|
|
63
|
+
def wait_for_done(self):
|
|
54
64
|
"""
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
Blocking call that waits for the order to be done. Exponential backoff is used to check the status of the order.
|
|
66
|
+
"""
|
|
67
|
+
wait_time = 2
|
|
68
|
+
back_off_factor = 1.5
|
|
69
|
+
minimum_poll_interval = 60 * 10 # 10 minutes
|
|
70
|
+
|
|
71
|
+
while True:
|
|
72
|
+
time.sleep(wait_time)
|
|
73
|
+
result = self.get_status()
|
|
74
|
+
if result.state == "Completed":
|
|
75
|
+
break
|
|
76
|
+
wait_time = max(
|
|
77
|
+
minimum_poll_interval, wait_time * back_off_factor
|
|
78
|
+
) # poll at least every 10 minutes
|
|
79
|
+
|
|
80
|
+
def get_results(self):
|
|
81
|
+
"""
|
|
82
|
+
Gets the results of the order.
|
|
57
83
|
|
|
58
|
-
|
|
84
|
+
:return: The results of the order.
|
|
85
|
+
:rtype: dict
|
|
86
|
+
"""
|
|
87
|
+
# return self.openapi_service.order_api.order_get_order_results_get(self.order_id) # throws error
|
|
88
|
+
raise NotImplementedError("Currently not supported")
|
|
59
89
|
|
|
60
90
|
@property
|
|
61
91
|
def dataset(self):
|
|
62
92
|
"""
|
|
63
93
|
The dataset associated with the order.
|
|
64
|
-
|
|
65
|
-
:raises ValueError: If the order has not been submitted.
|
|
66
94
|
:return: The RapidataDataset instance.
|
|
67
95
|
:rtype: RapidataDataset
|
|
68
96
|
"""
|
|
69
|
-
if self._dataset is None:
|
|
70
|
-
raise ValueError("You must submit the order before accessing the dataset.")
|
|
71
97
|
return self._dataset
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
from openapi_client.models.aggregator_type import AggregatorType
|
|
2
|
+
from openapi_client.models.create_order_model import CreateOrderModel
|
|
3
|
+
from openapi_client.models.create_order_model_referee import CreateOrderModelReferee
|
|
4
|
+
from openapi_client.models.create_order_model_workflow import CreateOrderModelWorkflow
|
|
5
|
+
from rapidata.rapidata_client.feature_flags import FeatureFlags
|
|
6
|
+
from rapidata.rapidata_client.metadata.base_metadata import Metadata
|
|
7
|
+
from rapidata.rapidata_client.order.dataset.rapidata_dataset import RapidataDataset
|
|
8
|
+
from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
|
|
1
9
|
from rapidata.rapidata_client.workflow import Workflow
|
|
2
10
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
3
|
-
from rapidata.
|
|
11
|
+
from rapidata.rapidata_client.referee import Referee
|
|
12
|
+
from rapidata.service.openapi_service import OpenAPIService
|
|
4
13
|
|
|
5
14
|
|
|
6
15
|
class RapidataOrderBuilder:
|
|
@@ -17,16 +26,22 @@ class RapidataOrderBuilder:
|
|
|
17
26
|
|
|
18
27
|
def __init__(
|
|
19
28
|
self,
|
|
20
|
-
|
|
29
|
+
openapi_service: OpenAPIService,
|
|
21
30
|
name: str,
|
|
22
31
|
):
|
|
23
32
|
self._name = name
|
|
24
|
-
self.
|
|
33
|
+
self._openapi_service = openapi_service
|
|
25
34
|
self._workflow: Workflow | None = None
|
|
35
|
+
self._referee: Referee | None = None
|
|
36
|
+
self._media_paths: list[str] = []
|
|
37
|
+
self._metadata: list[Metadata] | None = None
|
|
38
|
+
self._aggregator: AggregatorType | None = None
|
|
39
|
+
self._validation_set_id: str | None = None
|
|
40
|
+
self._feature_flags: FeatureFlags | None = None
|
|
26
41
|
|
|
27
|
-
def create(self) -> RapidataOrder:
|
|
42
|
+
def create(self, submit=True) -> RapidataOrder:
|
|
28
43
|
"""
|
|
29
|
-
|
|
44
|
+
Actually makes the API calls to create the order based on how the order builder was configures. Returns a RapidataOrder instance based on the created order with order_id and dataset_id.
|
|
30
45
|
|
|
31
46
|
:return: The created RapidataOrder instance.
|
|
32
47
|
:rtype: RapidataOrder
|
|
@@ -35,9 +50,33 @@ class RapidataOrderBuilder:
|
|
|
35
50
|
if self._workflow is None:
|
|
36
51
|
raise ValueError("You must provide a blueprint to create an order.")
|
|
37
52
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
if self._referee is None:
|
|
54
|
+
print("No referee provided, using default NaiveReferee.")
|
|
55
|
+
self._referee = NaiveReferee()
|
|
56
|
+
|
|
57
|
+
order_model = CreateOrderModel(
|
|
58
|
+
orderName=self._name,
|
|
59
|
+
workflow=CreateOrderModelWorkflow(self._workflow.to_model()),
|
|
60
|
+
userFilters=[],
|
|
61
|
+
referee=CreateOrderModelReferee(self._referee.to_model()),
|
|
62
|
+
validationSetId=self._validation_set_id,
|
|
63
|
+
featureFlags=self._feature_flags.to_list() if self._feature_flags is not None else None,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
result = self._openapi_service.order_api.order_create_post(
|
|
67
|
+
create_order_model=order_model
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
self.order_id = result.order_id
|
|
71
|
+
self._dataset = RapidataDataset(result.dataset_id, self._openapi_service)
|
|
72
|
+
order = RapidataOrder(order_id=self.order_id, dataset=self._dataset, openapi_service=self._openapi_service)
|
|
73
|
+
|
|
74
|
+
order.dataset.add_media_from_paths(self._media_paths, self._metadata)
|
|
75
|
+
|
|
76
|
+
if submit:
|
|
77
|
+
order.submit()
|
|
78
|
+
|
|
79
|
+
return order
|
|
41
80
|
|
|
42
81
|
def workflow(self, workflow: Workflow):
|
|
43
82
|
"""
|
|
@@ -50,3 +89,82 @@ class RapidataOrderBuilder:
|
|
|
50
89
|
"""
|
|
51
90
|
self._workflow = workflow
|
|
52
91
|
return self
|
|
92
|
+
|
|
93
|
+
def referee(self, referee: Referee):
|
|
94
|
+
"""
|
|
95
|
+
Set the referee for the order.
|
|
96
|
+
|
|
97
|
+
:param referee: The referee to be set.
|
|
98
|
+
:type referee: Referee
|
|
99
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
100
|
+
:rtype: RapidataOrderBuilder
|
|
101
|
+
"""
|
|
102
|
+
self._referee = referee
|
|
103
|
+
return self
|
|
104
|
+
|
|
105
|
+
def media(
|
|
106
|
+
self, media_paths: list[str], metadata: list[Metadata] | None = None):
|
|
107
|
+
"""
|
|
108
|
+
Set the media assets for the order.
|
|
109
|
+
|
|
110
|
+
:param media_paths: The paths of the media assets to be set.
|
|
111
|
+
:type media_paths: list[str]
|
|
112
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
113
|
+
:rtype: RapidataOrderBuilder
|
|
114
|
+
"""
|
|
115
|
+
self._media_paths = media_paths
|
|
116
|
+
self._metadata = metadata
|
|
117
|
+
return self
|
|
118
|
+
|
|
119
|
+
def feature_flags(self, feature_flags: FeatureFlags):
|
|
120
|
+
"""
|
|
121
|
+
Set the feature flags for the order.
|
|
122
|
+
|
|
123
|
+
:param feature_flags: The feature flags to be set.
|
|
124
|
+
:type feature_flags: FeatureFlags
|
|
125
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
126
|
+
:rtype: RapidataOrderBuilder
|
|
127
|
+
"""
|
|
128
|
+
self._feature_flags = feature_flags
|
|
129
|
+
return self
|
|
130
|
+
|
|
131
|
+
def target_country_codes(self, country_codes: list[str]):
|
|
132
|
+
"""
|
|
133
|
+
Set the target country codes for the order.
|
|
134
|
+
|
|
135
|
+
:param country_codes: The country codes to be set.
|
|
136
|
+
:type country_codes: list[str]
|
|
137
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
138
|
+
:rtype: RapidataOrderBuilder
|
|
139
|
+
"""
|
|
140
|
+
if self._workflow is None:
|
|
141
|
+
raise ValueError(
|
|
142
|
+
"You must set the workflow before setting the target country codes."
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
self._workflow.target_country_codes(country_codes)
|
|
146
|
+
return self
|
|
147
|
+
|
|
148
|
+
def aggregator(self, aggregator: AggregatorType):
|
|
149
|
+
"""
|
|
150
|
+
Set the aggregator for the order.
|
|
151
|
+
|
|
152
|
+
:param aggregator: The aggregator to be set.
|
|
153
|
+
:type aggregator: AggregatorType
|
|
154
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
155
|
+
:rtype: RapidataOrderBuilder
|
|
156
|
+
"""
|
|
157
|
+
self._aggregator = aggregator
|
|
158
|
+
return self
|
|
159
|
+
|
|
160
|
+
def validation_set(self, validation_set_id: str):
|
|
161
|
+
"""
|
|
162
|
+
Set the validation set for the order.
|
|
163
|
+
|
|
164
|
+
:param validation_set_id: The validation set ID to be set.
|
|
165
|
+
:type validation_set_id: str
|
|
166
|
+
:return: The updated RapidataOrderBuilder instance.
|
|
167
|
+
:rtype: RapidataOrderBuilder
|
|
168
|
+
"""
|
|
169
|
+
self._validation_set_id = validation_set_id
|
|
170
|
+
return self
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
from rapidata.rapidata_client.order.dataset.validation_set_builder import ValidationSetBuilder
|
|
1
2
|
from rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder
|
|
2
|
-
from rapidata.service import
|
|
3
|
-
|
|
3
|
+
from rapidata.service.openapi_service import OpenAPIService
|
|
4
4
|
|
|
5
5
|
class RapidataClient:
|
|
6
6
|
"""
|
|
@@ -11,7 +11,7 @@ class RapidataClient:
|
|
|
11
11
|
self,
|
|
12
12
|
client_id: str,
|
|
13
13
|
client_secret: str,
|
|
14
|
-
endpoint: str = "https://api.rapidata.ai",
|
|
14
|
+
endpoint: str = "https://api.app.rapidata.ai",
|
|
15
15
|
):
|
|
16
16
|
"""
|
|
17
17
|
Initialize the RapidataClient.
|
|
@@ -20,10 +20,12 @@ class RapidataClient:
|
|
|
20
20
|
:param client_secret: The client secret for authentication.
|
|
21
21
|
:param endpoint: The API endpoint URL. Defaults to "https://api.rapidata.ai".
|
|
22
22
|
"""
|
|
23
|
-
self.
|
|
23
|
+
self.openapi_service = OpenAPIService(
|
|
24
24
|
client_id=client_id, client_secret=client_secret, endpoint=endpoint
|
|
25
25
|
)
|
|
26
26
|
|
|
27
|
+
|
|
28
|
+
|
|
27
29
|
def new_order(self, name: str) -> RapidataOrderBuilder:
|
|
28
30
|
"""
|
|
29
31
|
Create a new order using a RapidataOrderBuilder instance.
|
|
@@ -31,4 +33,14 @@ class RapidataClient:
|
|
|
31
33
|
:param name: The name of the order.
|
|
32
34
|
:return: A RapidataOrderBuilder instance.
|
|
33
35
|
"""
|
|
34
|
-
return RapidataOrderBuilder(
|
|
36
|
+
return RapidataOrderBuilder(openapi_service=self.openapi_service, name=name)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def new_validation_set(self, name: str) -> ValidationSetBuilder:
|
|
40
|
+
"""
|
|
41
|
+
Create a new validation set using a ValidationDatasetBuilder instance.
|
|
42
|
+
|
|
43
|
+
:param name: The name of the validation set.
|
|
44
|
+
:return: A ValidationDatasetBuilder instance.
|
|
45
|
+
"""
|
|
46
|
+
return ValidationSetBuilder(name=name, openapi_service=self.openapi_service)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import Mapping
|
|
3
|
-
|
|
2
|
+
from typing import Any, Mapping
|
|
4
3
|
|
|
5
4
|
class Referee(ABC):
|
|
6
5
|
"""
|
|
@@ -11,4 +10,11 @@ class Referee(ABC):
|
|
|
11
10
|
"""
|
|
12
11
|
Convert the referee to a referee configuration dict.
|
|
13
12
|
"""
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
@abstractmethod
|
|
16
|
+
def to_model(self) -> Any:
|
|
17
|
+
"""
|
|
18
|
+
Convert the referee to a referee configuration model.
|
|
19
|
+
"""
|
|
14
20
|
pass
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
from
|
|
1
|
+
from openapi_client.models.naive_referee_model import NaiveRefereeModel
|
|
2
|
+
from rapidata.rapidata_client.referee.base_referee import Referee
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class NaiveReferee(Referee):
|
|
@@ -16,3 +17,6 @@ class NaiveReferee(Referee):
|
|
|
16
17
|
"_t": "NaiveRefereeConfig",
|
|
17
18
|
"guessesRequired": self.required_guesses,
|
|
18
19
|
}
|
|
20
|
+
|
|
21
|
+
def to_model(self):
|
|
22
|
+
return NaiveRefereeModel(_t="NaiveReferee", totalVotes=self.required_guesses)
|
|
@@ -2,5 +2,3 @@ from .base_workflow import Workflow as Workflow
|
|
|
2
2
|
from .classify_workflow import ClassifyWorkflow as ClassifyWorkflow
|
|
3
3
|
from .compare_workflow import CompareWorkflow as CompareWorkflow
|
|
4
4
|
from .free_text_workflow import FreeTextWorkflow as FreeTextWorkflow
|
|
5
|
-
from .feature_flags import FeatureFlags as FeatureFlags
|
|
6
|
-
from .country_codes import CountryCodes as CountryCodes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
from abc import ABC
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
2
|
from typing import Any
|
|
3
3
|
|
|
4
|
-
from
|
|
5
|
-
from rapidata.rapidata_client.
|
|
6
|
-
from rapidata.rapidata_client.
|
|
4
|
+
from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
|
|
5
|
+
from rapidata.rapidata_client.feature_flags import FeatureFlags
|
|
6
|
+
from rapidata.rapidata_client.referee.base_referee import Referee
|
|
7
|
+
from rapidata.rapidata_client.referee.naive_referee import NaiveReferee
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
class Workflow(ABC):
|
|
10
11
|
|
|
11
12
|
def __init__(self, type: str):
|
|
12
13
|
self._type = type
|
|
13
|
-
self._referee = NaiveReferee()
|
|
14
14
|
self._target_country_codes: list[str] = []
|
|
15
15
|
self._feature_flags: FeatureFlags = FeatureFlags()
|
|
16
16
|
|
|
@@ -21,6 +21,10 @@ class Workflow(ABC):
|
|
|
21
21
|
"targetCountryCodes": self._target_country_codes,
|
|
22
22
|
"featureFlags": self._feature_flags.to_list(),
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
@abstractmethod
|
|
26
|
+
def to_model(self) -> SimpleWorkflowModel:
|
|
27
|
+
pass
|
|
24
28
|
|
|
25
29
|
def referee(self, referee: Referee):
|
|
26
30
|
self._referee = referee
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
+
from openapi_client.models.attach_category_rapid_blueprint import AttachCategoryRapidBlueprint
|
|
3
|
+
from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
|
|
4
|
+
from openapi_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint
|
|
2
5
|
from rapidata.rapidata_client.workflow import Workflow
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
class ClassifyWorkflow(Workflow):
|
|
6
|
-
def __init__(self, question: str,
|
|
9
|
+
def __init__(self, question: str, options: list[str]):
|
|
7
10
|
super().__init__(type="SimpleWorkflowConfig")
|
|
8
11
|
self._question = question
|
|
9
|
-
self.
|
|
12
|
+
self._options = options
|
|
10
13
|
|
|
11
14
|
def to_dict(self) -> dict[str, Any]:
|
|
12
15
|
return {
|
|
@@ -14,6 +17,18 @@ class ClassifyWorkflow(Workflow):
|
|
|
14
17
|
"blueprint": {
|
|
15
18
|
"_t": "ClassifyBlueprint",
|
|
16
19
|
"title": self._question,
|
|
17
|
-
"possibleCategories": self.
|
|
20
|
+
"possibleCategories": self._options,
|
|
18
21
|
}
|
|
19
22
|
}
|
|
23
|
+
|
|
24
|
+
def to_model(self) -> SimpleWorkflowModel:
|
|
25
|
+
blueprint = AttachCategoryRapidBlueprint(
|
|
26
|
+
_t="ClassifyBlueprint",
|
|
27
|
+
title=self._question,
|
|
28
|
+
possibleCategories=self._options,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
return SimpleWorkflowModel(
|
|
32
|
+
_t="SimpleWorkflow",
|
|
33
|
+
blueprint=SimpleWorkflowModelBlueprint(blueprint),
|
|
34
|
+
)
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
from typing import Any
|
|
2
|
+
from openapi_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint
|
|
2
3
|
from rapidata.rapidata_client.workflow import Workflow
|
|
4
|
+
from openapi_client.models.compare_rapid_blueprint import CompareRapidBlueprint
|
|
5
|
+
from openapi_client.models.simple_workflow_model import SimpleWorkflowModel
|
|
3
6
|
|
|
4
7
|
|
|
5
8
|
class CompareWorkflow(Workflow):
|
|
6
9
|
def __init__(self, criteria: str):
|
|
7
10
|
super().__init__(type="CompareWorkflowConfig")
|
|
8
11
|
self._criteria = criteria
|
|
9
|
-
self._k_factor = 40
|
|
10
|
-
self._match_size = 2
|
|
11
|
-
self._matches_until_completed = 10
|
|
12
12
|
|
|
13
13
|
def to_dict(self) -> dict[str, Any]:
|
|
14
14
|
return {
|
|
@@ -16,15 +16,14 @@ class CompareWorkflow(Workflow):
|
|
|
16
16
|
"criteria": self._criteria,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return self
|
|
19
|
+
def to_model(self) -> SimpleWorkflowModel:
|
|
20
|
+
blueprint = CompareRapidBlueprint(
|
|
21
|
+
_t="CompareBlueprint",
|
|
22
|
+
criteria=self._criteria,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
return SimpleWorkflowModel(
|
|
26
|
+
_t="SimpleWorkflow",
|
|
27
|
+
blueprint=SimpleWorkflowModelBlueprint(blueprint),
|
|
28
|
+
)
|
|
30
29
|
|