├── .github └── workflows │ ├── deploy_doc.yml │ ├── docs_gh_pages.yml │ ├── pyright-type-checking.yml │ ├── release_and_publish.yml │ └── update-openapi-client.yml ├── .gitignore ├── .openapi-generator-ignore ├── .vscode └── settings.json ├── CNAME ├── LICENSE ├── README.md ├── docs ├── api.md ├── confidence_stopping.md ├── examples │ ├── classify_order.md │ ├── compare_order.md │ ├── draw_order.md │ ├── free_text_order.md │ ├── locate_order.md │ ├── select_words_audio_order.md │ └── select_words_order.md ├── human_prompting.md ├── improve_order_quality.md ├── index.md ├── js │ └── tawk.js ├── media │ ├── compare_quickstart.png │ ├── order-types │ │ └── good_bad_ai_image.png │ └── rapidata.svg ├── plots │ └── confidence_threshold_plot_with_slider_darkmode.html ├── quickstart.md ├── stylesheets │ └── extra.css └── understanding_the_results.md ├── examples ├── .env example ├── advanced_classify_order.py ├── advanced_compare_order.py ├── advanced_free_text_order.py ├── basic_classify_order_image.py ├── basic_compare_order.py ├── basic_draw_order.py ├── basic_free_text_order.py ├── basic_locate_order.py ├── basic_select_words_order.py ├── classify_order.py ├── classify_text_asset_order.py ├── compare_order.py ├── compare_prompt_image_alignment.py ├── complex_compare_order.py ├── conditional_validation_rapid_selection.py ├── data │ ├── rapidata_concept_logo.jpg │ ├── rapidata_logo.png │ ├── waiting.mp4 │ └── wallaby.jpg ├── free_text_order.py ├── ranking_order.py ├── select_faulty_prompt_order.py └── select_words_order.py ├── mkdocs.yml ├── openapi ├── .gitignore ├── config.yaml ├── download-and-merge-spec.sh ├── generate.sh ├── openapi-merge.json ├── output.swagger.json └── templates │ ├── README.mustache │ ├── README_onlypackage.mustache │ ├── __init__.mustache │ ├── __init__api.mustache │ ├── __init__model.mustache │ ├── __init__package.mustache │ ├── api.mustache │ ├── api_client.mustache │ ├── api_doc.mustache │ ├── api_doc_example.mustache │ ├── api_response.mustache │ ├── api_test.mustache │ ├── asyncio │ └── rest.mustache │ ├── common_README.mustache │ ├── configuration.mustache │ ├── exceptions.mustache │ ├── git_push.sh.mustache │ ├── github-workflow.mustache │ ├── gitignore.mustache │ ├── gitlab-ci.mustache │ ├── model.mustache │ ├── model_anyof.mustache │ ├── model_doc.mustache │ ├── model_enum.mustache │ ├── model_generic.mustache │ ├── model_oneof.mustache │ ├── model_test.mustache │ ├── partial_api.mustache │ ├── partial_api_args.mustache │ ├── partial_header.mustache │ ├── py.typed.mustache │ ├── pyproject.mustache │ ├── python_doc_auth_partial.mustache │ ├── requirements.mustache │ ├── rest.mustache │ ├── setup.mustache │ ├── setup_cfg.mustache │ ├── signing.mustache │ ├── test-requirements.mustache │ ├── tornado │ └── rest.mustache │ ├── tox.mustache │ └── travis.mustache ├── openapitools.json ├── poetry.lock ├── pyproject.toml ├── pyrightconfig.json ├── scripts ├── gen_ref_pages.py └── gen_ref_pages_preserve_md_files.py ├── src ├── .openapi-generator-ignore └── rapidata │ ├── __init__.py │ ├── api_client │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ ├── campaign_api.py │ │ ├── client_api.py │ │ ├── coco_api.py │ │ ├── compare_workflow_api.py │ │ ├── customer_rapid_api.py │ │ ├── datapoint_api.py │ │ ├── dataset_api.py │ │ ├── evaluation_workflow_api.py │ │ ├── feedback_api.py │ │ ├── identity_api.py │ │ ├── newsletter_api.py │ │ ├── order_api.py │ │ ├── pipeline_api.py │ │ ├── rapid_api.py │ │ ├── rapidata_identity_api_api.py │ │ ├── simple_workflow_api.py │ │ ├── user_info_api.py │ │ ├── user_rapid_api.py │ │ ├── validation_set_api.py │ │ └── workflow_api.py │ ├── api_client.py │ ├── api_response.py │ ├── configuration.py │ ├── exceptions.py │ ├── models │ │ ├── __init__.py │ │ ├── ab_test_selection.py │ │ ├── ab_test_selection_a_inner.py │ │ ├── add_campaign_artifact_result.py │ │ ├── add_campaign_model.py │ │ ├── add_campaign_model_user_filters_inner.py │ │ ├── add_user_response_result.py │ │ ├── add_user_response_result_validation_truth.py │ │ ├── add_validation_rapid_model.py │ │ ├── add_validation_rapid_model_payload.py │ │ ├── add_validation_rapid_model_truth.py │ │ ├── add_validation_rapid_result.py │ │ ├── add_validation_text_rapid_model.py │ │ ├── admin_order_model.py │ │ ├── admin_order_model_paged_result.py │ │ ├── age_group.py │ │ ├── age_user_filter_model.py │ │ ├── aggregator_type.py │ │ ├── are_rapids_active_result.py │ │ ├── asset_metadata.py │ │ ├── asset_metadata_asset.py │ │ ├── asset_metadata_model.py │ │ ├── asset_metadata_model_asset.py │ │ ├── attach_category_rapid_blueprint.py │ │ ├── attach_category_result.py │ │ ├── attach_category_truth.py │ │ ├── base_error.py │ │ ├── bounding_box_payload.py │ │ ├── bounding_box_rapid_blueprint.py │ │ ├── bounding_box_result.py │ │ ├── bounding_box_truth.py │ │ ├── box_shape.py │ │ ├── campaign_artifact_model.py │ │ ├── campaign_query_model.py │ │ ├── campaign_query_model_paged_result.py │ │ ├── campaign_query_result.py │ │ ├── campaign_query_result_paged_result.py │ │ ├── campaign_status.py │ │ ├── campaign_user_filter_model.py │ │ ├── capped_selection.py │ │ ├── capped_selection_selections_inner.py │ │ ├── classification_metadata.py │ │ ├── classification_metadata_filter_config.py │ │ ├── classification_metadata_model.py │ │ ├── classify_payload.py │ │ ├── clients_query_result.py │ │ ├── clients_query_result_paged_result.py │ │ ├── clone_dataset_model.py │ │ ├── clone_order_model.py │ │ ├── clone_order_result.py │ │ ├── compare_match_status.py │ │ ├── compare_payload.py │ │ ├── compare_rapid_blueprint.py │ │ ├── compare_result.py │ │ ├── compare_truth.py │ │ ├── compare_workflow_config.py │ │ ├── compare_workflow_config_metadata_value.py │ │ ├── compare_workflow_config_model.py │ │ ├── compare_workflow_config_model_pair_maker_config.py │ │ ├── compare_workflow_config_pair_maker_config.py │ │ ├── compare_workflow_config_rapid_selection_configs_inner.py │ │ ├── compare_workflow_config_referee.py │ │ ├── compare_workflow_get_result_overview_get200_response.py │ │ ├── compare_workflow_model.py │ │ ├── compare_workflow_model1.py │ │ ├── compare_workflow_model1_pair_maker_information.py │ │ ├── compare_workflow_model1_referee.py │ │ ├── compare_workflow_model_pair_maker_config.py │ │ ├── comparison_operator.py │ │ ├── completed_rapid_model.py │ │ ├── completed_rapid_model_asset.py │ │ ├── conditional_validation_rapid_selection_config.py │ │ ├── conditional_validation_selection.py │ │ ├── coordinate.py │ │ ├── correlated_rapid_selection_config.py │ │ ├── count_classification_metadata_filter_config.py │ │ ├── count_metadata.py │ │ ├── count_metadata_model.py │ │ ├── country_user_filter_model.py │ │ ├── create_bridge_token_result.py │ │ ├── create_client_model.py │ │ ├── create_client_result.py │ │ ├── create_complex_order_model.py │ │ ├── create_complex_order_model_pipeline.py │ │ ├── create_complex_order_result.py │ │ ├── create_datapoint_from_files_model.py │ │ ├── create_datapoint_from_files_model_metadata_inner.py │ │ ├── create_datapoint_from_text_sources_model.py │ │ ├── create_datapoint_from_urls_model.py │ │ ├── create_datapoint_from_urls_model_metadata_inner.py │ │ ├── create_datapoint_result.py │ │ ├── create_datapoints_from_s3_bucket_model.py │ │ ├── create_dataset_artifact_model.py │ │ ├── create_dataset_artifact_model_dataset.py │ │ ├── create_default_order_model.py │ │ ├── create_default_order_model_workflow_config.py │ │ ├── create_demographic_rapid_model.py │ │ ├── create_empty_validation_set_result.py │ │ ├── create_independent_workflow_model.py │ │ ├── create_independent_workflow_model_workflow_config.py │ │ ├── create_independent_workflow_result.py │ │ ├── create_legacy_client_model.py │ │ ├── create_legacy_order_result.py │ │ ├── create_order_model.py │ │ ├── create_order_model_referee.py │ │ ├── create_order_model_selections_inner.py │ │ ├── create_order_model_user_filters_inner.py │ │ ├── create_order_model_workflow.py │ │ ├── create_order_result.py │ │ ├── create_rapid_result.py │ │ ├── create_simple_pipeline_model.py │ │ ├── create_simple_pipeline_model_artifacts_inner.py │ │ ├── create_simple_pipeline_model_pipeline_steps_inner.py │ │ ├── create_unsupported_order_model.py │ │ ├── create_validation_set_model.py │ │ ├── custom_user_filter_model.py │ │ ├── customer_order_model.py │ │ ├── customer_order_model_paged_result.py │ │ ├── datapoint.py │ │ ├── datapoint_asset.py │ │ ├── datapoint_get_by_id_get200_response.py │ │ ├── datapoint_metadata_model.py │ │ ├── datapoint_metadata_model_metadata_inner.py │ │ ├── datapoint_model.py │ │ ├── datapoint_model_asset.py │ │ ├── datapoint_state.py │ │ ├── dataset_artifact_model.py │ │ ├── dataset_dataset_id_datapoints_post_request_metadata_inner.py │ │ ├── dataset_evaluation_step_model.py │ │ ├── demographic.py │ │ ├── demographic_metadata_model.py │ │ ├── demographic_rapid_selection_config.py │ │ ├── demographic_selection.py │ │ ├── early_stopping_referee_model.py │ │ ├── elo_config.py │ │ ├── elo_config_model.py │ │ ├── empty_validation_truth.py │ │ ├── error_type.py │ │ ├── evaluation_workflow_config.py │ │ ├── evaluation_workflow_model.py │ │ ├── evaluation_workflow_model1.py │ │ ├── feature_flag.py │ │ ├── feature_flag_model.py │ │ ├── feedback_model.py │ │ ├── file_artifact_model.py │ │ ├── file_asset.py │ │ ├── file_asset_metadata_inner.py │ │ ├── file_asset_model.py │ │ ├── file_asset_model1.py │ │ ├── file_asset_model1_metadata_inner.py │ │ ├── file_asset_model2.py │ │ ├── file_asset_model_metadata_inner.py │ │ ├── file_asset_model_metadata_value.py │ │ ├── filter.py │ │ ├── filter_operator.py │ │ ├── free_text_payload.py │ │ ├── free_text_rapid_blueprint.py │ │ ├── free_text_result.py │ │ ├── gender.py │ │ ├── gender_user_filter_model.py │ │ ├── get_attach_category_workflow_result_overview_result.py │ │ ├── get_available_validation_sets_result.py │ │ ├── get_classify_workflow_result_overview_result.py │ │ ├── get_compare_ab_summary_result.py │ │ ├── get_compare_workflow_result_overview_result.py │ │ ├── get_compare_workflow_result_overview_small_result.py │ │ ├── get_compare_workflow_results_model.py │ │ ├── get_compare_workflow_results_result.py │ │ ├── get_compare_workflow_results_result_asset.py │ │ ├── get_compare_workflow_results_result_paged_result.py │ │ ├── get_datapoint_by_id_result.py │ │ ├── get_datapoints_by_dataset_id_result.py │ │ ├── get_dataset_by_id_result.py │ │ ├── get_dataset_progress_result.py │ │ ├── get_failed_datapoints_result.py │ │ ├── get_order_by_id_result.py │ │ ├── get_order_results_result.py │ │ ├── get_pipeline_by_id_result.py │ │ ├── get_pipeline_by_id_result_artifacts_value.py │ │ ├── get_public_orders_result.py │ │ ├── get_rapid_responses_result.py │ │ ├── get_responses_result.py │ │ ├── get_simple_workflow_result_overview_result.py │ │ ├── get_simple_workflow_results_model.py │ │ ├── get_simple_workflow_results_result.py │ │ ├── get_simple_workflow_results_result_paged_result.py │ │ ├── get_validation_rapids_query.py │ │ ├── get_validation_rapids_query_paged_result.py │ │ ├── get_validation_rapids_result.py │ │ ├── get_validation_rapids_result_asset.py │ │ ├── get_validation_rapids_result_paged_result.py │ │ ├── get_validation_rapids_result_payload.py │ │ ├── get_validation_rapids_result_truth.py │ │ ├── get_validation_set_by_id_result.py │ │ ├── get_workflow_by_id_result.py │ │ ├── get_workflow_by_id_result_workflow.py │ │ ├── get_workflow_config_result.py │ │ ├── get_workflow_config_result_workflow_config.py │ │ ├── get_workflow_progress_result.py │ │ ├── get_workflow_result_overview_result.py │ │ ├── get_workflow_results_result.py │ │ ├── get_workflow_results_result_paged_result.py │ │ ├── google_one_tap_login_model.py │ │ ├── i_workflow_model_paged_result.py │ │ ├── identity_read_bridge_token_get202_response.py │ │ ├── image_dimension_metadata.py │ │ ├── image_dimension_metadata_model.py │ │ ├── import_from_file_result.py │ │ ├── import_validation_set_from_file_result.py │ │ ├── in_progress_rapid_model.py │ │ ├── inspect_report_result.py │ │ ├── issue_auth_token_result.py │ │ ├── issue_client_auth_token_result.py │ │ ├── labeling_selection.py │ │ ├── language_user_filter_model.py │ │ ├── legacy_issue_client_auth_token_result.py │ │ ├── legacy_request_password_reset_command.py │ │ ├── legacy_submit_password_reset_command.py │ │ ├── line.py │ │ ├── line_payload.py │ │ ├── line_point.py │ │ ├── line_rapid_blueprint.py │ │ ├── line_result.py │ │ ├── line_truth.py │ │ ├── locate_box_truth.py │ │ ├── locate_coordinate.py │ │ ├── locate_payload.py │ │ ├── locate_rapid_blueprint.py │ │ ├── locate_result.py │ │ ├── location_metadata.py │ │ ├── location_metadata_exists_filter_config.py │ │ ├── location_metadata_model.py │ │ ├── logic_operator.py │ │ ├── login_model.py │ │ ├── metadata_visibilities.py │ │ ├── multi_asset.py │ │ ├── multi_asset_model.py │ │ ├── multi_asset_model1.py │ │ ├── multi_asset_model1_assets_inner.py │ │ ├── multi_asset_model2.py │ │ ├── multi_compare_truth.py │ │ ├── naive_referee_config.py │ │ ├── naive_referee_info.py │ │ ├── naive_referee_model.py │ │ ├── named_classification.py │ │ ├── named_entity_payload.py │ │ ├── named_entity_rapid_blueprint.py │ │ ├── named_entity_result.py │ │ ├── named_entity_truth.py │ │ ├── never_ending_referee_config.py │ │ ├── never_ending_referee_info.py │ │ ├── new_user_filter_model.py │ │ ├── new_user_filter_model1.py │ │ ├── newsletter_model.py │ │ ├── no_validation_workflow_rapid_selection_config.py │ │ ├── not_available_yet_result.py │ │ ├── not_started_rapid_model.py │ │ ├── not_user_filter_model.py │ │ ├── null_asset.py │ │ ├── null_asset_model.py │ │ ├── null_asset_model1.py │ │ ├── null_asset_model2.py │ │ ├── online_pair_maker_config.py │ │ ├── online_pair_maker_config_model.py │ │ ├── online_pair_maker_information.py │ │ ├── only_validation_workflow_rapid_selection_config.py │ │ ├── or_user_filter_model.py │ │ ├── order_model.py │ │ ├── order_model_paged_result.py │ │ ├── order_query_get200_response.py │ │ ├── order_state.py │ │ ├── original_filename_metadata.py │ │ ├── original_filename_metadata_model.py │ │ ├── page_info.py │ │ ├── pipeline_id_workflow_artifact_id_put_request.py │ │ ├── pipeline_id_workflow_put_request.py │ │ ├── polygon_payload.py │ │ ├── polygon_rapid_blueprint.py │ │ ├── polygon_result.py │ │ ├── polygon_truth.py │ │ ├── pre_arranged_pair_maker_config.py │ │ ├── pre_arranged_pair_maker_config_model.py │ │ ├── pre_arranged_pair_maker_information.py │ │ ├── preliminary_download_model.py │ │ ├── preliminary_download_result.py │ │ ├── private_text_metadata_input.py │ │ ├── probabilistic_attach_category_referee_config.py │ │ ├── probabilistic_attach_category_referee_info.py │ │ ├── problem_details.py │ │ ├── prompt_asset_metadata_input.py │ │ ├── prompt_metadata.py │ │ ├── prompt_metadata_input.py │ │ ├── prompt_metadata_model.py │ │ ├── public_order_model.py │ │ ├── public_text_metadata_input.py │ │ ├── query_campaigns_model.py │ │ ├── query_model.py │ │ ├── query_orders_model.py │ │ ├── query_validation_rapids_result.py │ │ ├── query_validation_rapids_result_asset.py │ │ ├── query_validation_rapids_result_paged_result.py │ │ ├── query_validation_rapids_result_payload.py │ │ ├── query_validation_rapids_result_truth.py │ │ ├── query_validation_set_model.py │ │ ├── query_workflows_model.py │ │ ├── ranked_datapoint_model.py │ │ ├── rapid_answer.py │ │ ├── rapid_answer_result.py │ │ ├── rapid_issue.py │ │ ├── rapid_model.py │ │ ├── rapid_model_paged_result.py │ │ ├── rapid_model_referee.py │ │ ├── rapid_response.py │ │ ├── rapid_response_result.py │ │ ├── rapid_result_model.py │ │ ├── rapid_result_model_result.py │ │ ├── rapid_skipped_model.py │ │ ├── rapid_state.py │ │ ├── read_bridge_token_keys_result.py │ │ ├── register_temporary_customer_model.py │ │ ├── register_temporary_customer_result.py │ │ ├── report_model.py │ │ ├── request_password_reset_command.py │ │ ├── response_count_user_filter_model.py │ │ ├── retrieval_mode.py │ │ ├── root_filter.py │ │ ├── scrub_payload.py │ │ ├── scrub_range.py │ │ ├── scrub_rapid_blueprint.py │ │ ├── scrub_result.py │ │ ├── scrub_truth.py │ │ ├── send_completion_mail_step_model.py │ │ ├── shape.py │ │ ├── shuffling_selection.py │ │ ├── signup_customer_model.py │ │ ├── signup_shadow_customer_model.py │ │ ├── simple_workflow_config.py │ │ ├── simple_workflow_config_blueprint.py │ │ ├── simple_workflow_config_model.py │ │ ├── simple_workflow_config_model_blueprint.py │ │ ├── simple_workflow_get_result_overview_get200_response.py │ │ ├── simple_workflow_model.py │ │ ├── simple_workflow_model1.py │ │ ├── simple_workflow_model1_blueprint.py │ │ ├── simple_workflow_model_blueprint.py │ │ ├── skip_result.py │ │ ├── skip_truth.py │ │ ├── sort_criterion.py │ │ ├── sort_direction.py │ │ ├── source_url_metadata.py │ │ ├── source_url_metadata_model.py │ │ ├── static_rapid_selection_config.py │ │ ├── static_selection.py │ │ ├── sticky_state.py │ │ ├── submit_coco_model.py │ │ ├── submit_coco_result.py │ │ ├── submit_password_reset_command.py │ │ ├── text_asset.py │ │ ├── text_asset_model.py │ │ ├── text_asset_model1.py │ │ ├── text_asset_model2.py │ │ ├── text_metadata.py │ │ ├── text_metadata_model.py │ │ ├── transcription_metadata.py │ │ ├── transcription_metadata_input.py │ │ ├── transcription_metadata_model.py │ │ ├── transcription_payload.py │ │ ├── transcription_rapid_blueprint.py │ │ ├── transcription_result.py │ │ ├── transcription_truth.py │ │ ├── transcription_word.py │ │ ├── translated_prompt_metadata_model.py │ │ ├── translated_string.py │ │ ├── unlock_order_result.py │ │ ├── update_access_model.py │ │ ├── update_campaign_model.py │ │ ├── update_dataset_name_model.py │ │ ├── update_dimensions_model.py │ │ ├── update_order_model.py │ │ ├── update_order_name_model.py │ │ ├── update_validation_rapid_model.py │ │ ├── update_validation_rapid_model_truth.py │ │ ├── update_workflow_config_model.py │ │ ├── update_workflow_config_model_workflow_config.py │ │ ├── update_workflow_config_request.py │ │ ├── update_workflow_config_request_config.py │ │ ├── upload_coco_result.py │ │ ├── upload_datapoints_result.py │ │ ├── upload_files_from_s3_bucket_model.py │ │ ├── upload_from_s3_result.py │ │ ├── upload_text_sources_to_dataset_model.py │ │ ├── url_asset_input.py │ │ ├── user_score_user_filter_model.py │ │ ├── validation_chance.py │ │ ├── validation_import_post_request_blueprint.py │ │ ├── validation_rapid_selection_config.py │ │ ├── validation_selection.py │ │ ├── validation_set.py │ │ ├── validation_set_model.py │ │ ├── validation_set_model_paged_result.py │ │ ├── validation_set_overview_model.py │ │ ├── validation_set_paged_result.py │ │ ├── workflow_aggregation_step_model.py │ │ ├── workflow_artifact_model.py │ │ ├── workflow_config_artifact_model.py │ │ ├── workflow_config_artifact_model_workflow_config.py │ │ ├── workflow_labeling_step_model.py │ │ ├── workflow_split_model.py │ │ ├── workflow_split_model_filter_configs_inner.py │ │ └── workflow_state.py │ └── rest.py │ ├── api_client_README.md │ ├── rapidata_client │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ └── rapidata_exception.py │ ├── assets │ │ ├── __init__.py │ │ ├── _base_asset.py │ │ ├── _media_asset.py │ │ ├── _multi_asset.py │ │ ├── _sessions.py │ │ ├── _text_asset.py │ │ └── data_type_enum.py │ ├── country_codes │ │ ├── __init__.py │ │ └── country_codes.py │ ├── demographic │ │ ├── __init__.py │ │ └── demographic_manager.py │ ├── filter │ │ ├── __init__.py │ │ ├── _base_filter.py │ │ ├── age_filter.py │ │ ├── campaign_filter.py │ │ ├── country_filter.py │ │ ├── custom_filter.py │ │ ├── gender_filter.py │ │ ├── language_filter.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── age_group.py │ │ │ └── gender.py │ │ ├── new_user_filter.py │ │ ├── not_filter.py │ │ ├── or_filter.py │ │ ├── rapidata_filters.py │ │ ├── response_count_filter.py │ │ └── user_score_filter.py │ ├── logging │ │ ├── __init__.py │ │ ├── logger.py │ │ └── output_manager.py │ ├── metadata │ │ ├── __init__.py │ │ ├── _base_metadata.py │ │ ├── _media_asset_metadata.py │ │ ├── _private_text_metadata.py │ │ ├── _prompt_metadata.py │ │ ├── _public_text_metadata.py │ │ └── _select_words_metadata.py │ ├── order │ │ ├── __init__.py │ │ ├── _rapidata_dataset.py │ │ ├── _rapidata_order_builder.py │ │ ├── rapidata_order.py │ │ ├── rapidata_order_manager.py │ │ └── rapidata_results.py │ ├── rapidata_client.py │ ├── referee │ │ ├── __init__.py │ │ ├── _base_referee.py │ │ ├── _early_stopping_referee.py │ │ └── _naive_referee.py │ ├── selection │ │ ├── __init__.py │ │ ├── _base_selection.py │ │ ├── ab_test_selection.py │ │ ├── capped_selection.py │ │ ├── conditional_validation_selection.py │ │ ├── demographic_selection.py │ │ ├── labeling_selection.py │ │ ├── rapidata_selections.py │ │ ├── retrieval_modes.py │ │ ├── shuffling_selection.py │ │ ├── static_selection.py │ │ └── validation_selection.py │ ├── settings │ │ ├── __init__.py │ │ ├── _rapidata_setting.py │ │ ├── alert_on_fast_response.py │ │ ├── custom_setting.py │ │ ├── free_text_minimum_characters.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ └── translation_behaviour_options.py │ │ ├── no_shuffle.py │ │ ├── play_video_until_the_end.py │ │ ├── rapidata_settings.py │ │ └── translation_behaviour.py │ ├── validation │ │ ├── __init__.py │ │ ├── rapidata_validation_set.py │ │ ├── rapids │ │ │ ├── __init__.py │ │ │ ├── box.py │ │ │ ├── rapids.py │ │ │ └── rapids_manager.py │ │ └── validation_set_manager.py │ └── workflow │ │ ├── __init__.py │ │ ├── _base_workflow.py │ │ ├── _classify_workflow.py │ │ ├── _compare_workflow.py │ │ ├── _draw_workflow.py │ │ ├── _evaluation_workflow.py │ │ ├── _free_text_workflow.py │ │ ├── _locate_workflow.py │ │ ├── _ranking_workflow.py │ │ ├── _select_words_workflow.py │ │ └── _timestamp_workflow.py │ └── service │ ├── __init__.py │ ├── credential_manager.py │ ├── local_file_service.py │ └── openapi_service.py └── tests ├── __init__.py ├── integration ├── __init__.py ├── test_example_orders.py └── test_internal_orders.py └── order ├── __init__.py └── test_order_builder.py /.github/workflows/deploy_doc.yml: -------------------------------------------------------------------------------- 1 | name: Deploy Documentation 2 | 3 | on: workflow_dispatch 4 | 5 | jobs: 6 | deploy-docs: 7 | if: github.event_name != 'pull_request' || github.event.pull_request.merged == true 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - uses: actions/setup-python@v5 12 | with: 13 | python-version: '3.10' 14 | - name: Install Poetry 15 | run: | 16 | curl -sSL https://install.python-poetry.org | python3 - 17 | echo "$HOME/.local/bin" >> $GITHUB_PATH 18 | - name: Update lock file and install dependencies 19 | run: | 20 | poetry lock 21 | poetry install --with docs 22 | - name: Clean docs 23 | run: | 24 | rm -rf site/ 25 | poetry run mkdocs build --clean 26 | - name: Build MkDocs site 27 | run: | 28 | poetry run mkdocs build 29 | - name: Deploy to GitHub Pages 30 | uses: peaceiris/actions-gh-pages@v4 31 | if: github.ref == 'refs/heads/main' 32 | with: 33 | github_token: ${{ secrets.GITHUB_TOKEN }} 34 | publish_dir: ./site 35 | force_orphan: true 36 | cname: docs.rapidata.ai 37 | -------------------------------------------------------------------------------- /.github/workflows/docs_gh_pages.yml: -------------------------------------------------------------------------------- 1 | name: Manual Deploy MkDocs to GitHub Pages 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | permissions: 7 | contents: write 8 | 9 | jobs: 10 | deploy-docs: 11 | runs-on: ubuntu-latest 12 | # Only run on push to main or when a PR is merged 13 | if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) 14 | steps: 15 | - uses: actions/checkout@v4 16 | - uses: actions/setup-python@v5 17 | with: 18 | python-version: '3.10' 19 | - name: Install Poetry 20 | run: | 21 | curl -sSL https://install.python-poetry.org | python3 - 22 | echo "$HOME/.local/bin" >> $GITHUB_PATH 23 | - name: Install dependencies 24 | run: | 25 | poetry install --with docs 26 | - name: Build MkDocs site 27 | run: | 28 | poetry run mkdocs build 29 | - name: Deploy to GitHub Pages 30 | uses: peaceiris/actions-gh-pages@v4 31 | if: github.ref == 'refs/heads/main' 32 | with: 33 | github_token: ${{ secrets.GITHUB_TOKEN }} 34 | publish_dir: ./site 35 | force_orphan: true 36 | -------------------------------------------------------------------------------- /.github/workflows/pyright-type-checking.yml: -------------------------------------------------------------------------------- 1 | name: Python Type Checking with Pyright 2 | 3 | on: 4 | pull_request: 5 | types: [opened, synchronize, reopened] 6 | 7 | jobs: 8 | type-check: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - run: pipx install poetry 15 | - uses: actions/setup-python@v5 16 | with: 17 | cache: 'poetry' 18 | 19 | - run: poetry install 20 | - run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH 21 | 22 | - uses: jakebailey/pyright-action@v2 23 | with: 24 | version: v1.1.396 25 | working-directory: src/rapidata/rapidata_client 26 | -------------------------------------------------------------------------------- /.github/workflows/update-openapi-client.yml: -------------------------------------------------------------------------------- 1 | name: Update OpenAPI Client and create a PR 2 | on: 3 | repository_dispatch: 4 | types: [update-openapi-client] 5 | workflow_dispatch: 6 | inputs: 7 | version: 8 | description: 'Version string for the update' 9 | default: 'latest' 10 | required: true 11 | type: string 12 | 13 | jobs: 14 | generate_openapi_client: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/create-github-app-token@v1 18 | id: generate-token 19 | with: 20 | app-id: ${{ vars.RAPIDATA_OPENAPI_GENERATOR_APP_ID }} 21 | private-key: ${{ secrets.RAPIDATA_OPENAPI_GENERATOR_PRIVATE_KEY }} 22 | - name: Checkout code 23 | uses: actions/checkout@v4 24 | with: 25 | token: ${{ steps.generate-token.outputs.token }} 26 | - name: Setup node 27 | uses: actions/setup-node@v4 28 | - name: Install node packages 29 | run: npm i -g openapi-merge-cli @openapitools/openapi-generator-cli 30 | - name: Download specs 31 | run: ./openapi/download-and-merge-spec.sh 32 | - name: Generate client 33 | run: ./openapi/generate.sh 34 | - name: Create Pull Request 35 | uses: peter-evans/create-pull-request@v7 36 | with: 37 | base: 'main' 38 | branch: 'openapi-generation' 39 | title: 'Update OpenAPI Schemas' 40 | committer: Rudolf the Rabbit 41 | author: Rudolf the Rabbit 42 | delete-branch: true 43 | commit-message: 'chore: update OpenAPI client to ${{ inputs.version || github.event.client_payload.latest_tag }}' 44 | token: ${{ steps.generate-token.outputs.token }} 45 | add-paths: | 46 | openapi/output.swagger.json 47 | src/rapidata/api_client/ 48 | src/rapidata/api_client_README.md 49 | reviewers: | 50 | kannwism 51 | LinoGiger 52 | -------------------------------------------------------------------------------- /.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | 25 | 26 | **/*.md 27 | 28 | .openapi-generator/**/* -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.testing.unittestArgs": [ 3 | "-v", 4 | "-s", 5 | "./tests", 6 | "-p", 7 | "test_*.py" 8 | ], 9 | "python.testing.unittestEnabled": true, 10 | "python.testing.pytestEnabled": false, 11 | "python.analysis.typeCheckingMode": "basic", 12 | "python.analysis.extraPaths": [ 13 | "./src" 14 | ], 15 | "python.autoComplete.extraPaths": [ 16 | "./src" 17 | ], 18 | "editor.formatOnSave": true, 19 | "[python]": { 20 | "editor.defaultFormatter": "ms-python.black-formatter", 21 | "editor.formatOnSave": true 22 | } 23 | } -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | docs.rapidata.ai -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rapidata Python Client 2 | 3 | Python client to interface with the Rapidata API. 4 | 5 | Docs: https://docs.rapidata.ai/ 6 | -------------------------------------------------------------------------------- /docs/examples/classify_order.md: -------------------------------------------------------------------------------- 1 | # Example Classify Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | === "Basic" 6 | 7 | With this order, we want to rate different images based on a Likert scale to better understand how well the model generated the images we intended. We have various images that we want to evaluate, and we will assess how accurately they represent the desired concepts. When you run this with your own examples, you may use local paths to your images instead of the URLs. 8 | 9 | The `NoShuffle` setting is used to ensure that the answer options remain in a fixed order, because the answer options are ordered. 10 | 11 | ```python 12 | --8<-- "examples/basic_classify_order_image.py" 13 | ``` 14 | 15 | To preview the order and see what the annotators see, you can run the following code: 16 | 17 | ```python 18 | order.preview() 19 | ``` 20 | 21 | To open the order in the browser, you can run the following code: 22 | 23 | ```python 24 | order.view() 25 | ``` 26 | 27 | === "Advanced" 28 | In the advanced example we will first create a validation set to give the annotators a reference how they should rate the images. 29 | 30 | To get a better understanding of validation sets, please refer to the [Improve Quality](/improve_order_quality/) guide. 31 | 32 | ```python 33 | --8<-- "examples/advanced_classify_order.py" 34 | ``` 35 | 36 | To preview the order and see what the annotators see, you can run the following code: 37 | 38 | ```python 39 | order.preview() 40 | ``` 41 | 42 | To open the order in the browser, you can run the following code: 43 | 44 | ```python 45 | order.view() 46 | ``` 47 | -------------------------------------------------------------------------------- /docs/examples/compare_order.md: -------------------------------------------------------------------------------- 1 | # Example Compare Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | === "Basic" 6 | 7 | In this example we want to compare two image-to-text models, Flux and Midjourney, that have generated images based on a description, aka prompt. Those images have been saved to a public URL in order to be able to run the example anywhere. When you run this with your own examples, you may use local paths to your images instead of the URLs. 8 | 9 | We now want to find out which of the two images more closely aligns with the prompt - for every prompt. 10 | 11 | ```python 12 | --8<-- "examples/basic_compare_order.py" 13 | ``` 14 | 15 | To preview the order and see what the annotators see, you can run the following code: 16 | 17 | ```python 18 | order.preview() 19 | ``` 20 | 21 | To open the order in the browser, you can run the following code: 22 | 23 | ```python 24 | order.view() 25 | ``` 26 | 27 | === "Advanced" 28 | 29 | In the advanced example we will first create a validation set to give the annotators a reference how they should rate the images. 30 | 31 | To get a better understanding of validation sets, please refer to the [Improve Quality](/improve_order_quality/) guide. 32 | 33 | ```python 34 | --8<-- "examples/advanced_compare_order.py" 35 | ``` 36 | 37 | To preview the order and see what the annotators see, you can run the following code: 38 | 39 | ```python 40 | order.preview() 41 | ``` 42 | 43 | To open the order in the browser, you can run the following code: 44 | 45 | ```python 46 | order.view() 47 | ``` 48 | 49 | 50 | -------------------------------------------------------------------------------- /docs/examples/draw_order.md: -------------------------------------------------------------------------------- 1 | # Example Locate Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | A powerful new capability of image generation models is their ability to edit images. But how do these models understand the location and size of objects they need to edit? In this example, we will create an order where annotators color in the object in images, providing training data that helps the model learn where to apply its edits. 6 | 7 | ```python 8 | --8<-- "examples/basic_draw_order.py" 9 | ``` 10 | 11 | To preview the order and see what the annotators see, you can run the following code: 12 | 13 | ```python 14 | order.preview() 15 | ``` 16 | 17 | To open the order in the browser, you can run the following code: 18 | 19 | ```python 20 | order.view() 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/examples/free_text_order.md: -------------------------------------------------------------------------------- 1 | # Example Free Text Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | === "Basic" 6 | 7 | Let's assume you want to build a new LLM chatbot and you want to know what people might want to ask the bot. You can create a free-text order to gather the questions people might have. 8 | 9 | The free-text order will take longer to complete than the others, as the response process is slightly more involved from the perspective of the annotator. 10 | 11 | ```python 12 | --8<-- "examples/basic_free_text_order.py" 13 | ``` 14 | 15 | To preview the order and see what the annotators see, you can run the following code: 16 | 17 | ```python 18 | order.preview() 19 | ``` 20 | 21 | To open the order in the browser, you can run the following code: 22 | 23 | ```python 24 | order.view() 25 | ``` 26 | 27 | === "Advanced" 28 | 29 | In the advanced example we will add some filters to the order to make sure only annotators that have their phone set to english are able to answer. Additionally we will set a minimum length of 5 characters for the questions. 30 | 31 | ```python 32 | --8<-- "examples/advanced_free_text_order.py" 33 | ``` 34 | 35 | To preview the order and see what the annotators see, you can run the following code: 36 | 37 | ```python 38 | order.preview() 39 | ``` 40 | 41 | To open the order in the browser, you can run the following code: 42 | 43 | ```python 44 | order.view() 45 | ``` 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /docs/examples/locate_order.md: -------------------------------------------------------------------------------- 1 | # Example Locate Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | A big part of image generation is to make coherent images without any visual glitches. Rapidata makes it easy to get feedback on what parts of the image the model messed up. In this example, we will create an order where annotators are asked to select the parts of the image where there are visual glitches. 6 | 7 | ```python 8 | --8<-- "examples/basic_locate_order.py" 9 | ``` 10 | 11 | To preview the order and see what the annotators see, you can run the following code: 12 | 13 | ```python 14 | order.preview() 15 | ``` 16 | 17 | To open the order in the browser, you can run the following code: 18 | 19 | ```python 20 | order.view() 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/examples/select_words_audio_order.md: -------------------------------------------------------------------------------- 1 | # Example Text to Speech Select Words Order 2 | 3 | This example builds on what was introduced in the [Quickstart](/quickstart/) as well as the [Improve Quality](/improve_order_quality/) guide. 4 | 5 | ## Order description 6 | 7 | Text-to-speech is becoming increasingly important in the world of AI. With the select words order, we can test how understandable the AI-generated speech is. We do that by asking the user to click on the words they hear in the audio. This can be done on a language basis, where we can target even uncommon languages and make sure the AI is pronouncing the words correctly. 8 | 9 | This order may not run and require manual approval. If you're order does not start, you can reach out to us at . 10 | 11 | ```python 12 | --8<-- "examples/select_words_order.py" 13 | ``` 14 | 15 | The resulting rapids for the users look like this: 16 | 17 |
18 | ![SelectWords Example](../media/order-types/select_words_tts_example.png){ width="50%" } 19 |
20 | -------------------------------------------------------------------------------- /docs/examples/select_words_order.md: -------------------------------------------------------------------------------- 1 | # Example Select Words Order 2 | 3 | To learn about the basics of creating an order, please refer to the [quickstart guide](../quickstart.md). 4 | 5 | A big part of image generation is following the prompt accurately. Rapidata makes it easy to get feedback on what parts of the prompt the model is struggling with. In this example, we will create an order where annotators are asked to select the words that are not correctly depicted in the image. 6 | 7 | ```python 8 | --8<-- "examples/basic_select_words_order.py" 9 | ``` 10 | 11 | To preview the order and see what the annotators see, you can run the following code: 12 | 13 | ```python 14 | order.preview() 15 | ``` 16 | 17 | To open the order in the browser, you can run the following code: 18 | 19 | ```python 20 | order.view() 21 | ``` 22 | -------------------------------------------------------------------------------- /docs/js/tawk.js: -------------------------------------------------------------------------------- 1 | var Tawk_API = Tawk_API || {}, 2 | Tawk_LoadStart = new Date(); 3 | (function () { 4 | var s1 = document.createElement("script"), 5 | s0 = document.getElementsByTagName("script")[0]; 6 | s1.async = true; 7 | s1.src = "https://embed.tawk.to/671787452480f5b4f5914892/1iapugqdk"; 8 | s1.charset = "UTF-8"; 9 | s1.setAttribute("crossorigin", "*"); 10 | s0.parentNode.insertBefore(s1, s0); 11 | })(); 12 | -------------------------------------------------------------------------------- /docs/media/compare_quickstart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/docs/media/compare_quickstart.png -------------------------------------------------------------------------------- /docs/media/order-types/good_bad_ai_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/docs/media/order-types/good_bad_ai_image.png -------------------------------------------------------------------------------- /docs/media/rapidata.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/stylesheets/extra.css: -------------------------------------------------------------------------------- 1 | /* Add padding between tab headers and content */ 2 | .tabbed-set .tabbed-content { 3 | padding-top: 0.5rem; 4 | } 5 | 6 | /* Ensure tab content has space from the tab labels */ 7 | .tabbed-set>input:checked+label+.tabbed-content { 8 | padding-top: 100.5rem; 9 | } 10 | -------------------------------------------------------------------------------- /examples/.env example: -------------------------------------------------------------------------------- 1 | ENDPOINT=https://api.app.rapidata.ai 2 | 3 | CLIENT_ID= 4 | CLIENT_SECRET= -------------------------------------------------------------------------------- /examples/advanced_free_text_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import ( 2 | RapidataClient, 3 | FreeTextMinimumCharacters, 4 | LanguageFilter, 5 | ) 6 | 7 | if __name__ == "__main__": 8 | rapi = RapidataClient() 9 | order = rapi.order.create_free_text_order( 10 | name="Example prompt generation", 11 | instruction="What would you like to ask an AI? please spell out the question", 12 | datapoints=["https://assets.rapidata.ai/ai_question.png"], 13 | settings=[FreeTextMinimumCharacters(5)], 14 | filters=[LanguageFilter(["en"])], 15 | ).run() 16 | order.display_progress_bar() 17 | results = order.get_results() 18 | print(results) 19 | -------------------------------------------------------------------------------- /examples/basic_classify_order_image.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient, NoShuffle 2 | 3 | # List of image URLs representing different emotions 4 | IMAGE_URLS: list[str] = [ 5 | "https://assets.rapidata.ai/tshirt-4o.png", # Related T-Shirt with the text "Running on caffeine & dreams" 6 | "https://assets.rapidata.ai/tshirt-aurora.jpg", # Related T-shirt with the text "Running on caffeine & dreams" 7 | "https://assets.rapidata.ai/teamleader-aurora.jpg", # Unrelated image 8 | ] 9 | 10 | CONTEXTS: list[str] = [ 11 | "A t-shirt with the text 'Running on caffeine & dreams'" 12 | ] * len(IMAGE_URLS) # Each image will have the same context to be rated by 13 | 14 | if __name__ == "__main__": 15 | rapi = RapidataClient() 16 | 17 | # Create a classification order for emotions based on the images 18 | order = rapi.order.create_classification_order( 19 | name="Likert Scale Example", 20 | instruction="How well does the image match the description?", 21 | answer_options=["1: Not at all", 22 | "2: A little", 23 | "3: Moderately", 24 | "4: Very well", 25 | "5: Perfectly"], 26 | contexts=CONTEXTS, 27 | datapoints=IMAGE_URLS, 28 | responses_per_datapoint=25, 29 | settings=[NoShuffle()] # Do not shuffle the answer options 30 | ).run() # Execute the order 31 | 32 | # Display a progress bar for the order 33 | order.display_progress_bar() 34 | 35 | # Retrieve and print the results of the classification 36 | results = order.get_results() 37 | print(results) 38 | -------------------------------------------------------------------------------- /examples/basic_compare_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient 2 | 3 | PROMPTS: list[str] = [ 4 | "A sign that says 'Diffusion'.", 5 | "A yellow flower sticking out of a green pot.", 6 | "hyperrealism render of a surreal alien humanoid.", 7 | "psychedelic duck", 8 | "A small blue book sitting on a large red book." 9 | ] 10 | 11 | # Image pairs to be matched with prompts (flux vs midjourney versions) 12 | IMAGE_PAIRS: list[list[str]] = [ 13 | ["https://assets.rapidata.ai/flux_sign_diffusion.jpg", "https://assets.rapidata.ai/mj_sign_diffusion.jpg"], 14 | ["https://assets.rapidata.ai/flux_flower.jpg", "https://assets.rapidata.ai/mj_flower.jpg"], 15 | ["https://assets.rapidata.ai/flux_alien.jpg", "https://assets.rapidata.ai/mj_alien.jpg"], 16 | ["https://assets.rapidata.ai/flux_duck.jpg", "https://assets.rapidata.ai/mj_duck.jpg"], 17 | ["https://assets.rapidata.ai/flux_book.jpg", "https://assets.rapidata.ai/mj_book.jpg"] 18 | ] 19 | 20 | if __name__ == "__main__": 21 | rapi = RapidataClient() 22 | order = rapi.order.create_compare_order( 23 | name="Example Image Prompt Alignment Order", 24 | instruction="Which image follows the prompt more accurately?", 25 | datapoints=IMAGE_PAIRS, 26 | responses_per_datapoint=25, 27 | contexts=PROMPTS, # prompt is the context for each image pair 28 | ).run() 29 | order.display_progress_bar() 30 | results = order.get_results() 31 | print(results) 32 | -------------------------------------------------------------------------------- /examples/basic_draw_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient 2 | 3 | IMAGE_URLS = ["https://assets.rapidata.ai/midjourney-5.2_37_3.jpg", 4 | "https://assets.rapidata.ai/flux-1-pro_37_0.jpg", 5 | "https://assets.rapidata.ai/frames-23-1-25_37_4.png", 6 | "https://assets.rapidata.ai/aurora-20-1-25_37_3.png"] 7 | 8 | 9 | if __name__ == "__main__": 10 | rapi = RapidataClient() 11 | 12 | order = rapi.order.create_draw_order( 13 | name="Example Image Comparison", 14 | instruction="Color in all the blue books", 15 | datapoints=IMAGE_URLS, 16 | responses_per_datapoint=35, 17 | ).run() 18 | 19 | order.display_progress_bar() 20 | 21 | results = order.get_results() 22 | print(results) 23 | -------------------------------------------------------------------------------- /examples/basic_free_text_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient 2 | 3 | if __name__ == "__main__": 4 | rapi = RapidataClient() 5 | order = rapi.order.create_free_text_order( 6 | name="Example prompt generation", 7 | instruction="What would you like to ask an AI? please spell out the question", 8 | datapoints=["https://assets.rapidata.ai/ai_question.png"], 9 | ).run() 10 | order.display_progress_bar() 11 | results = order.get_results() 12 | print(results) 13 | -------------------------------------------------------------------------------- /examples/basic_locate_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient, RapidataSettings 2 | 3 | IMAGE_URLS = ["https://assets.rapidata.ai/eac11c3e-ad57-402b-90ed-23378d2ff869.jpg", 4 | "https://assets.rapidata.ai/04e7e3c6-5554-47ca-bdb2-950e48ac3e6c.jpg", 5 | "https://assets.rapidata.ai/91d9913c-b399-47f8-ad19-767798cc951c.jpg", 6 | "https://assets.rapidata.ai/d1cbf51d-7712-4819-96b4-20e030c573de.jpg"] 7 | 8 | 9 | if __name__ == "__main__": 10 | 11 | rapi = RapidataClient() 12 | 13 | order = rapi.order.create_locate_order( 14 | name="Artifact detection example", 15 | instruction="Look close, find incoherent errors, like senseless or malformed objects, incomprehensible details, or visual glitches? Tap to select.", 16 | datapoints=IMAGE_URLS, 17 | responses_per_datapoint=35, 18 | settings=[RapidataSettings.alert_on_fast_response(2500)], # This is optional, it will alert you if the annotators are responding before 2.5 seconds 19 | validation_set_id="6768a557026456ec851f51f9" # in this example, the validation set has already been created 20 | ).run() 21 | -------------------------------------------------------------------------------- /examples/basic_select_words_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient 2 | 3 | IMAGE_URLS = ['https://assets.rapidata.ai/dalle-3_244_0.jpg', 4 | 'https://assets.rapidata.ai/dalle-3_30_1.jpg', 5 | 'https://assets.rapidata.ai/dalle-3_268_2.jpg', 6 | 'https://assets.rapidata.ai/dalle-3_26_2.jpg'] 7 | 8 | PROMPTS = ['The black camera was next to the white tripod.', 9 | 'Four cars on the street.', 10 | 'Car is bigger than the airplane.', 11 | 'One cat and two dogs sitting on the grass.'] 12 | 13 | PROMPTS_WITH_NO_MISTAKES = [prompt + " [No_mistakes]" for prompt in PROMPTS] # selection is split based on spaces 14 | 15 | if __name__ == "__main__": 16 | rapi = RapidataClient() 17 | order = rapi.order.create_select_words_order( 18 | name="Detect Mistakes in Image-Text Alignment", 19 | instruction="The image is based on the text below. Select mistakes, i.e., words that are not aligned with the image.", 20 | datapoints=IMAGE_URLS, 21 | responses_per_datapoint=15, 22 | sentences=PROMPTS_WITH_NO_MISTAKES, 23 | filters=[ 24 | rapi.order.filters.language(["en"]), 25 | ], 26 | validation_set_id="6761a86eef7af86285630ea8" # in this example, the validation set has already been created 27 | ).run() 28 | order.display_progress_bar() 29 | result = order.get_results() 30 | print(result) 31 | -------------------------------------------------------------------------------- /examples/classify_order.py: -------------------------------------------------------------------------------- 1 | from rapidata import RapidataClient 2 | 3 | # List of image URLs representing different emotions 4 | IMAGE_URLS: list[str] = [ 5 | "https://assets.rapidata.ai/dalle-3_anger.webp", # Image representing anger 6 | "https://assets.rapidata.ai/dalle-3_disgust.webp", # Image representing disgust 7 | "https://assets.rapidata.ai/dalle-3_happiness.webp", # Image representing happiness 8 | "https://assets.rapidata.ai/dalle-3_sadness.webp" # Image representing sadness 9 | ] 10 | 11 | if __name__ == "__main__": 12 | # Create a Rapidata client instance 13 | rapi = RapidataClient() 14 | 15 | # Create a classification order for emotions based on the images 16 | order = rapi.order.create_classification_order( 17 | name="Emotions from Images", # Title of the order 18 | instruction="What emotion do you feel when you look at this image?", # Instruction for the user 19 | answer_options=["happy", "sad", "angry", "surprised", "disgusted", "scared", "neutral"], # Possible answers 20 | datapoints=IMAGE_URLS, # Images to classify 21 | responses_per_datapoint=25 # Number of responses for each image 22 | ).run() # Execute the order 23 | 24 | # To preview the order, you can uncomment the following line: 25 | # order.preview() 26 | 27 | # To open the order in the browser, you can uncomment the following line: 28 | # order.view() 29 | 30 | # Display the progress of the order 31 | order.display_progress_bar() 32 | 33 | # Retrieve and print the results of the classification 34 | results = order.get_results() 35 | print(results) 36 | -------------------------------------------------------------------------------- /examples/classify_text_asset_order.py: -------------------------------------------------------------------------------- 1 | """ 2 | Classify order with a validation set 3 | """ 4 | from rapidata import RapidataClient 5 | 6 | 7 | def new_classify_text_asset_order(rapi: RapidataClient): 8 | # Validation set 9 | # This will be shown as defined in the ValidationSelection and will make our annotators understand the task better 10 | validation_set = rapi.validation.create_classification_set( 11 | name="Example Text Classification Validation Set", 12 | instruction="How does this song continue?", 13 | answer_options=["Baby don't hurt me", "No more", "Illusions", "Submarine", "Rock you"], 14 | truths=[["Baby don't hurt me"]], 15 | datapoints=["What is love?"], 16 | data_type="text", 17 | explanations=["Somebody that I used to know"], 18 | ) 19 | 20 | # Configure order 21 | order = rapi.order.create_classification_order( 22 | name="Example Text Classify Order", 23 | instruction="How does this song continue?", 24 | answer_options=["Baby don't hurt me", "No more", "Illusions", "Submarine", "Rock you"], 25 | datapoints=["We will, we will ...", "We all live in a yellow ..."], 26 | data_type="text", 27 | responses_per_datapoint=3, 28 | validation_set_id=validation_set.id 29 | ).run() 30 | 31 | return order 32 | 33 | 34 | if __name__ == "__main__": 35 | order = new_classify_text_asset_order(RapidataClient()) 36 | order.display_progress_bar() 37 | results = order.get_results() 38 | print(results) 39 | -------------------------------------------------------------------------------- /examples/compare_order.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Compare order with a validation set 3 | ''' 4 | 5 | from rapidata import RapidataClient 6 | 7 | 8 | def new_compare_order(rapi: RapidataClient): 9 | logo_path = "https://assets.rapidata.ai/rapidata_logo.png" 10 | concept_path = "https://assets.rapidata.ai/rapidata_concept_logo.jpg" 11 | # Validation set 12 | # This will be shown as defined in the ValidationSelection and will make our annotators understand the task better 13 | validation_set = rapi.validation.create_compare_set( 14 | name="Example Compare Validation Set", 15 | instruction="Which logo is the actual Rapidata logo?", 16 | datapoints=[[logo_path, concept_path]], 17 | truths=[logo_path], 18 | ) 19 | 20 | # configure order 21 | order = rapi.order.create_compare_order( 22 | name="Example Compare Order", 23 | instruction="Which logo is better?", 24 | datapoints=[[concept_path, logo_path]], 25 | responses_per_datapoint=10, 26 | validation_set_id=validation_set.id 27 | ).run() 28 | 29 | return order 30 | 31 | 32 | if __name__ == "__main__": 33 | order = new_compare_order(RapidataClient()) 34 | order.display_progress_bar() 35 | results = order.get_results() 36 | print(results) 37 | -------------------------------------------------------------------------------- /examples/complex_compare_order.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Compare order with a validation set 3 | ''' 4 | 5 | from rapidata import RapidataClient 6 | 7 | def new_compare_order(rapi: RapidataClient): 8 | logo_path = "https://assets.rapidata.ai/rapidata_logo.png" 9 | concept_path = "https://assets.rapidata.ai/rapidata_concept_logo.jpg" 10 | 11 | # Validation set 12 | # This will be shown as defined in the ValidationSelection and will make our annotators understand the task better 13 | validation_set = rapi.validation.create_compare_set( 14 | name="Example SimpleMatchup Validation Set", 15 | instruction="Which logo is the actual Rapidata logo?", 16 | datapoints=[[logo_path, concept_path]], 17 | truths=[logo_path] 18 | ) 19 | 20 | # configure order 21 | order = rapi.order.create_compare_order( 22 | name="Example SimpleMatchup Order", 23 | instruction="Which logo is better?", 24 | datapoints=[[concept_path, logo_path]], 25 | responses_per_datapoint=10, 26 | contexts=["Hint: This is not a trick question"], 27 | validation_set_id=validation_set.id 28 | ).run() 29 | 30 | return order 31 | 32 | if __name__ == "__main__": 33 | new_compare_order(RapidataClient()) 34 | -------------------------------------------------------------------------------- /examples/conditional_validation_rapid_selection.py: -------------------------------------------------------------------------------- 1 | """ 2 | Classify order with a validation set 3 | """ 4 | 5 | from rapidata import ( 6 | RapidataClient, 7 | LabelingSelection, 8 | ConditionalValidationSelection, 9 | ) 10 | from rapidata.rapidata_client.assets._media_asset import MediaAsset 11 | 12 | 13 | def new_cond_validation_rapid_order(rapi: RapidataClient): 14 | # Validation set 15 | # This will be shown as defined in the ValidationSelection and will make our annotators understand the task better 16 | validation_set = rapi.validation.create_classification_set( 17 | name="Example Classify Validation Set", 18 | instruction="What is shown in the image?", 19 | answer_options=["Fish", "Cat", "Wallaby", "Airplane"], 20 | truths=[["Wallaby"]], 21 | datapoints=["examples/data/wallaby.jpg"], 22 | contexts=["Hint: It has a pouch"], 23 | ) 24 | # configure order 25 | selections = [ 26 | ConditionalValidationSelection( 27 | chances=[0.9], 28 | thresholds=[0.35], 29 | rapid_counts=[1], 30 | validation_set_id=validation_set.id, 31 | ), 32 | LabelingSelection(amount=1), 33 | ] 34 | order = rapi.order.create_classification_order( 35 | name="Example Classify Order", 36 | instruction="What is shown in the image?", 37 | answer_options=["Fish", "Cat", "Wallaby", "Airplane"], 38 | datapoints=["examples/data/wallaby.jpg"], 39 | responses_per_datapoint=3, 40 | contexts=["Hint: It has a pouch"], 41 | selections=selections 42 | ).run() 43 | 44 | result = order.get_status() 45 | print("Order in state: ", result) 46 | 47 | return order 48 | 49 | 50 | if __name__ == "__main__": 51 | order = new_cond_validation_rapid_order(RapidataClient()) 52 | -------------------------------------------------------------------------------- /examples/data/rapidata_concept_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/examples/data/rapidata_concept_logo.jpg -------------------------------------------------------------------------------- /examples/data/rapidata_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/examples/data/rapidata_logo.png -------------------------------------------------------------------------------- /examples/data/waiting.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/examples/data/waiting.mp4 -------------------------------------------------------------------------------- /examples/data/wallaby.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/examples/data/wallaby.jpg -------------------------------------------------------------------------------- /examples/free_text_order.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Free Text Order 3 | ''' 4 | 5 | from rapidata import RapidataClient 6 | 7 | def get_prompt_ideas(rapi: RapidataClient): 8 | 9 | order = rapi.order.create_free_text_order( 10 | name="Example prompt generation", 11 | instruction="What would you like to ask an AI? please spell out the question", 12 | datapoints=["https://assets.rapidata.ai/ai_question.png"], 13 | settings=[rapi.order.settings.free_text_minimum_characters(5)] 14 | ).run() 15 | 16 | return order 17 | 18 | 19 | if __name__ == "__main__": 20 | order = get_prompt_ideas(RapidataClient()) 21 | order.display_progress_bar() 22 | results = order.get_results() 23 | print(results) 24 | -------------------------------------------------------------------------------- /examples/ranking_order.py: -------------------------------------------------------------------------------- 1 | """ 2 | Ranking order 3 | """ 4 | from rapidata.rapidata_client import RapidataClient 5 | 6 | 7 | def new_ranking_order(rapi: RapidataClient): 8 | datapoints = [ 9 | "https://assets.rapidata.ai/f9d92460-a362-493c-af91-bf50046453ae.webp", 10 | "https://assets.rapidata.ai/9bcd8b18-e9ad-4449-84d4-b3d72e200e9c.webp", 11 | "https://assets.rapidata.ai/266f6446-3ca8-4c2d-b070-13558b35a4e0.webp", 12 | "https://assets.rapidata.ai/f787f02c-e5d0-43ca-aa6e-aea747845cf3.webp", 13 | "https://assets.rapidata.ai/7e518a1b-4d1c-4a86-9109-26646684cc02.webp", 14 | "https://assets.rapidata.ai/10af47bd-3502-4534-b917-73dba5feaf76.webp", 15 | "https://assets.rapidata.ai/59725ca0-1fd5-4850-a15c-4221e191e293.webp", 16 | "https://assets.rapidata.ai/65d3939d-c1b8-433c-b180-13dae80f0519.webp", 17 | "https://assets.rapidata.ai/c13b8feb-fb97-4646-8dfc-97f05d37a637.webp", 18 | "https://assets.rapidata.ai/586dc517-c987-4d06-8a6f-553508b86356.webp", 19 | "https://assets.rapidata.ai/f4884ecd-cacb-4387-ab18-3b6e7dcdf10c.webp", 20 | "https://assets.rapidata.ai/79076f76-a432-4ef9-9007-6d09a218417a.webp" 21 | ] 22 | 23 | order = rapi.order.create_ranking_order( 24 | name="Example Ranking Order", 25 | instruction="Which rabbit looks the coolest?", 26 | datapoints=datapoints, 27 | responses_per_comparison=3, #Each match is concluded after 3 votes 28 | total_comparison_budget= 24, #Make 24 comparisons, each comparison containing 2 datapoints 29 | random_comparisons_ratio=0.5 #First half of the comparisons are random, the second half are close matchups 30 | ).run() 31 | 32 | return order 33 | 34 | 35 | if __name__ == "__main__": 36 | order = new_ranking_order(RapidataClient()) 37 | order.display_progress_bar() 38 | results = order.get_results() 39 | print(results) 40 | -------------------------------------------------------------------------------- /examples/select_faulty_prompt_order.py: -------------------------------------------------------------------------------- 1 | ''' 2 | SelectWords order with validation set 3 | ''' 4 | 5 | from rapidata import RapidataClient 6 | 7 | def get_urls_and_prompts(): 8 | links = ['https://assets.rapidata.ai/dalle-3_244_0.jpg', 9 | 'https://assets.rapidata.ai/dalle-3_30_1.jpg', 10 | 'https://assets.rapidata.ai/dalle-3_268_2.jpg', 11 | 'https://assets.rapidata.ai/dalle-3_26_2.jpg'] 12 | 13 | prompts = ['The black camera was next to the white tripod.', 14 | 'Four cars on the street.', 15 | 'Car is bigger than the airplane.', 16 | 'One cat and two dogs sitting on the grass.'] 17 | 18 | return links, prompts 19 | 20 | def new_select_words_order(rapi: RapidataClient): 21 | links, prompts = get_urls_and_prompts() 22 | 23 | prompts_with_no_mistakes = [prompt + " [No_mistakes]" for prompt in prompts] # selection is split based on spaces 24 | 25 | order = rapi.order.create_select_words_order( 26 | name="Detect Mistakes in Image-Text Alignment", 27 | instruction="The image is based on the text below. Select mistakes, i.e., words that are not aligned with the image.", 28 | datapoints=links, 29 | responses_per_datapoint=15, 30 | sentences=prompts_with_no_mistakes, 31 | filters=[ 32 | rapi.order.filters.language(["en"]), 33 | ], 34 | validation_set_id="6761a86eef7af86285630ea8" # in this example, the validation set has already been created 35 | ).run() 36 | 37 | return order 38 | 39 | if __name__ == "__main__": 40 | rapi = RapidataClient() 41 | order = new_select_words_order(rapi) 42 | order.display_progress_bar() 43 | result = order.get_results() 44 | print(result) 45 | 46 | -------------------------------------------------------------------------------- /examples/select_words_order.py: -------------------------------------------------------------------------------- 1 | ''' 2 | SelectWords order with validation set 3 | ''' 4 | 5 | from rapidata import RapidataClient 6 | 7 | def create_validation_set(rapi: RapidataClient): 8 | validation_set = rapi.validation.create_select_words_set( 9 | name="Example SelectWords Validation Set", 10 | instruction="Select the words you hear in the audio", 11 | datapoints=["https://assets.rapidata.ai/where_did_you__today.mp3"], 12 | sentences=["Where did you go today?"], 13 | truths=[[0, 1, 2, 4]], 14 | required_completeness=1, 15 | required_precision=1, 16 | ) 17 | return validation_set 18 | 19 | def new_select_words_order(rapi: RapidataClient, validation_set_id: str): 20 | order = rapi.order.create_select_words_order( 21 | name="Example SelectWords Order", 22 | instruction="Select the words you hear in the audio", 23 | datapoints=["https://assets.rapidata.ai/openai_tts_demo.mp3"], 24 | sentences=["Hello, welcome to OpenAI's Text-to-Speech demo!"], 25 | validation_set_id=validation_set_id, 26 | responses_per_datapoint=25, 27 | filters=[ 28 | rapi.order.filters.language(["en"]) 29 | ] 30 | ).run() 31 | 32 | return order 33 | 34 | if __name__ == "__main__": 35 | rapi = RapidataClient() 36 | validation_set = create_validation_set(rapi) # only call this once 37 | validation_set = rapi.validation.find_validation_sets(name="Example SelectWords Validation Set")[0] 38 | order = new_select_words_order(rapi, validation_set.id) 39 | order.display_progress_bar() 40 | result = order.get_results() 41 | print(result) 42 | 43 | -------------------------------------------------------------------------------- /openapi/.gitignore: -------------------------------------------------------------------------------- 1 | openapi-client/* 2 | !openapi-client/openapi_client/ 3 | spec/ -------------------------------------------------------------------------------- /openapi/config.yaml: -------------------------------------------------------------------------------- 1 | validateSpec: false 2 | generateSourceCodeOnly: true 3 | packageName: rapidata.api_client -------------------------------------------------------------------------------- /openapi/download-and-merge-spec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf openapi/spec 4 | mkdir openapi/spec 5 | 6 | # Use a function to simulate an associative array 7 | url_for() { 8 | case $1 in 9 | "order") echo "https://api.rabbitdata.ch/Order/swagger/v1/swagger.json" ;; 10 | "dataset") echo "https://api.rabbitdata.ch/Dataset/swagger/v1/swagger.json" ;; 11 | "identity") echo "https://api.rabbitdata.ch/Identity/swagger/v1/swagger.json" ;; 12 | "validation") echo "https://api.rabbitdata.ch/Validation/swagger/v1/swagger.json" ;; 13 | "rapid") echo "https://api.rabbitdata.ch/Rapid/swagger/v1/swagger.json" ;; 14 | "workflow") echo "https://api.rabbitdata.ch/Workflow/swagger/v1/swagger.json" ;; 15 | "pipeline") echo "https://api.rabbitdata.ch/Pipeline/swagger/v1/swagger.json" ;; 16 | "campaign") echo "https://api.rabbitdata.ch/Campaign/swagger/v1/swagger.json" ;; 17 | *) echo "" ;; 18 | esac 19 | } 20 | 21 | # List of keys 22 | keys=("order" "dataset" "identity" "validation" "rapid" "workflow" "pipeline" "campaign") 23 | 24 | for key in "${keys[@]}"; do 25 | url=$(url_for "$key") 26 | output_json="openapi/spec/${key}.json" 27 | 28 | # Download the JSON file using curl 29 | curl -o "$output_json" "$url" 30 | 31 | echo "Downloaded $url to $output_json" 32 | 33 | done 34 | 35 | # Merge the OpenAPI specs into a single file (output.swagger.json) 36 | cd openapi 37 | npx openapi-merge-cli 38 | -------------------------------------------------------------------------------- /openapi/generate.sh: -------------------------------------------------------------------------------- 1 | npx openapi-generator-cli generate --global-property modelTests=false,modelDocs=false,apiTests=false,apiDocs=false -i openapi/output.swagger.json -g python -o ./src -c openapi/config.yaml -t openapi/templates 2 | -------------------------------------------------------------------------------- /openapi/openapi-merge.json: -------------------------------------------------------------------------------- 1 | { 2 | "inputs": [ 3 | { 4 | "inputFile": "./spec/dataset.json" 5 | }, 6 | { 7 | "inputFile": "./spec/order.json" 8 | }, 9 | { 10 | "inputFile": "./spec/identity.json" 11 | }, 12 | { 13 | "inputFile": "./spec/validation.json" 14 | }, 15 | { 16 | "inputFile": "./spec/rapid.json" 17 | }, 18 | { 19 | "inputFile": "./spec/workflow.json" 20 | }, 21 | { 22 | "inputFile": "./spec/pipeline.json" 23 | }, 24 | { 25 | "inputFile": "./spec/campaign.json" 26 | } 27 | ], 28 | "output": "./output.swagger.json" 29 | } 30 | -------------------------------------------------------------------------------- /openapi/templates/README.mustache: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescriptionWithNewLines}} 3 | {{{.}}} 4 | {{/appDescriptionWithNewLines}} 5 | 6 | This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Generator version: {{generatorVersion}} 14 | - Build package: {{generatorClass}} 15 | {{#infoUrl}} 16 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 17 | {{/infoUrl}} 18 | 19 | ## Requirements. 20 | 21 | Python {{{generatorLanguageVersion}}} 22 | 23 | ## Installation & Usage 24 | ### pip install 25 | 26 | If the python package is hosted on a repository, you can install directly using: 27 | 28 | ```sh 29 | pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git 30 | ``` 31 | (you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`) 32 | 33 | Then import the package: 34 | ```python 35 | import {{{packageName}}} 36 | ``` 37 | 38 | ### Setuptools 39 | 40 | Install via [Setuptools](http://pypi.python.org/pypi/setuptools). 41 | 42 | ```sh 43 | python setup.py install --user 44 | ``` 45 | (or `sudo python setup.py install` to install the package for all users) 46 | 47 | Then import the package: 48 | ```python 49 | import {{{packageName}}} 50 | ``` 51 | 52 | ### Tests 53 | 54 | Execute `pytest` to run the tests. 55 | 56 | ## Getting Started 57 | 58 | Please follow the [installation procedure](#installation--usage) and then run the following: 59 | 60 | {{> common_README }} 61 | -------------------------------------------------------------------------------- /openapi/templates/README_onlypackage.mustache: -------------------------------------------------------------------------------- 1 | # {{{projectName}}} 2 | {{#appDescription}} 3 | {{{.}}} 4 | {{/appDescription}} 5 | 6 | The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: 7 | 8 | - API version: {{appVersion}} 9 | - Package version: {{packageVersion}} 10 | {{^hideGenerationTimestamp}} 11 | - Build date: {{generatedDate}} 12 | {{/hideGenerationTimestamp}} 13 | - Generator version: {{generatorVersion}} 14 | - Build package: {{generatorClass}} 15 | {{#infoUrl}} 16 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) 17 | {{/infoUrl}} 18 | 19 | ## Requirements. 20 | 21 | Python {{{generatorLanguageVersion}}} 22 | 23 | ## Installation & Usage 24 | 25 | This python library package is generated without supporting files like setup.py or requirements files 26 | 27 | To be able to use it, you will need these dependencies in your own package that uses this library: 28 | 29 | * urllib3 >= 1.25.3, < 3.0.0 30 | * python-dateutil >= 2.8.2 31 | {{#asyncio}} 32 | * aiohttp >= 3.8.4 33 | * aiohttp-retry >= 2.8.3 34 | {{/asyncio}} 35 | {{#tornado}} 36 | * tornado >= 4.2, < 5 37 | {{/tornado}} 38 | {{#hasHttpSignatureMethods}} 39 | * pem >= 19.3.0 40 | * pycryptodome >= 3.9.0 41 | {{/hasHttpSignatureMethods}} 42 | * pydantic >= 2 43 | * typing-extensions >= 4.7.1 44 | 45 | ## Getting Started 46 | 47 | In your own code, to use this library to connect and interact with {{{projectName}}}, 48 | you can run the following: 49 | 50 | {{> common_README }} 51 | -------------------------------------------------------------------------------- /openapi/templates/__init__.mustache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/openapi/templates/__init__.mustache -------------------------------------------------------------------------------- /openapi/templates/__init__api.mustache: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | 3 | # import apis into api package 4 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}} 5 | {{/apis}}{{/apiInfo}} 6 | -------------------------------------------------------------------------------- /openapi/templates/__init__model.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | {{>partial_header}} 5 | 6 | # import models into model package 7 | {{#models}} 8 | {{#model}} 9 | from {{modelPackage}}.{{classFilename}} import {{classname}} 10 | {{/model}} 11 | {{/models}} 12 | -------------------------------------------------------------------------------- /openapi/templates/__init__package.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | # flake8: noqa 4 | 5 | {{>partial_header}} 6 | 7 | __version__ = "{{packageVersion}}" 8 | 9 | # import apis into sdk package 10 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}} 11 | {{/apis}}{{/apiInfo}} 12 | # import ApiClient 13 | from {{packageName}}.api_response import ApiResponse 14 | from {{packageName}}.api_client import ApiClient 15 | from {{packageName}}.configuration import Configuration 16 | from {{packageName}}.exceptions import OpenApiException 17 | from {{packageName}}.exceptions import ApiTypeError 18 | from {{packageName}}.exceptions import ApiValueError 19 | from {{packageName}}.exceptions import ApiKeyError 20 | from {{packageName}}.exceptions import ApiAttributeError 21 | from {{packageName}}.exceptions import ApiException 22 | {{#hasHttpSignatureMethods}} 23 | from {{packageName}}.signing import HttpSigningConfiguration 24 | {{/hasHttpSignatureMethods}} 25 | 26 | # import models into sdk package 27 | {{#models}} 28 | {{#model}} 29 | from {{modelPackage}}.{{classFilename}} import {{classname}} 30 | {{/model}} 31 | {{/models}} 32 | {{#recursionLimit}} 33 | 34 | __import__('sys').setrecursionlimit({{{.}}}) 35 | {{/recursionLimit}} 36 | -------------------------------------------------------------------------------- /openapi/templates/api_doc_example.mustache: -------------------------------------------------------------------------------- 1 | 2 | ```python 3 | import {{{packageName}}} 4 | {{#vendorExtensions.x-py-example-import}} 5 | {{{.}}} 6 | {{/vendorExtensions.x-py-example-import}} 7 | from {{{packageName}}}.rest import ApiException 8 | from pprint import pprint 9 | 10 | {{> python_doc_auth_partial}} 11 | # Enter a context with an instance of the API client 12 | {{#asyncio}}async {{/asyncio}}with {{{packageName}}}.ApiClient(configuration) as api_client: 13 | # Create an instance of the API class 14 | api_instance = {{{packageName}}}.{{{classname}}}(api_client) 15 | {{#allParams}} 16 | {{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} 17 | {{/allParams}} 18 | 19 | try: 20 | {{#summary}} 21 | # {{{.}}} 22 | {{/summary}} 23 | {{#returnType}}api_response = {{/returnType}}{{#asyncio}}await {{/asyncio}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) 24 | {{#returnType}} 25 | print("The response of {{classname}}->{{operationId}}:\n") 26 | pprint(api_response) 27 | {{/returnType}} 28 | except Exception as e: 29 | print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e) 30 | ``` 31 | 32 | {{#vendorExtensions.x-py-postponed-example-imports.size}} 33 | {{#vendorExtensions.x-py-postponed-example-imports}} 34 | {{{.}}} 35 | {{/vendorExtensions.x-py-postponed-example-imports}} 36 | {{classname}}.update_forward_refs() 37 | {{/vendorExtensions.x-py-postponed-example-imports.size}} 38 | -------------------------------------------------------------------------------- /openapi/templates/api_response.mustache: -------------------------------------------------------------------------------- 1 | """API response object.""" 2 | 3 | from __future__ import annotations 4 | from typing import Optional, Generic, Mapping, TypeVar 5 | from pydantic import Field, StrictInt, StrictBytes, BaseModel 6 | 7 | T = TypeVar("T") 8 | 9 | class ApiResponse(BaseModel, Generic[T]): 10 | """ 11 | API response object 12 | """ 13 | 14 | status_code: StrictInt = Field(description="HTTP status code") 15 | headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") 16 | data: T = Field(description="Deserialized data given the data type") 17 | raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") 18 | 19 | model_config = { 20 | "arbitrary_types_allowed": True 21 | } 22 | -------------------------------------------------------------------------------- /openapi/templates/api_test.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import unittest 6 | 7 | from {{apiPackage}}.{{classFilename}} import {{classname}} 8 | 9 | 10 | class {{#operations}}Test{{classname}}(unittest.{{#asyncio}}IsolatedAsyncio{{/asyncio}}TestCase): 11 | """{{classname}} unit test stubs""" 12 | 13 | {{#asyncio}} 14 | async def asyncSetUp(self) -> None: 15 | self.api = {{classname}}() 16 | 17 | async def asyncTearDown(self) -> None: 18 | pass 19 | {{/asyncio}} 20 | {{^asyncio}} 21 | def setUp(self) -> None: 22 | self.api = {{classname}}() 23 | 24 | def tearDown(self) -> None: 25 | pass 26 | {{/asyncio}} 27 | 28 | {{#operation}} 29 | {{#asyncio}} 30 | async def test_{{operationId}}(self) -> None: 31 | {{/asyncio}} 32 | {{^asyncio}} 33 | def test_{{operationId}}(self) -> None: 34 | {{/asyncio}} 35 | """Test case for {{{operationId}}} 36 | 37 | {{#summary}} 38 | {{{.}}} 39 | {{/summary}} 40 | """ 41 | pass 42 | 43 | {{/operation}} 44 | {{/operations}} 45 | 46 | if __name__ == '__main__': 47 | unittest.main() 48 | -------------------------------------------------------------------------------- /openapi/templates/git_push.sh.mustache: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ 3 | # 4 | # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" 5 | 6 | git_user_id=$1 7 | git_repo_id=$2 8 | release_note=$3 9 | git_host=$4 10 | 11 | if [ "$git_host" = "" ]; then 12 | git_host="{{{gitHost}}}" 13 | echo "[INFO] No command line input provided. Set \$git_host to $git_host" 14 | fi 15 | 16 | if [ "$git_user_id" = "" ]; then 17 | git_user_id="{{{gitUserId}}}" 18 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" 19 | fi 20 | 21 | if [ "$git_repo_id" = "" ]; then 22 | git_repo_id="{{{gitRepoId}}}" 23 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" 24 | fi 25 | 26 | if [ "$release_note" = "" ]; then 27 | release_note="{{{releaseNote}}}" 28 | echo "[INFO] No command line input provided. Set \$release_note to $release_note" 29 | fi 30 | 31 | # Initialize the local directory as a Git repository 32 | git init 33 | 34 | # Adds the files in the local repository and stages them for commit. 35 | git add . 36 | 37 | # Commits the tracked changes and prepares them to be pushed to a remote repository. 38 | git commit -m "$release_note" 39 | 40 | # Sets the new remote 41 | git_remote=$(git remote) 42 | if [ "$git_remote" = "" ]; then # git remote not defined 43 | 44 | if [ "$GIT_TOKEN" = "" ]; then 45 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." 46 | git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git 47 | else 48 | git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git 49 | fi 50 | 51 | fi 52 | 53 | git pull origin master 54 | 55 | # Pushes (Forces) the changes in the local repository up to the remote repository 56 | echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" 57 | git push origin master 2>&1 | grep -v 'To https' 58 | -------------------------------------------------------------------------------- /openapi/templates/github-workflow.mustache: -------------------------------------------------------------------------------- 1 | # NOTE: This file is auto generated by OpenAPI Generator. 2 | # URL: https://openapi-generator.tech 3 | # 4 | # ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python 5 | 6 | name: {{packageName}} Python package 7 | {{=<% %>=}} 8 | 9 | on: [push, pull_request] 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | - name: Set up Python ${{ matrix.python-version }} 22 | uses: actions/setup-python@v4 23 | with: 24 | python-version: ${{ matrix.python-version }} 25 | - name: Install dependencies 26 | run: | 27 | python -m pip install --upgrade pip 28 | pip install -r requirements.txt 29 | pip install -r test-requirements.txt 30 | - name: Test with pytest 31 | run: | 32 | pytest --cov={{packageName}} 33 | -------------------------------------------------------------------------------- /openapi/templates/gitignore.mustache: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | venv/ 48 | .venv/ 49 | .python-version 50 | .pytest_cache 51 | 52 | # Translations 53 | *.mo 54 | *.pot 55 | 56 | # Django stuff: 57 | *.log 58 | 59 | # Sphinx documentation 60 | docs/_build/ 61 | 62 | # PyBuilder 63 | target/ 64 | 65 | #Ipython Notebook 66 | .ipynb_checkpoints 67 | -------------------------------------------------------------------------------- /openapi/templates/gitlab-ci.mustache: -------------------------------------------------------------------------------- 1 | # NOTE: This file is auto generated by OpenAPI Generator. 2 | # URL: https://openapi-generator.tech 3 | # 4 | # ref: https://docs.gitlab.com/ee/ci/README.html 5 | # ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml 6 | 7 | stages: 8 | - test 9 | 10 | .pytest: 11 | stage: test 12 | script: 13 | - pip install -r requirements.txt 14 | - pip install -r test-requirements.txt 15 | - pytest --cov={{{packageName}}} 16 | 17 | pytest-3.8: 18 | extends: .pytest 19 | image: python:3.8-alpine 20 | pytest-3.9: 21 | extends: .pytest 22 | image: python:3.9-alpine 23 | pytest-3.10: 24 | extends: .pytest 25 | image: python:3.10-alpine 26 | pytest-3.11: 27 | extends: .pytest 28 | image: python:3.11-alpine 29 | pytest-3.12: 30 | extends: .pytest 31 | image: python:3.12-alpine 32 | -------------------------------------------------------------------------------- /openapi/templates/model.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | {{#models}} 6 | {{#model}} 7 | {{#isEnum}} 8 | {{>model_enum}} 9 | {{/isEnum}} 10 | {{^isEnum}} 11 | {{#oneOf}}{{#-first}}{{>model_oneof}}{{/-first}}{{/oneOf}}{{^oneOf}}{{#anyOf}}{{#-first}}{{>model_anyof}}{{/-first}}{{/anyOf}}{{^anyOf}}{{>model_generic}}{{/anyOf}}{{/oneOf}} 12 | {{/isEnum}} 13 | {{/model}} 14 | {{/models}} -------------------------------------------------------------------------------- /openapi/templates/model_doc.mustache: -------------------------------------------------------------------------------- 1 | {{#models}}{{#model}}# {{classname}} 2 | 3 | {{#description}}{{&description}} 4 | {{/description}} 5 | 6 | {{^isEnum}} 7 | ## Properties 8 | 9 | Name | Type | Description | Notes 10 | ------------ | ------------- | ------------- | ------------- 11 | {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} 12 | {{/vars}} 13 | 14 | ## Example 15 | 16 | ```python 17 | from {{modelPackage}}.{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}} import {{classname}} 18 | 19 | # TODO update the JSON string below 20 | json = "{}" 21 | # create an instance of {{classname}} from a JSON string 22 | {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance = {{classname}}.from_json(json) 23 | # print the JSON string representation of the object 24 | print({{classname}}.to_json()) 25 | 26 | # convert the object into a dict 27 | {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict = {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_instance.to_dict() 28 | # create an instance of {{classname}} from a dict 29 | {{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_from_dict = {{classname}}.from_dict({{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}_dict) 30 | ``` 31 | {{/isEnum}} 32 | {{#isEnum}} 33 | ## Enum 34 | {{#allowableValues}}{{#enumVars}} 35 | * `{{name}}` (value: `{{{value}}}`) 36 | {{/enumVars}}{{/allowableValues}} 37 | {{/isEnum}} 38 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 39 | 40 | {{/model}}{{/models}} 41 | -------------------------------------------------------------------------------- /openapi/templates/model_enum.mustache: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | import json 3 | from enum import Enum 4 | {{#vendorExtensions.x-py-other-imports}} 5 | {{{.}}} 6 | {{/vendorExtensions.x-py-other-imports}} 7 | from typing_extensions import Self 8 | 9 | 10 | class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum): 11 | """ 12 | {{{description}}}{{^description}}{{{classname}}}{{/description}} 13 | """ 14 | 15 | """ 16 | allowed enum values 17 | """ 18 | {{#allowableValues}} 19 | {{#enumVars}} 20 | {{{name}}} = {{{value}}} 21 | {{/enumVars}} 22 | 23 | @classmethod 24 | def from_json(cls, json_str: str) -> Self: 25 | """Create an instance of {{classname}} from a JSON string""" 26 | return cls(json.loads(json_str)) 27 | 28 | {{#defaultValue}} 29 | 30 | # 31 | @classmethod 32 | def _missing_value_(cls, value): 33 | if value is no_arg: 34 | return cls.{{{.}}} 35 | {{/defaultValue}} 36 | {{/allowableValues}} 37 | -------------------------------------------------------------------------------- /openapi/templates/model_test.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | import unittest 6 | 7 | {{#models}} 8 | {{#model}} 9 | from {{modelPackage}}.{{classFilename}} import {{classname}} 10 | 11 | class Test{{classname}}(unittest.TestCase): 12 | """{{classname}} unit test stubs""" 13 | 14 | def setUp(self): 15 | pass 16 | 17 | def tearDown(self): 18 | pass 19 | {{^isEnum}} 20 | 21 | def make_instance(self, include_optional) -> {{classname}}: 22 | """Test {{classname}} 23 | include_optional is a boolean, when False only required 24 | params are included, when True both required and 25 | optional params are included """ 26 | # uncomment below to create an instance of `{{{classname}}}` 27 | """ 28 | model = {{classname}}() 29 | if include_optional: 30 | return {{classname}}( 31 | {{#vars}} 32 | {{name}} = {{{example}}}{{^example}}None{{/example}}{{^-last}},{{/-last}} 33 | {{/vars}} 34 | ) 35 | else: 36 | return {{classname}}( 37 | {{#vars}} 38 | {{#required}} 39 | {{name}} = {{{example}}}{{^example}}None{{/example}}, 40 | {{/required}} 41 | {{/vars}} 42 | ) 43 | """ 44 | {{/isEnum}} 45 | 46 | def test{{classname}}(self): 47 | """Test {{classname}}""" 48 | {{^isEnum}} 49 | # inst_req_only = self.make_instance(include_optional=False) 50 | # inst_req_and_optional = self.make_instance(include_optional=True) 51 | {{/isEnum}} 52 | {{#isEnum}} 53 | # inst = {{{classname}}}() 54 | {{/isEnum}} 55 | {{/model}} 56 | {{/models}} 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /openapi/templates/partial_api.mustache: -------------------------------------------------------------------------------- 1 | """{{#isDeprecated}}(Deprecated) {{/isDeprecated}}{{{summary}}}{{^summary}}{{operationId}}{{/summary}} 2 | 3 | {{#notes}} 4 | {{{.}}} 5 | {{/notes}} 6 | 7 | {{#allParams}} 8 | :param {{paramName}}:{{#description}} {{{.}}}{{/description}}{{#required}} (required){{/required}}{{#optional}}(optional){{/optional}} 9 | :type {{paramName}}: {{dataType}}{{#optional}}, optional{{/optional}} 10 | {{/allParams}} 11 | :param _request_timeout: timeout setting for this request. If one 12 | number provided, it will be total request 13 | timeout. It can also be a pair (tuple) of 14 | (connection, read) timeouts. 15 | :type _request_timeout: int, tuple(int, int), optional 16 | :param _request_auth: set to override the auth_settings for an a single 17 | request; this effectively ignores the 18 | authentication in the spec for a single request. 19 | :type _request_auth: dict, optional 20 | :param _content_type: force content-type for the request. 21 | :type _content_type: str, Optional 22 | :param _headers: set to override the headers for a single 23 | request; this effectively ignores the headers 24 | in the spec for a single request. 25 | :type _headers: dict, optional 26 | :param _host_index: set to override the host_index for a single 27 | request; this effectively ignores the host_index 28 | in the spec for a single request. 29 | :type _host_index: int, optional 30 | :return: Returns the result object. 31 | """ # noqa: E501 32 | {{#isDeprecated}} 33 | warnings.warn("{{{httpMethod}}} {{{path}}} is deprecated.", DeprecationWarning) 34 | {{/isDeprecated}} 35 | 36 | _param = self._{{operationId}}_serialize( 37 | {{#allParams}} 38 | {{paramName}}={{paramName}}, 39 | {{/allParams}} 40 | _request_auth=_request_auth, 41 | _content_type=_content_type, 42 | _headers=_headers, 43 | _host_index=_host_index 44 | ) 45 | 46 | _response_types_map: Dict[str, Optional[str]] = { 47 | {{#responses}} 48 | {{^isWildcard}} 49 | '{{code}}': {{#dataType}}"{{.}}"{{/dataType}}{{^dataType}}None{{/dataType}}, 50 | {{/isWildcard}} 51 | {{/responses}} 52 | } -------------------------------------------------------------------------------- /openapi/templates/partial_api_args.mustache: -------------------------------------------------------------------------------- 1 | ( 2 | self, 3 | {{#allParams}} 4 | {{paramName}}: {{{vendorExtensions.x-py-typing}}}{{^required}} = None{{/required}}, 5 | {{/allParams}} 6 | _request_timeout: Union[ 7 | None, 8 | Annotated[StrictFloat, Field(gt=0)], 9 | Tuple[ 10 | Annotated[StrictFloat, Field(gt=0)], 11 | Annotated[StrictFloat, Field(gt=0)] 12 | ] 13 | ] = None, 14 | _request_auth: Optional[Dict[StrictStr, Any]] = None, 15 | _content_type: Optional[StrictStr] = None, 16 | _headers: Optional[Dict[StrictStr, Any]] = None, 17 | _host_index: Annotated[StrictInt, Field(ge=0, le={{#servers.size}}{{servers.size}}{{/servers.size}}{{^servers.size}}1{{/servers.size}})] = 0, 18 | ) -------------------------------------------------------------------------------- /openapi/templates/partial_header.mustache: -------------------------------------------------------------------------------- 1 | """ 2 | {{#appName}} 3 | {{{.}}} 4 | 5 | {{/appName}} 6 | {{#appDescription}} 7 | {{{.}}} 8 | 9 | {{/appDescription}} 10 | {{#version}} 11 | The version of the OpenAPI document: {{{.}}} 12 | {{/version}} 13 | {{#infoEmail}} 14 | Contact: {{{.}}} 15 | {{/infoEmail}} 16 | Generated by OpenAPI Generator (https://openapi-generator.tech) 17 | 18 | Do not edit the class manually. 19 | """ # noqa: E501 20 | -------------------------------------------------------------------------------- /openapi/templates/py.typed.mustache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/openapi/templates/py.typed.mustache -------------------------------------------------------------------------------- /openapi/templates/pyproject.mustache: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "{{{packageName}}}" 3 | version = "{{{packageVersion}}}" 4 | description = "{{{appName}}}" 5 | authors = ["{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}>"] 6 | license = "{{{licenseInfo}}}{{^licenseInfo}}NoLicense{{/licenseInfo}}" 7 | readme = "README.md" 8 | repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}" 9 | keywords = ["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"] 10 | include = ["{{packageName}}/py.typed"] 11 | 12 | [tool.poetry.dependencies] 13 | python = "^3.8" 14 | 15 | urllib3 = ">= 1.25.3 < 3.0.0" 16 | python-dateutil = ">= 2.8.2" 17 | {{#asyncio}} 18 | aiohttp = ">= 3.8.4" 19 | aiohttp-retry = ">= 2.8.3" 20 | {{/asyncio}} 21 | {{#tornado}} 22 | tornado = ">=4.2 <5" 23 | {{/tornado}} 24 | {{#hasHttpSignatureMethods}} 25 | pem = ">= 19.3.0" 26 | pycryptodome = ">= 3.9.0" 27 | {{/hasHttpSignatureMethods}} 28 | pydantic = ">= 2" 29 | typing-extensions = ">= 4.7.1" 30 | 31 | [tool.poetry.dev-dependencies] 32 | pytest = ">= 7.2.1" 33 | pytest-cov = ">= 2.8.1" 34 | tox = ">= 3.9.0" 35 | flake8 = ">= 4.0.0" 36 | types-python-dateutil = ">= 2.8.19.14" 37 | mypy = ">= 1.5" 38 | 39 | 40 | [build-system] 41 | requires = ["setuptools"] 42 | build-backend = "setuptools.build_meta" 43 | 44 | [tool.pylint.'MESSAGES CONTROL'] 45 | extension-pkg-whitelist = "pydantic" 46 | 47 | [tool.mypy] 48 | files = [ 49 | "{{{packageName}}}", 50 | #"test", # auto-generated tests 51 | "tests", # hand-written tests 52 | ] 53 | # TODO: enable "strict" once all these individual checks are passing 54 | # strict = true 55 | 56 | # List from: https://mypy.readthedocs.io/en/stable/existing_code.html#introduce-stricter-options 57 | warn_unused_configs = true 58 | warn_redundant_casts = true 59 | warn_unused_ignores = true 60 | 61 | ## Getting these passing should be easy 62 | strict_equality = true 63 | strict_concatenate = true 64 | 65 | ## Strongly recommend enabling this one as soon as you can 66 | check_untyped_defs = true 67 | 68 | ## These shouldn't be too much additional work, but may be tricky to 69 | ## get passing if you use a lot of untyped libraries 70 | disallow_subclassing_any = true 71 | disallow_untyped_decorators = true 72 | disallow_any_generics = true 73 | 74 | ### These next few are various gradations of forcing use of type annotations 75 | #disallow_untyped_calls = true 76 | #disallow_incomplete_defs = true 77 | #disallow_untyped_defs = true 78 | # 79 | ### This one isn't too hard to get passing, but return on investment is lower 80 | #no_implicit_reexport = true 81 | # 82 | ### This one can be tricky to get passing if you use a lot of untyped libraries 83 | #warn_return_any = true 84 | -------------------------------------------------------------------------------- /openapi/templates/requirements.mustache: -------------------------------------------------------------------------------- 1 | urllib3 >= 1.25.3, < 3.0.0 2 | python_dateutil >= 2.8.2 3 | {{#asyncio}} 4 | aiohttp >= 3.8.4 5 | aiohttp-retry >= 2.8.3 6 | {{/asyncio}} 7 | {{#tornado}} 8 | tornado = ">= 4.2, < 5" 9 | {{/tornado}} 10 | {{#hasHttpSignatureMethods}} 11 | pem >= 19.3.0 12 | pycryptodome >= 3.9.0 13 | {{/hasHttpSignatureMethods}} 14 | pydantic >= 2 15 | typing-extensions >= 4.7.1 16 | -------------------------------------------------------------------------------- /openapi/templates/setup.mustache: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | {{>partial_header}} 4 | 5 | from setuptools import setup, find_packages # noqa: H301 6 | 7 | # To install the library, run the following 8 | # 9 | # python setup.py install 10 | # 11 | # prerequisite: setuptools 12 | # http://pypi.python.org/pypi/setuptools 13 | NAME = "{{{projectName}}}" 14 | VERSION = "{{packageVersion}}" 15 | PYTHON_REQUIRES = ">= 3.8" 16 | {{#apiInfo}} 17 | {{#apis}} 18 | {{#-last}} 19 | REQUIRES = [ 20 | "urllib3 >= 1.25.3, < 3.0.0", 21 | "python-dateutil >= 2.8.2", 22 | {{#asyncio}} 23 | "aiohttp >= 3.8.4", 24 | "aiohttp-retry >= 2.8.3", 25 | {{/asyncio}} 26 | {{#tornado}} 27 | "tornado>=4.2, < 5", 28 | {{/tornado}} 29 | {{#hasHttpSignatureMethods}} 30 | "pem >= 19.3.0", 31 | "pycryptodome >= 3.9.0", 32 | {{/hasHttpSignatureMethods}} 33 | "pydantic >= 2", 34 | "typing-extensions >= 4.7.1", 35 | ] 36 | 37 | setup( 38 | name=NAME, 39 | version=VERSION, 40 | description="{{appName}}", 41 | author="{{infoName}}{{^infoName}}OpenAPI Generator community{{/infoName}}", 42 | author_email="{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}", 43 | url="{{packageUrl}}", 44 | keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"], 45 | install_requires=REQUIRES, 46 | packages=find_packages(exclude=["test", "tests"]), 47 | include_package_data=True, 48 | {{#licenseInfo}}license="{{.}}", 49 | {{/licenseInfo}}long_description_content_type='text/markdown', 50 | long_description="""\ 51 | {{appDescription}} 52 | """, # noqa: E501 53 | package_data={"{{{packageName}}}": ["py.typed"]}, 54 | ) 55 | {{/-last}} 56 | {{/apis}} 57 | {{/apiInfo}} 58 | -------------------------------------------------------------------------------- /openapi/templates/setup_cfg.mustache: -------------------------------------------------------------------------------- 1 | [flake8] 2 | max-line-length=99 3 | -------------------------------------------------------------------------------- /openapi/templates/test-requirements.mustache: -------------------------------------------------------------------------------- 1 | pytest >= 7.2.1 2 | pytest-cov >= 2.8.1 3 | tox >= 3.9.0 4 | flake8 >= 4.0.0 5 | types-python-dateutil >= 2.8.19.14 6 | mypy >= 1.5 7 | -------------------------------------------------------------------------------- /openapi/templates/tox.mustache: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py3 3 | 4 | [testenv] 5 | deps=-r{toxinidir}/requirements.txt 6 | -r{toxinidir}/test-requirements.txt 7 | 8 | commands= 9 | pytest --cov={{{packageName}}} 10 | -------------------------------------------------------------------------------- /openapi/templates/travis.mustache: -------------------------------------------------------------------------------- 1 | # ref: https://docs.travis-ci.com/user/languages/python 2 | language: python 3 | python: 4 | - "3.8" 5 | - "3.9" 6 | - "3.10" 7 | - "3.11" 8 | - "3.12" 9 | # uncomment the following if needed 10 | #- "3.12-dev" # 3.12 development branch 11 | #- "nightly" # nightly build 12 | # command to install dependencies 13 | install: 14 | - "pip install -r requirements.txt" 15 | - "pip install -r test-requirements.txt" 16 | # command to run tests 17 | script: pytest --cov={{{packageName}}} 18 | -------------------------------------------------------------------------------- /openapitools.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", 3 | "spaces": 2, 4 | "generator-cli": { 5 | "version": "7.9.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "rapidata" 3 | version = "2.27.0" 4 | description = "Rapidata package containing the Rapidata Python Client to interact with the Rapidata Web API in an easy way." 5 | authors = ["Rapidata AG "] 6 | license = "Apache-2.0" 7 | readme = "README.md" 8 | packages = [{ include = "rapidata", from = "src" }] 9 | 10 | [tool.poetry.dependencies] 11 | python = "^3.10" 12 | requests = "^2.32.3" 13 | pyjwt = "^2.9.0" 14 | pillow = "^10.4.0" 15 | pydantic = "^2.8.2" 16 | python-dateutil = "^2.9.0.post0" 17 | tqdm = "^4.66.5" 18 | deprecated = "^1.2.14" 19 | colorama = "0.4.6" 20 | tinytag = "^2.0.0" 21 | pandas = "^2.2.3" 22 | authlib = "^1.5.1" 23 | httpx = "^0.28.1" 24 | packaging = "^25.0" 25 | 26 | [tool.poetry.group.dev.dependencies] 27 | python-dotenv = "^1.0.1" 28 | black = "^24.8.0" 29 | 30 | [tool.poetry.group.docs.dependencies] 31 | mkdocs-material = "^9.5.34" 32 | mkdocstrings = { extras = ["python"], version = "^0.26.0" } 33 | mkdocs-autorefs = "^1.2.0" 34 | mkdocs-gen-files = "^0.5.0" 35 | mkdocs-literate-nav = "^0.6.1" 36 | pygments = "^2.18.0" 37 | mkdocs-section-index = "^0.3.9" 38 | mike = "^2.1.3" 39 | 40 | [build-system] 41 | requires = ["poetry-core"] 42 | build-backend = "poetry.core.masonry.api" 43 | -------------------------------------------------------------------------------- /pyrightconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["src/rapidata/rapidata_client"] 3 | } 4 | -------------------------------------------------------------------------------- /scripts/gen_ref_pages.py: -------------------------------------------------------------------------------- 1 | """Generate the code reference pages and navigation.""" 2 | 3 | from pathlib import Path 4 | 5 | import mkdocs_gen_files 6 | 7 | nav = mkdocs_gen_files.Nav() # type: ignore 8 | 9 | root = Path(__file__).parent.parent 10 | src = root / "src" 11 | 12 | for path in sorted(src.rglob("*.py")): 13 | module_path = path.relative_to(src).with_suffix("") 14 | 15 | # Skip files that start with underscore 16 | if any(part.startswith('_') for part in module_path.parts): 17 | continue 18 | 19 | if "rapidata_client" not in str(module_path): 20 | continue 21 | 22 | doc_path = path.relative_to(src).with_suffix(".md") 23 | full_doc_path = Path("reference", doc_path) 24 | 25 | parts = tuple(module_path.parts) 26 | 27 | if parts[-1] == "__init__": 28 | parts = parts[:-1] 29 | doc_path = doc_path.with_name("index.md") 30 | full_doc_path = full_doc_path.with_name("index.md") 31 | elif parts[-1] == "__main__": 32 | continue 33 | 34 | nav[parts] = doc_path.as_posix() 35 | 36 | with mkdocs_gen_files.open(full_doc_path, "w") as fd: 37 | ident = ".".join(parts) 38 | fd.write(f"::: {ident}") 39 | 40 | mkdocs_gen_files.set_edit_path(full_doc_path, path.relative_to(root)) 41 | 42 | with mkdocs_gen_files.open("reference/SUMMARY.md", "w") as nav_file: 43 | nav_file.writelines(nav.build_literate_nav()) 44 | -------------------------------------------------------------------------------- /src/.openapi-generator-ignore: -------------------------------------------------------------------------------- 1 | # OpenAPI Generator Ignore 2 | # Generated by openapi-generator https://github.com/openapitools/openapi-generator 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | 25 | api_client*.md 26 | -------------------------------------------------------------------------------- /src/rapidata/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "2.27.0" 2 | 3 | from .rapidata_client import ( 4 | RapidataClient, 5 | DemographicSelection, 6 | LabelingSelection, 7 | RetrievalMode, 8 | ValidationSelection, 9 | ConditionalValidationSelection, 10 | CappedSelection, 11 | ShufflingSelection, 12 | RapidataSettings, 13 | TranslationBehaviourOptions, 14 | AlertOnFastResponse, 15 | TranslationBehaviour, 16 | FreeTextMinimumCharacters, 17 | NoShuffle, 18 | PlayVideoUntilTheEnd, 19 | CustomSetting, 20 | CountryFilter, 21 | LanguageFilter, 22 | UserScoreFilter, 23 | CampaignFilter, 24 | CustomFilter, 25 | NotFilter, 26 | OrFilter, 27 | AgeFilter, 28 | AgeGroup, 29 | GenderFilter, 30 | Gender, 31 | CountryCodes, 32 | MediaAsset, 33 | TextAsset, 34 | MultiAsset, 35 | RapidataDataTypes, 36 | Box, 37 | PromptMetadata, 38 | logger, 39 | configure_logger, 40 | RapidataOutputManager, 41 | ) 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/api/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | 3 | # import apis into api package 4 | from rapidata.api_client.api.campaign_api import CampaignApi 5 | from rapidata.api_client.api.client_api import ClientApi 6 | from rapidata.api_client.api.coco_api import CocoApi 7 | from rapidata.api_client.api.compare_workflow_api import CompareWorkflowApi 8 | from rapidata.api_client.api.customer_rapid_api import CustomerRapidApi 9 | from rapidata.api_client.api.datapoint_api import DatapointApi 10 | from rapidata.api_client.api.dataset_api import DatasetApi 11 | from rapidata.api_client.api.evaluation_workflow_api import EvaluationWorkflowApi 12 | from rapidata.api_client.api.feedback_api import FeedbackApi 13 | from rapidata.api_client.api.identity_api import IdentityApi 14 | from rapidata.api_client.api.newsletter_api import NewsletterApi 15 | from rapidata.api_client.api.order_api import OrderApi 16 | from rapidata.api_client.api.pipeline_api import PipelineApi 17 | from rapidata.api_client.api.rapidata_identity_api_api import RapidataIdentityAPIApi 18 | from rapidata.api_client.api.simple_workflow_api import SimpleWorkflowApi 19 | from rapidata.api_client.api.user_info_api import UserInfoApi 20 | from rapidata.api_client.api.user_rapid_api import UserRapidApi 21 | from rapidata.api_client.api.validation_set_api import ValidationSetApi 22 | from rapidata.api_client.api.workflow_api import WorkflowApi 23 | 24 | -------------------------------------------------------------------------------- /src/rapidata/api_client/api_response.py: -------------------------------------------------------------------------------- 1 | """API response object.""" 2 | 3 | from __future__ import annotations 4 | from typing import Optional, Generic, Mapping, TypeVar 5 | from pydantic import Field, StrictInt, StrictBytes, BaseModel 6 | 7 | T = TypeVar("T") 8 | 9 | class ApiResponse(BaseModel, Generic[T]): 10 | """ 11 | API response object 12 | """ 13 | 14 | status_code: StrictInt = Field(description="HTTP status code") 15 | headers: Optional[Mapping[str, str]] = Field(None, description="HTTP headers") 16 | data: T = Field(description="Deserialized data given the data type") 17 | raw_data: StrictBytes = Field(description="Raw data (HTTP response body)") 18 | 19 | model_config = { 20 | "arbitrary_types_allowed": True 21 | } 22 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/age_group.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class AgeGroup(str, Enum): 22 | """ 23 | AgeGroup 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | ENUM_0_MINUS_17 = '0-17' 30 | ENUM_18_MINUS_29 = '18-29' 31 | ENUM_30_MINUS_39 = '30-39' 32 | ENUM_40_MINUS_49 = '40-49' 33 | ENUM_50_MINUS_64 = '50-64' 34 | ENUM_65_PLUS = '65+' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of AgeGroup from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/aggregator_type.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class AggregatorType(str, Enum): 22 | """ 23 | AggregatorType 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | NONCOMMITTAL = 'NonCommittal' 30 | MAJORITYVOTE = 'MajorityVote' 31 | SIMPLEMATCHUP = 'SimpleMatchup' 32 | LOCATECLUSTER = 'LocateCluster' 33 | CLASSIFICATION = 'Classification' 34 | LOCATE = 'Locate' 35 | BOUNDINGBOX = 'BoundingBox' 36 | LINE = 'Line' 37 | TRANSCRIPTION = 'Transcription' 38 | SINGLEPOINTLOCATE = 'SinglePointLocate' 39 | FREETEXT = 'FreeText' 40 | SCRUB = 'Scrub' 41 | 42 | @classmethod 43 | def from_json(cls, json_str: str) -> Self: 44 | """Create an instance of AggregatorType from a JSON string""" 45 | return cls(json.loads(json_str)) 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/are_rapids_active_result.py: -------------------------------------------------------------------------------- 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 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class AreRapidsActiveResult(BaseModel): 26 | """ 27 | AreRapidsActiveResult 28 | """ # noqa: E501 29 | is_valid: StrictBool = Field(alias="isValid") 30 | __properties: ClassVar[List[str]] = ["isValid"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of AreRapidsActiveResult from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of AreRapidsActiveResult from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "isValid": obj.get("isValid") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/base_error.py: -------------------------------------------------------------------------------- 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, 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 BaseError(BaseModel): 26 | """ 27 | BaseError 28 | """ # noqa: E501 29 | error_message: Optional[StrictStr] = Field(default=None, alias="errorMessage") 30 | __properties: ClassVar[List[str]] = ["errorMessage"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of BaseError from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of BaseError from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "errorMessage": obj.get("errorMessage") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/campaign_status.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class CampaignStatus(str, Enum): 22 | """ 23 | CampaignStatus 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | CREATED = 'Created' 30 | PREVIEW = 'Preview' 31 | ACTIVE = 'Active' 32 | ANALYSIS = 'Analysis' 33 | PAUSED = 'Paused' 34 | COMPLETED = 'Completed' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of CampaignStatus from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/compare_match_status.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class CompareMatchStatus(str, Enum): 22 | """ 23 | CompareMatchStatus 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | IDLE = 'Idle' 30 | QUEUED = 'Queued' 31 | PROCESSING = 'Processing' 32 | COMPLETED = 'Completed' 33 | 34 | @classmethod 35 | def from_json(cls, json_str: str) -> Self: 36 | """Create an instance of CompareMatchStatus from a JSON string""" 37 | return cls(json.loads(json_str)) 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/comparison_operator.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class ComparisonOperator(str, Enum): 22 | """ 23 | ComparisonOperator 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | EQUAL = 'Equal' 30 | NOTEQUAL = 'NotEqual' 31 | LESSTHAN = 'LessThan' 32 | LESSTHANOREQUAL = 'LessThanOrEqual' 33 | GREATERTHAN = 'GreaterThan' 34 | GREATERTHANOREQUAL = 'GreaterThanOrEqual' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of ComparisonOperator from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/create_rapid_result.py: -------------------------------------------------------------------------------- 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, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class CreateRapidResult(BaseModel): 26 | """ 27 | CreateRapidResult 28 | """ # noqa: E501 29 | rapid_id: StrictStr = Field(alias="rapidId") 30 | __properties: ClassVar[List[str]] = ["rapidId"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of CreateRapidResult from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of CreateRapidResult from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "rapidId": obj.get("rapidId") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/datapoint_state.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class DatapointState(str, Enum): 22 | """ 23 | DatapointState 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | READY = 'Ready' 30 | PENDING = 'Pending' 31 | FAILED = 'Failed' 32 | 33 | @classmethod 34 | def from_json(cls, json_str: str) -> Self: 35 | """Create an instance of DatapointState from a JSON string""" 36 | return cls(json.loads(json_str)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/error_type.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class ErrorType(str, Enum): 22 | """ 23 | ErrorType 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | VALIDATION = 'Validation' 30 | AUTHORIZATION = 'Authorization' 31 | RUNTIME = 'Runtime' 32 | NOTFOUND = 'NotFound' 33 | TIMEOUT = 'Timeout' 34 | 35 | @classmethod 36 | def from_json(cls, json_str: str) -> Self: 37 | """Create an instance of ErrorType from a JSON string""" 38 | return cls(json.loads(json_str)) 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/feature_flag.py: -------------------------------------------------------------------------------- 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, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class FeatureFlag(BaseModel): 26 | """ 27 | FeatureFlag 28 | """ # noqa: E501 29 | key: StrictStr 30 | value: StrictStr 31 | __properties: ClassVar[List[str]] = ["key", "value"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of FeatureFlag from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of FeatureFlag from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "key": obj.get("key"), 85 | "value": obj.get("value") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/filter_operator.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class FilterOperator(str, Enum): 22 | """ 23 | FilterOperator 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | EQ = 'Eq' 30 | NEQ = 'Neq' 31 | GT = 'Gt' 32 | GTE = 'Gte' 33 | LT = 'Lt' 34 | LTE = 'Lte' 35 | CONTAINS = 'Contains' 36 | STARTSWITH = 'StartsWith' 37 | ENDSWITH = 'EndsWith' 38 | 39 | @classmethod 40 | def from_json(cls, json_str: str) -> Self: 41 | """Create an instance of FilterOperator from a JSON string""" 42 | return cls(json.loads(json_str)) 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/gender.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class Gender(str, Enum): 22 | """ 23 | Gender 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | MALE = 'Male' 30 | FEMALE = 'Female' 31 | OTHER = 'Other' 32 | 33 | @classmethod 34 | def from_json(cls, json_str: str) -> Self: 35 | """Create an instance of Gender from a JSON string""" 36 | return cls(json.loads(json_str)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/get_dataset_by_id_result.py: -------------------------------------------------------------------------------- 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, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class GetDatasetByIdResult(BaseModel): 26 | """ 27 | GetDatasetByIdResult 28 | """ # noqa: E501 29 | name: StrictStr 30 | __properties: ClassVar[List[str]] = ["name"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of GetDatasetByIdResult from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of GetDatasetByIdResult from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "name": obj.get("name") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/import_from_file_result.py: -------------------------------------------------------------------------------- 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, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ImportFromFileResult(BaseModel): 26 | """ 27 | ImportFromFileResult 28 | """ # noqa: E501 29 | dataset_id: StrictStr = Field(alias="datasetId") 30 | __properties: ClassVar[List[str]] = ["datasetId"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of ImportFromFileResult from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of ImportFromFileResult from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "datasetId": obj.get("datasetId") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/logic_operator.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class LogicOperator(str, Enum): 22 | """ 23 | LogicOperator 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | AND = 'And' 30 | OR = 'Or' 31 | NOT = 'Not' 32 | 33 | @classmethod 34 | def from_json(cls, json_str: str) -> Self: 35 | """Create an instance of LogicOperator from a JSON string""" 36 | return cls(json.loads(json_str)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/metadata_visibilities.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class MetadataVisibilities(str, Enum): 22 | """ 23 | MetadataVisibilities 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | NONE = 'None' 30 | USERS = 'Users' 31 | CUSTOMERS = 'Customers' 32 | ADMINS = 'Admins' 33 | DASHBOARD = 'Dashboard' 34 | ALL = 'All' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of MetadataVisibilities from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/order_state.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class OrderState(str, Enum): 22 | """ 23 | OrderState 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | CREATED = 'Created' 30 | PREVIEW = 'Preview' 31 | SUBMITTED = 'Submitted' 32 | MANUALREVIEW = 'ManualReview' 33 | PROCESSING = 'Processing' 34 | PAUSED = 'Paused' 35 | COMPLETED = 'Completed' 36 | CANCELLED = 'Cancelled' 37 | FAILED = 'Failed' 38 | 39 | @classmethod 40 | def from_json(cls, json_str: str) -> Self: 41 | """Create an instance of OrderState from a JSON string""" 42 | return cls(json.loads(json_str)) 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/rapid_issue.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class RapidIssue(str, Enum): 22 | """ 23 | RapidIssue 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | OTHER = 'Other' 30 | CANNOTSUBMIT = 'CannotSubmit' 31 | NOASSET = 'NoAsset' 32 | INAPPROPRIATE = 'Inappropriate' 33 | NOCORRECTOPTION = 'NoCorrectOption' 34 | WRONGLANGUAGE = 'WrongLanguage' 35 | DONOTUNDERSTAND = 'DoNotUnderstand' 36 | DONOTCARE = 'DoNotCare' 37 | NOTSEEOPTIONSORMEDIADIDNTLOAD = 'NotSeeOptionsOrMediaDidntLoad' 38 | MYANSWERISCORRECT = 'MyAnswerIsCorrect' 39 | 40 | @classmethod 41 | def from_json(cls, json_str: str) -> Self: 42 | """Create an instance of RapidIssue from a JSON string""" 43 | return cls(json.loads(json_str)) 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/rapid_state.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class RapidState(str, Enum): 22 | """ 23 | RapidState 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | LABELING = 'Labeling' 30 | PAUSED = 'Paused' 31 | INCOMPLETE = 'Incomplete' 32 | FLAGGED = 'Flagged' 33 | DONE = 'Done' 34 | NONE = 'None' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of RapidState from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/retrieval_mode.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class RetrievalMode(str, Enum): 22 | """ 23 | RetrievalMode 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | RANDOM = 'Random' 30 | SHUFFLED = 'Shuffled' 31 | SEQUENTIAL = 'Sequential' 32 | 33 | @classmethod 34 | def from_json(cls, json_str: str) -> Self: 35 | """Create an instance of RetrievalMode from a JSON string""" 36 | return cls(json.loads(json_str)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/scrub_range.py: -------------------------------------------------------------------------------- 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, StrictInt 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class ScrubRange(BaseModel): 26 | """ 27 | ScrubRange 28 | """ # noqa: E501 29 | start: StrictInt 30 | end: StrictInt 31 | __properties: ClassVar[List[str]] = ["start", "end"] 32 | 33 | model_config = ConfigDict( 34 | populate_by_name=True, 35 | validate_assignment=True, 36 | protected_namespaces=(), 37 | ) 38 | 39 | 40 | def to_str(self) -> str: 41 | """Returns the string representation of the model using alias""" 42 | return pprint.pformat(self.model_dump(by_alias=True)) 43 | 44 | def to_json(self) -> str: 45 | """Returns the JSON representation of the model using alias""" 46 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 47 | return json.dumps(self.to_dict()) 48 | 49 | @classmethod 50 | def from_json(cls, json_str: str) -> Optional[Self]: 51 | """Create an instance of ScrubRange from a JSON string""" 52 | return cls.from_dict(json.loads(json_str)) 53 | 54 | def to_dict(self) -> Dict[str, Any]: 55 | """Return the dictionary representation of the model using alias. 56 | 57 | This has the following differences from calling pydantic's 58 | `self.model_dump(by_alias=True)`: 59 | 60 | * `None` is only added to the output dict for nullable fields that 61 | were set at model initialization. Other fields with value `None` 62 | are ignored. 63 | """ 64 | excluded_fields: Set[str] = set([ 65 | ]) 66 | 67 | _dict = self.model_dump( 68 | by_alias=True, 69 | exclude=excluded_fields, 70 | exclude_none=True, 71 | ) 72 | return _dict 73 | 74 | @classmethod 75 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 76 | """Create an instance of ScrubRange from a dict""" 77 | if obj is None: 78 | return None 79 | 80 | if not isinstance(obj, dict): 81 | return cls.model_validate(obj) 82 | 83 | _obj = cls.model_validate({ 84 | "start": obj.get("start"), 85 | "end": obj.get("end") 86 | }) 87 | return _obj 88 | 89 | 90 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/sort_direction.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class SortDirection(str, Enum): 22 | """ 23 | SortDirection 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | ASC = 'Asc' 30 | DESC = 'Desc' 31 | 32 | @classmethod 33 | def from_json(cls, json_str: str) -> Self: 34 | """Create an instance of SortDirection from a JSON string""" 35 | return cls(json.loads(json_str)) 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/sticky_state.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class StickyState(str, Enum): 22 | """ 23 | StickyState 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | NONE = 'None' 30 | TEMPORARY = 'Temporary' 31 | PERMANENT = 'Permanent' 32 | 33 | @classmethod 34 | def from_json(cls, json_str: str) -> Self: 35 | """Create an instance of StickyState from a JSON string""" 36 | return cls(json.loads(json_str)) 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/unlock_order_result.py: -------------------------------------------------------------------------------- 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, StrictStr 21 | from typing import Any, ClassVar, Dict, List 22 | from typing import Optional, Set 23 | from typing_extensions import Self 24 | 25 | class UnlockOrderResult(BaseModel): 26 | """ 27 | UnlockOrderResult 28 | """ # noqa: E501 29 | dataset_ids: Dict[str, StrictStr] = Field(alias="datasetIds") 30 | __properties: ClassVar[List[str]] = ["datasetIds"] 31 | 32 | model_config = ConfigDict( 33 | populate_by_name=True, 34 | validate_assignment=True, 35 | protected_namespaces=(), 36 | ) 37 | 38 | 39 | def to_str(self) -> str: 40 | """Returns the string representation of the model using alias""" 41 | return pprint.pformat(self.model_dump(by_alias=True)) 42 | 43 | def to_json(self) -> str: 44 | """Returns the JSON representation of the model using alias""" 45 | # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 46 | return json.dumps(self.to_dict()) 47 | 48 | @classmethod 49 | def from_json(cls, json_str: str) -> Optional[Self]: 50 | """Create an instance of UnlockOrderResult from a JSON string""" 51 | return cls.from_dict(json.loads(json_str)) 52 | 53 | def to_dict(self) -> Dict[str, Any]: 54 | """Return the dictionary representation of the model using alias. 55 | 56 | This has the following differences from calling pydantic's 57 | `self.model_dump(by_alias=True)`: 58 | 59 | * `None` is only added to the output dict for nullable fields that 60 | were set at model initialization. Other fields with value `None` 61 | are ignored. 62 | """ 63 | excluded_fields: Set[str] = set([ 64 | ]) 65 | 66 | _dict = self.model_dump( 67 | by_alias=True, 68 | exclude=excluded_fields, 69 | exclude_none=True, 70 | ) 71 | return _dict 72 | 73 | @classmethod 74 | def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 75 | """Create an instance of UnlockOrderResult from a dict""" 76 | if obj is None: 77 | return None 78 | 79 | if not isinstance(obj, dict): 80 | return cls.model_validate(obj) 81 | 82 | _obj = cls.model_validate({ 83 | "datasetIds": obj.get("datasetIds") 84 | }) 85 | return _obj 86 | 87 | 88 | -------------------------------------------------------------------------------- /src/rapidata/api_client/models/workflow_state.py: -------------------------------------------------------------------------------- 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 json 17 | from enum import Enum 18 | from typing_extensions import Self 19 | 20 | 21 | class WorkflowState(str, Enum): 22 | """ 23 | WorkflowState 24 | """ 25 | 26 | """ 27 | allowed enum values 28 | """ 29 | CREATED = 'Created' 30 | STARTED = 'Started' 31 | LABELING = 'Labeling' 32 | PAUSED = 'Paused' 33 | DONE = 'Done' 34 | FAILED = 'Failed' 35 | 36 | @classmethod 37 | def from_json(cls, json_str: str) -> Self: 38 | """Create an instance of WorkflowState from a JSON string""" 39 | return cls(json.loads(json_str)) 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/__init__.py: -------------------------------------------------------------------------------- 1 | from .rapidata_client import RapidataClient 2 | from .selection import ( 3 | DemographicSelection, 4 | LabelingSelection, 5 | ValidationSelection, 6 | ConditionalValidationSelection, 7 | CappedSelection, 8 | ShufflingSelection, 9 | RetrievalMode, 10 | ) 11 | from .metadata import ( 12 | PrivateTextMetadata, 13 | PublicTextMetadata, 14 | PromptMetadata, 15 | SelectWordsMetadata, 16 | ) 17 | from .settings import ( 18 | RapidataSettings, 19 | TranslationBehaviourOptions, 20 | AlertOnFastResponse, 21 | TranslationBehaviour, 22 | FreeTextMinimumCharacters, 23 | NoShuffle, 24 | PlayVideoUntilTheEnd, 25 | CustomSetting, 26 | ) 27 | from .country_codes import CountryCodes 28 | from .assets import ( 29 | MediaAsset, 30 | TextAsset, 31 | MultiAsset, 32 | RapidataDataTypes 33 | ) 34 | from .filter import ( 35 | CountryFilter, 36 | LanguageFilter, 37 | UserScoreFilter, 38 | CampaignFilter, 39 | AgeFilter, 40 | GenderFilter, 41 | CustomFilter, 42 | AgeGroup, 43 | Gender, 44 | NotFilter, 45 | OrFilter, 46 | ResponseCountFilter, 47 | ) 48 | 49 | from .logging import ( 50 | configure_logger, 51 | logger, 52 | RapidataOutputManager 53 | ) 54 | 55 | from .validation import Box 56 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/src/rapidata/rapidata_client/api/__init__.py -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/__init__.py: -------------------------------------------------------------------------------- 1 | """Assets Package 2 | 3 | This package provides classes for different types of assets, including MediaAsset, TextAsset, and MultiAsset. 4 | """ 5 | from ._base_asset import BaseAsset 6 | from ._media_asset import MediaAsset 7 | from ._text_asset import TextAsset 8 | from ._multi_asset import MultiAsset 9 | from .data_type_enum import RapidataDataTypes 10 | from ._sessions import SessionManager 11 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/_base_asset.py: -------------------------------------------------------------------------------- 1 | """Base Asset Module 2 | 3 | Defines the BaseAsset class, which serves as the abstract base class for all asset types. 4 | """ 5 | 6 | class BaseAsset: 7 | """BaseAsset Class 8 | 9 | An abstract base class for different types of assets. This class is intended to be subclassed by specific asset types. 10 | """ 11 | pass 12 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/_multi_asset.py: -------------------------------------------------------------------------------- 1 | """Multi Asset Module 2 | 3 | Defines the MultiAsset class for handling multiple BaseAsset instances. 4 | """ 5 | 6 | from rapidata.rapidata_client.assets._base_asset import BaseAsset 7 | from rapidata.rapidata_client.assets import MediaAsset, TextAsset 8 | from typing import Iterator, Sequence, cast 9 | 10 | 11 | class MultiAsset(BaseAsset): 12 | """MultiAsset Class 13 | 14 | Represents a collection of multiple BaseAsset instances. 15 | 16 | Args: 17 | assets (List[BaseAsset]): A list of BaseAsset instances to be managed together. 18 | """ 19 | 20 | def __init__(self, assets: Sequence[BaseAsset]) -> None: 21 | """ 22 | Initialize a MultiAsset instance. 23 | 24 | Args: 25 | assets (List[BaseAsset]): A list of BaseAsset instances to be managed together. 26 | """ 27 | if len(assets) != 2: 28 | raise ValueError("Assets must come in pairs for comparison tasks.") 29 | 30 | for asset in assets: 31 | if not isinstance(asset, (TextAsset, MediaAsset)): 32 | raise TypeError("All assets must be a TextAsset or MediaAsset.") 33 | 34 | if not all(isinstance(asset, type(assets[0])) for asset in assets): 35 | raise ValueError("All assets must be of the same type.") 36 | 37 | self.assets = assets 38 | 39 | def __len__(self) -> int: 40 | """ 41 | Get the number of assets in the MultiAsset. 42 | 43 | Returns: 44 | int: The number of assets. 45 | """ 46 | return len(self.assets) 47 | 48 | def __iter__(self) -> Iterator[BaseAsset]: 49 | """ 50 | Return an iterator over the assets in the MultiAsset. 51 | 52 | Returns: 53 | Iterator[BaseAsset]: An iterator over the assets. 54 | """ 55 | return iter(self.assets) 56 | 57 | def __str__(self) -> str: 58 | return f"MultiAsset(assets={self.assets})" 59 | 60 | def __repr__(self) -> str: 61 | return f"MultiAsset(assets={self.assets})" 62 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/_sessions.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from requests.adapters import HTTPAdapter 3 | from urllib3.util.retry import Retry 4 | 5 | class SessionManager: 6 | _session = None 7 | 8 | @classmethod 9 | def get_session(cls, ) -> requests.Session: 10 | """Get a singleton requests session with retry logic. 11 | 12 | Returns: 13 | requests.Session: A singleton requests session with retry logic. 14 | """ 15 | if cls._session is None: 16 | max_retries: int = 5 17 | max_workers: int = 10 18 | cls._session = requests.Session() 19 | retries = Retry( 20 | total=max_retries, 21 | backoff_factor=1, 22 | status_forcelist=[500, 502, 503, 504], 23 | allowed_methods=["GET"], 24 | respect_retry_after_header=True 25 | ) 26 | 27 | adapter = HTTPAdapter( 28 | pool_connections=max_workers * 2, 29 | pool_maxsize=max_workers * 4, 30 | max_retries=retries 31 | ) 32 | cls._session.mount('http://', adapter) 33 | cls._session.mount('https://', adapter) 34 | 35 | return cls._session 36 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/_text_asset.py: -------------------------------------------------------------------------------- 1 | """Text Asset Module 2 | 3 | Defines the TextAsset class for handling textual data within assets. 4 | """ 5 | 6 | from rapidata.rapidata_client.assets._base_asset import BaseAsset 7 | 8 | 9 | class TextAsset(BaseAsset): 10 | """TextAsset Class 11 | 12 | Represents a textual asset. 13 | 14 | Args: 15 | text (str): The text content of the asset. 16 | """ 17 | 18 | def __init__(self, text: str): 19 | """ 20 | Initialize a TextAsset instance. 21 | 22 | Args: 23 | text (str): The textual content of the asset. 24 | """ 25 | if not isinstance(text, str): 26 | raise ValueError("Text must be a string") 27 | 28 | self.text = text 29 | 30 | def __str__(self) -> str: 31 | return f"TextAsset(text={self.text})" 32 | 33 | def __repr__(self) -> str: 34 | return f"TextAsset(text={self.text})" 35 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/assets/data_type_enum.py: -------------------------------------------------------------------------------- 1 | class RapidataDataTypes: 2 | MEDIA = "media" # any form of image, video or audio 3 | TEXT = "text" 4 | 5 | @classmethod 6 | def _possible_values(cls): 7 | return [cls.MEDIA, cls.TEXT] 8 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/country_codes/__init__.py: -------------------------------------------------------------------------------- 1 | from .country_codes import CountryCodes 2 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/country_codes/country_codes.py: -------------------------------------------------------------------------------- 1 | class CountryCodes: 2 | 3 | ENGLISH_SPEAKING = [ 4 | "AU", 5 | "BE", 6 | "CA", 7 | "DK", 8 | "FI", 9 | "IE", 10 | "LU", 11 | "NL", 12 | "NZ", 13 | "NO", 14 | "SG", 15 | "SE", 16 | "GB", 17 | "US", 18 | ] 19 | GERMAN_SPEAKING = ["AT", "DE"] 20 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/demographic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/src/rapidata/rapidata_client/demographic/__init__.py -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/demographic/demographic_manager.py: -------------------------------------------------------------------------------- 1 | from rapidata.service.openapi_service import OpenAPIService 2 | from rapidata.rapidata_client.assets import MediaAsset 3 | from rapidata.api_client.models.create_demographic_rapid_model import CreateDemographicRapidModel 4 | from rapidata.api_client.models.classify_payload import ClassifyPayload 5 | from rapidata.rapidata_client.logging import logger 6 | 7 | class DemographicManager: 8 | def __init__(self, openapi_service: OpenAPIService): 9 | self._openapi_service = openapi_service 10 | logger.debug("DemographicManager initialized") 11 | 12 | def create_demographic_rapid(self, 13 | instruction: str, 14 | answer_options: list[str], 15 | datapoint: str, 16 | key: str): 17 | 18 | media = MediaAsset(path=datapoint) 19 | model = CreateDemographicRapidModel( 20 | key=key, 21 | payload=ClassifyPayload( 22 | _t="ClassifyPayload", 23 | possibleCategories=answer_options, 24 | title=instruction 25 | ) 26 | ) 27 | 28 | self._openapi_service.rapid_api.rapid_demographic_post(model=model, file=[media.to_file()]) 29 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/__init__.py: -------------------------------------------------------------------------------- 1 | from ._base_filter import RapidataFilter 2 | from .age_filter import AgeFilter, AgeGroup 3 | from .campaign_filter import CampaignFilter 4 | from .country_filter import CountryFilter 5 | from .gender_filter import GenderFilter, Gender 6 | from .language_filter import LanguageFilter 7 | from .user_score_filter import UserScoreFilter 8 | from .custom_filter import CustomFilter 9 | from .not_filter import NotFilter 10 | from .or_filter import OrFilter 11 | from .response_count_filter import ResponseCountFilter 12 | from .new_user_filter import NewUserFilter 13 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/_base_filter.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | 5 | class RapidataFilter: 6 | """The base class for all Rapidata Filters.""" 7 | 8 | @abstractmethod 9 | def _to_model(self) -> Any: 10 | pass 11 | 12 | def __or__(self, other): 13 | """Enable the | operator to create OrFilter combinations.""" 14 | if not isinstance(other, RapidataFilter): 15 | return NotImplemented 16 | 17 | from rapidata.rapidata_client.filter.or_filter import OrFilter 18 | 19 | # If self is already an OrFilter, extend its filters list 20 | if isinstance(self, OrFilter): 21 | if isinstance(other, OrFilter): 22 | return OrFilter(self.filters + other.filters) 23 | else: 24 | return OrFilter(self.filters + [other]) 25 | # If other is an OrFilter, prepend self to its filters 26 | elif isinstance(other, OrFilter): 27 | return OrFilter([self] + other.filters) 28 | # Neither is an OrFilter, create a new one 29 | else: 30 | return OrFilter([self, other]) 31 | 32 | def __invert__(self): 33 | """Enable the ~ operator to create NotFilter negations.""" 34 | from rapidata.rapidata_client.filter.not_filter import NotFilter 35 | 36 | # If self is already a NotFilter, return the original filter (double negation) 37 | if isinstance(self, NotFilter): 38 | return self.filter 39 | # Create a new NotFilter 40 | else: 41 | return NotFilter(self) 42 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/age_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.age_user_filter_model import AgeUserFilterModel 4 | from rapidata.rapidata_client.filter.models.age_group import AgeGroup 5 | 6 | 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.""" 15 | 16 | def __init__(self, age_groups: list[AgeGroup]): 17 | self.age_groups = age_groups 18 | 19 | def _to_model(self): 20 | return AgeUserFilterModel( 21 | _t="AgeFilter", 22 | ageGroups=[age_group._to_backend_model() for age_group in self.age_groups], 23 | ) 24 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/campaign_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.campaign_user_filter_model import ( 4 | CampaignUserFilterModel, 5 | ) 6 | 7 | 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 | """ 18 | 19 | def __init__(self, campaign_ids: list[str]): 20 | self.campaign_ids = campaign_ids 21 | 22 | def _to_model(self): 23 | return CampaignUserFilterModel( 24 | _t="CampaignFilter", 25 | campaignIds=self.campaign_ids, 26 | ) 27 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/country_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.country_user_filter_model import CountryUserFilterModel 4 | 5 | 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 (capitalized) to filter by. 13 | """ 14 | 15 | def __init__(self, country_codes: list[str]): 16 | # check that all characters in the country codes are uppercase 17 | if not isinstance(country_codes, list): 18 | raise ValueError("Country codes must be a list") 19 | 20 | if not all([code.isupper() for code in country_codes]): 21 | raise ValueError("Country codes must be uppercase") 22 | 23 | self.country_codes = country_codes 24 | 25 | def _to_model(self): 26 | return CountryUserFilterModel(_t="CountryFilter", countries=self.country_codes) 27 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/custom_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.custom_user_filter_model import CustomUserFilterModel 4 | 5 | 6 | class CustomFilter(RapidataFilter): 7 | """CustomFilter Class 8 | 9 | Can be used to filter who to target based on custom filters. 10 | 11 | Ought to be used with contact to Rapidata. 12 | 13 | Warning: If identifier does not exist, order will not get any responses. 14 | 15 | Args: 16 | identifier (str): Identifier of the custom filter. 17 | values (list[str]): List of values to filter by. 18 | """ 19 | 20 | def __init__(self, identifier: str, values: list[str]): 21 | self.identifier = identifier 22 | self.values = values 23 | 24 | def _to_model(self): 25 | return CustomUserFilterModel( 26 | _t="CustomFilter", 27 | identifier=self.identifier, 28 | values=self.values, 29 | ) 30 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/gender_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.gender_user_filter_model import GenderUserFilterModel 4 | from rapidata.rapidata_client.filter.models.gender import Gender 5 | 6 | 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.""" 15 | 16 | def __init__(self, genders: list[Gender]): 17 | self.genders = genders 18 | 19 | def _to_model(self): 20 | return GenderUserFilterModel( 21 | _t="GenderFilter", 22 | genders=[gender._to_backend_model() for gender in self.genders], 23 | ) 24 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/language_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.language_user_filter_model import ( 4 | LanguageUserFilterModel, 5 | ) 6 | 7 | 8 | class LanguageFilter(RapidataFilter): 9 | """LanguageFilter Class 10 | 11 | Can be used to filter who to target based on language codes. 12 | 13 | Args: 14 | language_codes (list[str]): List of language codes to filter by. 15 | 16 | Example: 17 | ```python 18 | LanguageFilter(["en", "de"]) 19 | ``` 20 | This will limit the order to be shown to only people who have their phone set to english or german 21 | """ 22 | def __init__(self, language_codes: list[str]): 23 | if not isinstance(language_codes, list): 24 | raise ValueError("Language codes must be a list") 25 | 26 | # check that all characters in the language codes are lowercase 27 | if not all([code.islower() for code in language_codes]): 28 | raise ValueError("Language codes must be lowercase") 29 | 30 | for code in language_codes: 31 | if not len(code) == 2: 32 | raise ValueError("Language codes must be two characters long") 33 | 34 | self.languages = language_codes 35 | 36 | def _to_model(self): 37 | return LanguageUserFilterModel(_t="LanguageFilter", languages=self.languages) 38 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/src/rapidata/rapidata_client/filter/models/__init__.py -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/models/age_group.py: -------------------------------------------------------------------------------- 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 | 27 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/models/gender.py: -------------------------------------------------------------------------------- 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) 20 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/new_user_filter.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 2 | from rapidata.api_client.models.new_user_filter_model import NewUserFilterModel 3 | 4 | class NewUserFilter(RapidataFilter): 5 | """NewUserFilter Class 6 | 7 | Can be used to filter new users. 8 | """ 9 | 10 | def _to_model(self): 11 | return NewUserFilterModel( 12 | _t="NewUserFilter" 13 | ) 14 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/not_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.not_user_filter_model import NotUserFilterModel 4 | from rapidata.api_client.models.create_order_model_user_filters_inner import CreateOrderModelUserFiltersInner 5 | 6 | 7 | class NotFilter(RapidataFilter): 8 | """A filter that negates another filter's condition. 9 | This class implements a logical NOT operation on a given filter, inverting its results. 10 | 11 | Args: 12 | filter (RapidataFilter): The filter whose condition should be negated. 13 | 14 | Example: 15 | ```python 16 | from rapidata import NotFilter, LanguageFilter 17 | 18 | NotFilter(LanguageFilter(["en"])) 19 | ``` 20 | 21 | This will limit the order to be shown to only people who have their phone set to a language other than English. 22 | """ 23 | def __init__(self, filter: RapidataFilter): 24 | if not isinstance(filter, RapidataFilter): 25 | raise ValueError("Filter must be a RapidataFilter object") 26 | 27 | self.filter = filter 28 | 29 | def _to_model(self): 30 | return NotUserFilterModel(_t="NotFilter", filter=CreateOrderModelUserFiltersInner(self.filter._to_model())) 31 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/or_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.or_user_filter_model import OrUserFilterModel 4 | from rapidata.api_client.models.create_order_model_user_filters_inner import CreateOrderModelUserFiltersInner 5 | 6 | 7 | class OrFilter(RapidataFilter): 8 | """A filter that combines multiple filters with a logical OR operation. 9 | This class implements a logical OR operation on a list of filters, where the condition is met if any of the filters' conditions are met. 10 | 11 | Args: 12 | filters (list[RapidataFilter]): A list of filters to be combined with OR. 13 | 14 | Example: 15 | ```python 16 | from rapidata import OrFilter, LanguageFilter, CountryFilter 17 | 18 | OrFilter([LanguageFilter(["en"]), CountryFilter(["US"])]) 19 | ``` 20 | 21 | This will match users who either have their phone set to English OR are located in the United States. 22 | """ 23 | def __init__(self, filters: list[RapidataFilter]): 24 | if not all(isinstance(filter, RapidataFilter) for filter in filters): 25 | raise ValueError("Filters must be a RapidataFilter object") 26 | 27 | self.filters = filters 28 | 29 | def _to_model(self): 30 | return OrUserFilterModel(_t="OrFilter", filters=[CreateOrderModelUserFiltersInner(filter._to_model()) for filter in self.filters]) 31 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/rapidata_filters.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.filter import ( 2 | AgeFilter, 3 | CountryFilter, 4 | GenderFilter, 5 | LanguageFilter, 6 | UserScoreFilter, 7 | NotFilter, 8 | OrFilter) 9 | 10 | class RapidataFilters: 11 | """RapidataFilters Classes 12 | 13 | These filters can be added to the order to specifically target a certain group of users. 14 | 15 | Note that adding multiple filters to the same order will result in a logical AND operation between the filters. 16 | 17 | Warning: 18 | This might significantly slow down the number of responses you receive. 19 | 20 | Attributes: 21 | user_score (UserScoreFilter): The UserScoreFilter instance. 22 | age (AgeFilter): The AgeFilter instance. 23 | country (CountryFilter): The CountryFilter instance. 24 | gender (GenderFilter): The GenderFilter instance. 25 | language (LanguageFilter): The LanguageFilter instance. 26 | not_filter (NotFilter): The NotFilter instance. 27 | or_filter (OrFilter): The OrFilter instance. 28 | 29 | Example: 30 | ```python 31 | from rapidata import CountryFilter, LanguageFilter 32 | filters=[CountryFilter(["US", "DE"]), LanguageFilter(["en"])] 33 | ``` 34 | 35 | This ensures the order is only shown to users in the US and Germany whose phones are set to English. 36 | 37 | Info: 38 | The or and not filter support the | and ~ operators respectively. 39 | The and is given by the elements in the list. 40 | 41 | ```python 42 | from rapidata import AgeFilter, LanguageFilter, CountryFilter 43 | filters=[~AgeFilter([AgeGroup.UNDER_18]), CountryFilter(["US"]) | LanguageFilter(["en"])] 44 | ``` 45 | 46 | This would return users who are not under 18 years old and are from the US or whose phones are set to English. 47 | """ 48 | user_score = UserScoreFilter 49 | age = AgeFilter 50 | country = CountryFilter 51 | gender = GenderFilter 52 | language = LanguageFilter 53 | not_filter = NotFilter 54 | or_filter = OrFilter 55 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/response_count_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.response_count_user_filter_model import ( 4 | ResponseCountUserFilterModel, 5 | ) 6 | 7 | class ResponseCountFilter(RapidataFilter): 8 | """ResponseCountFilter Class 9 | Can be used to filter users based on the number of responses they have given on validation tasks with the specified dimension. 10 | 11 | response_count (int): The number of user responses to filter by. 12 | dimension (str): The dimension to apply the filter on (e.g. "default", "electrical", etc.). 13 | operator (str): The comparison operator to use. Must be one of: 14 | - "Equal" 15 | - "NotEqual" 16 | - "LessThan" 17 | - "LessThanOrEqual" 18 | - "GreaterThan" 19 | - "GreaterThanOrEqual" 20 | 21 | Raises: 22 | ValueError: If `response_count` is not an integer. 23 | ValueError: If `dimension` is not a string. 24 | ValueError: If `operator` is not a string or not one of the allowed values. 25 | 26 | Example: 27 | ```python 28 | from rapidata import ResponseCountFilter 29 | 30 | filter = ResponseCountFilter(response_count=10, dimension="electrical", operator="GreaterThan") 31 | ``` 32 | This will filter users who have a response count greater than 10 for the "electrical" dimension. 33 | """ 34 | 35 | def __init__(self, response_count: int, dimension: str, operator: str): 36 | if operator not in ["Equal", "NotEqual", "LessThan", "LessThanOrEqual", "GreaterThan", "GreaterThanOrEqual"]: 37 | raise ValueError("Operator must be one of Equal, NotEqual, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual") 38 | 39 | self.response_count = response_count 40 | self.dimension = dimension 41 | self.operator = operator 42 | 43 | def _to_model(self): 44 | return ResponseCountUserFilterModel( 45 | _t="ResponseCountFilter", responseCount=self.response_count, dimension=self.dimension, operator=self.operator 46 | ) 47 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/filter/user_score_filter.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.filter._base_filter import RapidataFilter 3 | from rapidata.api_client.models.user_score_user_filter_model import ( 4 | UserScoreUserFilterModel, 5 | ) 6 | 7 | 8 | class UserScoreFilter(RapidataFilter): 9 | """UserScoreFilter Class 10 | 11 | Can be used to filter who to target based on their user score. 12 | 13 | Args: 14 | lower_bound (float): The lower bound of the user score. 15 | upper_bound (float): The upper bound of the user score. 16 | dimension (str): The dimension of the userScore to be considerd for the filter. 17 | 18 | Example: 19 | ```python 20 | UserScoreFilter(0.5, 0.9) 21 | ``` 22 | This will only show the order to users that have a UserScore of >=0.5 and <=0.9 23 | """ 24 | def __init__(self, lower_bound: float = 0.0, upper_bound: float = 1.0, dimension: str | None = None): 25 | if lower_bound < 0 or lower_bound > 1: 26 | raise ValueError("The lower bound must be between 0 and 1.") 27 | if upper_bound < 0 or upper_bound > 1: 28 | raise ValueError("The upper bound must be between 0 and 1.") 29 | if lower_bound >= upper_bound: 30 | raise ValueError("The lower bound must be less than the upper bound.") 31 | 32 | self.upper_bound = upper_bound 33 | self.lower_bound = lower_bound 34 | self.dimension = dimension 35 | 36 | def _to_model(self): 37 | return UserScoreUserFilterModel( 38 | _t="UserScoreFilter", 39 | upperbound=self.upper_bound, 40 | lowerbound=self.lower_bound, 41 | dimension=self.dimension, 42 | ) 43 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/logging/__init__.py: -------------------------------------------------------------------------------- 1 | from .logger import configure_logger, logger 2 | from .output_manager import managed_print, RapidataOutputManager 3 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/logging/logger.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import os 3 | from typing import Optional 4 | 5 | # Create module-level logger 6 | logger = logging.getLogger("rapidata") 7 | 8 | def configure_logger( 9 | level: str = "WARNING", 10 | log_file: Optional[str] = None, 11 | format_string: str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" 12 | ): 13 | """Configure the Rapidata logger with custom settings.""" 14 | # Convert string level to logging level 15 | level_map = { 16 | "DEBUG": logging.DEBUG, 17 | "INFO": logging.INFO, 18 | "WARNING": logging.WARNING, 19 | "ERROR": logging.ERROR, 20 | "CRITICAL": logging.CRITICAL 21 | } 22 | 23 | numeric_level = level_map.get(level.upper(), logging.INFO) 24 | logger.setLevel(numeric_level) 25 | 26 | # Remove existing handlers if any 27 | for handler in logger.handlers[:]: 28 | logger.removeHandler(handler) 29 | 30 | # Create formatter 31 | formatter = logging.Formatter(format_string) 32 | 33 | # Console handler 34 | console_handler = logging.StreamHandler() 35 | console_handler.setFormatter(formatter) 36 | logger.addHandler(console_handler) 37 | 38 | # File handler (optional) 39 | if log_file: 40 | log_dir = os.path.dirname(log_file) 41 | if log_dir: 42 | os.makedirs(log_dir, exist_ok=True) 43 | file_handler = logging.FileHandler(log_file) 44 | file_handler.setFormatter(formatter) 45 | logger.addHandler(file_handler) 46 | 47 | configure_logger() 48 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/logging/output_manager.py: -------------------------------------------------------------------------------- 1 | class RapidataOutputManager: 2 | silent_mode = False 3 | 4 | @classmethod 5 | def enable_silent_mode(cls): 6 | cls.silent_mode = True 7 | 8 | @classmethod 9 | def disable_silent_mode(cls): 10 | cls.silent_mode = False 11 | 12 | def managed_print(*args, **kwargs): 13 | if not RapidataOutputManager.silent_mode: 14 | print(*args, **kwargs) 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/__init__.py: -------------------------------------------------------------------------------- 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 6 | from ._media_asset_metadata import MediaAssetMetadata 7 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_base_metadata.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | 5 | class Metadata: 6 | """The base class for all Rapidata Metadata.""" 7 | 8 | @abstractmethod 9 | def to_model(self) -> Any: 10 | pass 11 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_media_asset_metadata.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.prompt_asset_metadata_input import PromptAssetMetadataInput 2 | from rapidata.api_client.models.url_asset_input import UrlAssetInput 3 | from rapidata.rapidata_client.metadata._base_metadata import Metadata 4 | 5 | 6 | class MediaAssetMetadata(Metadata): 7 | 8 | def __init__(self, url: str): 9 | super().__init__() 10 | self._url = url 11 | 12 | def to_model(self): 13 | return PromptAssetMetadataInput( 14 | _t="PromptAssetMetadataInput", asset=UrlAssetInput(_t="UrlAssetInput", url=self._url) 15 | ) 16 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_private_text_metadata.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.private_text_metadata_input import ( 2 | PrivateTextMetadataInput, 3 | ) 4 | from rapidata.rapidata_client.metadata._base_metadata import Metadata 5 | 6 | 7 | class PrivateTextMetadata(Metadata): 8 | 9 | def __init__(self, text: str, identifier: str = "private_text"): 10 | super().__init__() 11 | self._identifier = identifier 12 | self._text = text 13 | 14 | def to_model(self): 15 | return PrivateTextMetadataInput( 16 | _t="PrivateTextMetadataInput", identifier=self._identifier, text=self._text 17 | ) 18 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_prompt_metadata.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.metadata._base_metadata import Metadata 2 | from rapidata.api_client.models.prompt_metadata_input import PromptMetadataInput 3 | 4 | 5 | class PromptMetadata(Metadata): 6 | """The PromptMetadata class is used to display a prompt to the user.""" 7 | 8 | def __init__(self, prompt: str): 9 | super().__init__() 10 | 11 | if not isinstance(prompt, str): 12 | raise ValueError("Prompt must be a string") 13 | 14 | self._prompt = prompt 15 | 16 | 17 | def to_model(self): 18 | return PromptMetadataInput(_t="PromptMetadataInput", prompt=self._prompt) 19 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_public_text_metadata.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.public_text_metadata_input import ( 2 | PublicTextMetadataInput, 3 | ) 4 | from rapidata.rapidata_client.metadata._base_metadata import Metadata 5 | 6 | 7 | class PublicTextMetadata(Metadata): 8 | 9 | def __init__(self, text: str, identifier: str = "public_text"): 10 | super().__init__() 11 | self._identifier = identifier 12 | self._text = text 13 | 14 | def to_model(self): 15 | return PublicTextMetadataInput( 16 | _t="PublicTextMetadataInput", identifier=self._identifier, text=self._text 17 | ) 18 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/metadata/_select_words_metadata.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.transcription_metadata_input import ( 2 | TranscriptionMetadataInput, 3 | ) 4 | from rapidata.rapidata_client.metadata._base_metadata import Metadata 5 | 6 | 7 | class SelectWordsMetadata(Metadata): 8 | """SelectWordsMetadata Class is used to define the Sentence that will be display to the user.""" 9 | 10 | def __init__(self, select_words: str): 11 | super().__init__() 12 | self.select_words = select_words 13 | 14 | def to_model(self): 15 | return TranscriptionMetadataInput( 16 | _t="TranscriptionMetadataInput", 17 | transcription=self.select_words, 18 | ) 19 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/order/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/src/rapidata/rapidata_client/order/__init__.py -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/referee/__init__.py: -------------------------------------------------------------------------------- 1 | from ._base_referee import Referee 2 | from ._naive_referee import NaiveReferee #as MaxVoteReferee 3 | from ._early_stopping_referee import EarlyStoppingReferee 4 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/referee/_base_referee.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Any, Mapping 3 | 4 | class Referee(ABC): 5 | """ 6 | The referee defines when a rapid is considered complete. 7 | """ 8 | @abstractmethod 9 | def _to_dict(self) -> Mapping[str, str | int | float]: 10 | """ 11 | Convert the referee to a referee configuration dict. 12 | """ 13 | pass 14 | 15 | @abstractmethod 16 | def _to_model(self) -> Any: 17 | """ 18 | Convert the referee to a referee configuration model. 19 | """ 20 | pass 21 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/referee/_early_stopping_referee.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.referee._base_referee import Referee 3 | from rapidata.api_client.models.early_stopping_referee_model import ( 4 | EarlyStoppingRefereeModel, 5 | ) 6 | 7 | 8 | class EarlyStoppingReferee(Referee): 9 | """A referee that stops the task when confidence in the winning category exceeds a threshold. 10 | 11 | This referee implements an early stopping mechanism for classification & compare tasks. 12 | It terminates the task when the confidence in the leading category surpasses 13 | a specified threshold or when the maximum number of votes is reached. 14 | 15 | The threshold behaves logarithmically, meaning small increments (e.g., from 0.99 16 | to 0.999) can significantly impact the stopping criteria. 17 | 18 | This referee is supported for the classification and compare tasks (in compare, 19 | the two options are treated as the categories). 20 | 21 | Args: 22 | threshold (float, optional): The confidence threshold for early stopping. 23 | Defaults to 0.999. 24 | max_vote_count (int, optional): The maximum number of votes allowed 25 | before stopping. Defaults to 100. 26 | 27 | Attributes: 28 | threshold (float): The confidence threshold for early stopping. 29 | max_vote_count (int): The maximum number of votes allowed before stopping. 30 | """ 31 | 32 | def __init__(self, threshold: float = 0.999, max_vote_count: int = 100): 33 | if threshold <= 0 or threshold >= 1: 34 | raise ValueError("The threshold must be between 0 and 1.") 35 | if max_vote_count < 1: 36 | raise ValueError("The number of responses must be greater than 0.") 37 | 38 | self.threshold = threshold 39 | self.max_vote_count = max_vote_count 40 | 41 | def _to_dict(self): 42 | return { 43 | "_t": "ProbabilisticAttachCategoryRefereeConfig", 44 | "threshold": self.threshold, 45 | "maxVotes": self.max_vote_count, 46 | } 47 | 48 | def _to_model(self) -> Any: 49 | return EarlyStoppingRefereeModel( 50 | _t="EarlyStoppingReferee", 51 | threshold=self.threshold, 52 | maxVotes=self.max_vote_count, 53 | ) 54 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/referee/_naive_referee.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.naive_referee_model import NaiveRefereeModel 2 | from rapidata.rapidata_client.referee._base_referee import Referee 3 | 4 | 5 | class NaiveReferee(Referee): 6 | """A simple referee that completes a task after a fixed number of responses. 7 | 8 | This referee implements a straightforward approach to task completion, 9 | where the task is considered finished after a predetermined number of 10 | responses have been made, regardless of the content or quality of those responses. 11 | 12 | Args: 13 | responses (int, optional): The number of responses required 14 | to complete the task. Defaults to 10. This is per media item. 15 | 16 | Attributes: 17 | responses (int): The number of responses required to complete the task. 18 | """ 19 | 20 | def __init__(self, responses: int = 10): 21 | if responses < 1: 22 | raise ValueError("The number of responses must be greater than 0.") 23 | super().__init__() 24 | self.responses = responses 25 | 26 | def _to_dict(self): 27 | return { 28 | "_t": "NaiveRefereeConfig", 29 | "guessesRequired": self.responses, 30 | } 31 | 32 | def _to_model(self): 33 | return NaiveRefereeModel(_t="NaiveReferee", totalVotes=self.responses) 34 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/__init__.py: -------------------------------------------------------------------------------- 1 | from ._base_selection import RapidataSelection 2 | from .demographic_selection import DemographicSelection 3 | from .labeling_selection import LabelingSelection 4 | from .validation_selection import ValidationSelection 5 | from .conditional_validation_selection import ConditionalValidationSelection 6 | from .capped_selection import CappedSelection 7 | from .shuffling_selection import ShufflingSelection 8 | from .ab_test_selection import AbTestSelection 9 | from .static_selection import StaticSelection 10 | from .retrieval_modes import RetrievalMode 11 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/_base_selection.py: -------------------------------------------------------------------------------- 1 | from abc import abstractmethod 2 | from typing import Any 3 | 4 | 5 | class RapidataSelection: 6 | 7 | @abstractmethod 8 | def _to_model(self) -> Any: 9 | pass 10 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/ab_test_selection.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.ab_test_selection import ( 2 | AbTestSelection as AbTestSelectionModel, 3 | ) 4 | from rapidata.api_client.models.ab_test_selection_a_inner import ( 5 | AbTestSelectionAInner, 6 | ) 7 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 8 | from typing import Sequence 9 | 10 | 11 | class AbTestSelection(RapidataSelection): 12 | """AbTestSelection Class 13 | 14 | Splits the userbase into two segments and serves them a different collection of rapids. 15 | 16 | Useful for A/B Test. 17 | 18 | Args: 19 | a_selections (Sequence[RapidataSelection]): List of selections for group A. 20 | b_selections (Sequence[RapidataSelection]): List of selections for group B. 21 | """ 22 | 23 | def __init__(self, a_selections: Sequence[RapidataSelection], b_selections: Sequence[RapidataSelection]): 24 | self.a_selections = a_selections 25 | self.b_selections = b_selections 26 | 27 | def _to_model(self): 28 | return AbTestSelectionModel( 29 | _t="AbTestSelection", 30 | a=[ 31 | AbTestSelectionAInner(selection._to_model()) 32 | for selection in self.a_selections 33 | ], 34 | b=[ 35 | AbTestSelectionAInner(selection._to_model()) 36 | for selection in self.b_selections 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/capped_selection.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.capped_selection import ( 2 | CappedSelection as CappedSelectionModel, 3 | ) 4 | from rapidata.api_client.models.ab_test_selection_a_inner import ( 5 | AbTestSelectionAInner, 6 | ) 7 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 8 | from typing import Sequence 9 | 10 | 11 | class CappedSelection(RapidataSelection): 12 | """CappedSelection Class 13 | 14 | Takes in different selections and caps the amount of rapids that can be shown. 15 | 16 | Useful for demographic and conditional validation selections. 17 | 18 | Args: 19 | selections (Sequence[RapidataSelection]): List of selections to cap. 20 | max_rapids (int): The maximum amount of rapids that can be shown for this selection. 21 | """ 22 | 23 | def __init__(self, selections: Sequence[RapidataSelection], max_rapids: int): 24 | self.selections = selections 25 | self.max_rapids = max_rapids 26 | 27 | def _to_model(self): 28 | return CappedSelectionModel( 29 | _t="CappedSelection", 30 | selections=[ 31 | AbTestSelectionAInner(selection._to_model()) 32 | for selection in self.selections 33 | ], 34 | maxRapids=self.max_rapids, 35 | ) 36 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/demographic_selection.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 2 | from rapidata.api_client.models.demographic_selection import DemographicSelection as DemographicSelectionModel 3 | 4 | 5 | class DemographicSelection(RapidataSelection): 6 | """Demographic selection class. 7 | 8 | This is used to ask demographic questions in an order. 9 | 10 | The keys will select the rapids based on the confidence we already saved for each user. 11 | 12 | If the confidence is high, the users will be selected to solve the rapids with lower probability. 13 | 14 | Args: 15 | keys (list[str]): List of keys for the demographic rapids to be shown. As an example: "age" 16 | max_rapids (int): The maximum number of rapids to run.\n 17 | Allows to provide more keys, in case some of the earlier ones are not selected because of high confidence. 18 | 19 | Example: 20 | ```python 21 | DemographicSelection(["age", "gender"], 1) 22 | ``` 23 | This will try to ask the user about their age, if that is not selected due to an already high confidence, it will try asking about their gender. 24 | The gender question may also be skipped if the confidence is high enough. 25 | """ 26 | 27 | 28 | def __init__(self, keys: list[str], max_rapids: int): 29 | self.keys = keys 30 | self.max_rapids = max_rapids 31 | 32 | def _to_model(self): 33 | return DemographicSelectionModel(_t="DemographicSelection", keys=self.keys, maxRapids=self.max_rapids) 34 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/labeling_selection.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 3 | from rapidata.rapidata_client.selection.retrieval_modes import RetrievalMode 4 | from rapidata.api_client.models.labeling_selection import ( 5 | LabelingSelection as LabelingSelectionModel, 6 | ) 7 | 8 | 9 | class LabelingSelection(RapidataSelection): 10 | """Labeling selection class. 11 | 12 | Decides how many actual datapoints you want to show per session. 13 | 14 | Args: 15 | amount (int): The amount of labeling rapids that will be shown per session. 16 | retrieval_mode (RetrievalMode): The retrieval mode to use. Defaults to "Shuffled". 17 | max_iterations (int | None): An annotator can answer the same task only once if the retrieval_mode is "Shuffled" 18 | or "Sequential". max_iterations can increase the amount of responses an annotator can do 19 | to the same task (datapoint). 20 | """ 21 | 22 | def __init__(self, amount: int, retrieval_mode: RetrievalMode = RetrievalMode.Shuffled, max_iterations: int | None = None): 23 | self.amount = amount 24 | self.retrieval_mode = retrieval_mode 25 | self.max_iterations = max_iterations 26 | 27 | def _to_model(self) -> Any: 28 | return LabelingSelectionModel(_t="LabelingSelection", amount=self.amount, retrievalMode=self.retrieval_mode.value, maxIterations=self.max_iterations) 29 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/rapidata_selections.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.selection import ( 2 | DemographicSelection, 3 | LabelingSelection, 4 | ValidationSelection, 5 | ConditionalValidationSelection, 6 | CappedSelection, 7 | ShufflingSelection) 8 | 9 | class RapidataSelections: 10 | """RapidataSelections Classes 11 | 12 | Selections are used to define what type of tasks and in what order they are shown to the user. 13 | All Tasks are called a "Session". A session can contain multiple tasks of different types. 14 | 15 | Attributes: 16 | labeling (LabelingSelection): The LabelingSelection instance. 17 | validation (ValidationSelection): The ValidationSelection instance. 18 | conditional_validation (ConditionalValidationSelection): The ConditionalValidationSelection instance. 19 | demographic (DemographicSelection): The DemographicSelection instance. 20 | capped (CappedSelection): The CappedSelection instance. 21 | shuffling (ShufflingSelection): The ShufflingSelection instance. 22 | 23 | Example: 24 | ```python 25 | from rapidata import LabelingSelection, ValidationSelection 26 | selections=[ValidationSelection("your-validation-set-id", 1), 27 | LabelingSelection(2)] 28 | ``` 29 | 30 | This will require annotators to complete one validation task followed by two labeling tasks. 31 | """ 32 | labeling = LabelingSelection 33 | validation = ValidationSelection 34 | conditional_validation = ConditionalValidationSelection 35 | demographic = DemographicSelection 36 | capped = CappedSelection 37 | shuffling = ShufflingSelection 38 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/retrieval_modes.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | class RetrievalMode(Enum): 4 | """ 5 | Enum for defining retrieval modes for datapoints. 6 | """ 7 | Shuffled = "Shuffled" 8 | """ 9 | Will shuffle the datapoints randomly for each user. The user will then see the datapoints in that order. This will take into account the "max_iterations" parameter. 10 | """ 11 | Sequential = "Sequential" 12 | """ 13 | Will show the datapoints in the order they are in the dataset. This will take into account the "max_iterations" parameter. 14 | """ 15 | Random = "Random" 16 | """ 17 | Will just randomly feed the datapoints to the annotators. This will NOT take into account the "max_iterations" parameter. 18 | """ 19 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/shuffling_selection.py: -------------------------------------------------------------------------------- 1 | 2 | from rapidata.api_client.models.ab_test_selection_a_inner import AbTestSelectionAInner 3 | from rapidata.api_client.models.shuffling_selection import ShufflingSelection as ShufflingSelectionModel 4 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 5 | 6 | from typing import Sequence 7 | 8 | 9 | class ShufflingSelection(RapidataSelection): 10 | """ShufflingSelection Class 11 | 12 | Shuffles the selections provided in the list. 13 | 14 | Args: 15 | selections (Sequence[RapidataSelection]): List of selections to shuffle. 16 | 17 | Example: 18 | ```python 19 | selection = ShufflingSelection( 20 | [ValidSelections("validation_id", 1), LabelingSelection(2)]) 21 | ``` 22 | This means that the users will get 1 validation task and 2 labeling tasks in a shuffled order. 23 | """ 24 | 25 | def __init__(self, selections: Sequence[RapidataSelection]): 26 | self.selections = selections 27 | 28 | def _to_model(self) -> ShufflingSelectionModel: 29 | return ShufflingSelectionModel( 30 | _t="ShufflingSelection", 31 | selections=[ 32 | AbTestSelectionAInner(selection._to_model()) 33 | for selection in self.selections 34 | ] 35 | ) 36 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/static_selection.py: -------------------------------------------------------------------------------- 1 | 2 | from rapidata.api_client.models.static_selection import StaticSelection as StaticSelectionModel 3 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 4 | 5 | class StaticSelection(RapidataSelection): 6 | """StaticSelection Class 7 | 8 | Given a list of RapidIds, theses specific rapids will be shown in order for every session. 9 | 10 | Args: 11 | rapid_ids (list[str]): List of rapid ids to show. 12 | """ 13 | 14 | def __init__(self, rapid_ids: list[str]): 15 | self.rapid_ids = rapid_ids 16 | 17 | def _to_model(self) -> StaticSelectionModel: 18 | return StaticSelectionModel( 19 | _t="StaticSelection", 20 | rapidIds=self.rapid_ids 21 | ) 22 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/selection/validation_selection.py: -------------------------------------------------------------------------------- 1 | 2 | from rapidata.api_client.models.validation_selection import ValidationSelection as ValidationSelectionModel 3 | from rapidata.rapidata_client.selection._base_selection import RapidataSelection 4 | 5 | 6 | class ValidationSelection(RapidataSelection): 7 | """Validation selection class. 8 | 9 | Decides how many validation rapids you want to show per session. 10 | 11 | Args: 12 | validation_set_id (str): The id of the validation set to be used. 13 | amount (int): The amount of validation rapids that will be shown per session of this validation set. 14 | """ 15 | 16 | def __init__(self, validation_set_id: str, amount: int = 1): 17 | self.validation_set_id = validation_set_id 18 | self.amount = amount 19 | 20 | def _to_model(self): 21 | return ValidationSelectionModel(_t="ValidationSelection", validationSetId=self.validation_set_id, amount=self.amount) 22 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/__init__.py: -------------------------------------------------------------------------------- 1 | from .models import TranslationBehaviourOptions 2 | from .alert_on_fast_response import AlertOnFastResponse 3 | from .translation_behaviour import TranslationBehaviour 4 | from .free_text_minimum_characters import FreeTextMinimumCharacters 5 | from .no_shuffle import NoShuffle 6 | from .play_video_until_the_end import PlayVideoUntilTheEnd 7 | from .custom_setting import CustomSetting 8 | from .rapidata_settings import RapidataSettings 9 | from ._rapidata_setting import RapidataSetting 10 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/_rapidata_setting.py: -------------------------------------------------------------------------------- 1 | from pydantic import BaseModel 2 | from typing import Any 3 | from rapidata.api_client.models.feature_flag_model import FeatureFlagModel 4 | 5 | class RapidataSetting(BaseModel): 6 | """Base class for all settings""" 7 | key: str 8 | value: Any 9 | 10 | def _to_feature_flag(self) -> FeatureFlagModel: 11 | return FeatureFlagModel(key=self.key, value=str(self.value)) 12 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/alert_on_fast_response.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 2 | from rapidata.rapidata_client.logging import managed_print 3 | 4 | class AlertOnFastResponse(RapidataSetting): 5 | """ 6 | Gives an alert as a pop up on the UI when the response time is less than the milliseconds. 7 | 8 | Args: 9 | threshold (int): if the user responds in less than this time, an alert will be shown. 10 | """ 11 | 12 | def __init__(self, threshold: int): 13 | if not isinstance(threshold, int): 14 | raise ValueError("The alert must be an integer.") 15 | if threshold < 10: 16 | managed_print(f"Warning: Are you sure you want to set the threshold so low ({threshold} milliseconds)?") 17 | if threshold > 25000: 18 | raise ValueError("The alert must be less than 25000 milliseconds.") 19 | if threshold < 0: 20 | raise ValueError("The alert must be greater than or equal to 0.") 21 | 22 | super().__init__(key="alert_on_fast_response", value=threshold) 23 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/custom_setting.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 2 | 3 | class CustomSetting(RapidataSetting): 4 | """ 5 | Set a custom setting with the given key and value. Use this to enable features that do not have a dedicated method (yet) 6 | 7 | Args: 8 | key (str): The key for the custom setting. 9 | value (str): The value for the custom setting. 10 | """ 11 | 12 | def __init__(self, key: str, value: str): 13 | if not isinstance(key, str): 14 | raise ValueError("The key must be a string.") 15 | 16 | super().__init__(key=key, value=value) 17 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/free_text_minimum_characters.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 2 | from rapidata.rapidata_client.logging import managed_print, logger 3 | 4 | class FreeTextMinimumCharacters(RapidataSetting): 5 | """ 6 | Set the minimum number of characters a user has to type. 7 | 8 | Args: 9 | value (int): The minimum number of characters for free text. 10 | """ 11 | 12 | def __init__(self, value: int): 13 | if value < 1: 14 | raise ValueError("The minimum number of characters must be greater than or equal to 1.") 15 | if value > 40: 16 | managed_print(f"Warning: Are you sure you want to set the minimum number of characters at {value}?") 17 | super().__init__(key="free_text_minimum_characters", value=value) 18 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .translation_behaviour_options import TranslationBehaviourOptions 2 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/models/translation_behaviour_options.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | class TranslationBehaviourOptions(Enum): 4 | """The options for the translation behaviour setting. 5 | 6 | Attributes: 7 | BOTH: Show both the original and the translated text. 8 | May clutter the screen if the options are too long. 9 | ONLY_ORIGINAL: Show only the original text. 10 | ONLY_TRANSLATED: Show only the translated text.""" 11 | 12 | BOTH = "both" 13 | ONLY_ORIGINAL = "only original" 14 | ONLY_TRANSLATED = "only translated" 15 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/no_shuffle.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 2 | 3 | class NoShuffle(RapidataSetting): 4 | """ 5 | Only for classification and compare tasks. If true, the order of the categories / images will not be shuffled and presented in the same order as specified. 6 | 7 | If this is not added to the order, the shuffling will be active. 8 | 9 | Args: 10 | value (bool, optional): Whether to disable shuffling. Defaults to True for function call. 11 | """ 12 | def __init__(self, value: bool = True): 13 | if not isinstance(value, bool): 14 | raise ValueError("The value must be a boolean.") 15 | 16 | super().__init__(key="no_shuffle", value=value) 17 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/play_video_until_the_end.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 2 | 3 | class PlayVideoUntilTheEnd(RapidataSetting): 4 | """ 5 | Allows users to only answer once the video has finished playing. 6 | The additional time gets added on top of the video duration. Can be negative to allow answers before the video ends. 7 | 8 | Args: 9 | additional_time (int, optional): Additional time in milliseconds. Defaults to 0. 10 | """ 11 | 12 | def __init__(self, additional_time: int = 0): 13 | if additional_time < -25000 or additional_time > 25000: 14 | raise ValueError("The additional time must be between -25000 and 25000.") 15 | 16 | super().__init__(key="alert_on_fast_response_add_media_duration", value=additional_time) 17 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/rapidata_settings.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings import ( 2 | AlertOnFastResponse, 3 | TranslationBehaviour, 4 | FreeTextMinimumCharacters, 5 | NoShuffle, 6 | PlayVideoUntilTheEnd, 7 | CustomSetting, 8 | ) 9 | 10 | class RapidataSettings: 11 | """ 12 | Container class for all setting factory functions 13 | 14 | Settings can be added to an order to determine the behaviour of the task. 15 | 16 | Attributes: 17 | alert_on_fast_response (AlertOnFastResponse): The AlertOnFastResponse instance. 18 | translation_behaviour (TranslationBehaviour): The TranslationBehaviour instance. 19 | free_text_minimum_characters (FreeTextMinimumCharacters): The FreeTextMinimumCharacters instance. 20 | no_shuffle (NoShuffle): The NoShuffle instance. 21 | play_video_until_the_end (PlayVideoUntilTheEnd): The PlayVideoUntilTheEnd instance. 22 | custom_setting (CustomSetting): The CustomSetting instance. 23 | 24 | Example: 25 | ```python 26 | from rapidata import FreeTextMinimumCharacters 27 | settings=[FreeTextMinimumCharacters(10)] 28 | ``` 29 | 30 | This can be used in a free text order to set the minimum number of characters required to submit the task. 31 | """ 32 | 33 | alert_on_fast_response = AlertOnFastResponse 34 | translation_behaviour = TranslationBehaviour 35 | free_text_minimum_characters = FreeTextMinimumCharacters 36 | no_shuffle = NoShuffle 37 | play_video_until_the_end = PlayVideoUntilTheEnd 38 | custom_setting = CustomSetting 39 | 40 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/settings/translation_behaviour.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.settings.models.translation_behaviour_options import TranslationBehaviourOptions 2 | from rapidata.rapidata_client.settings._rapidata_setting import RapidataSetting 3 | 4 | class TranslationBehaviour(RapidataSetting): 5 | """ 6 | Defines what's the behaviour of the translation in the UI. 7 | Will not translate text datapoints or sentences. 8 | 9 | Args: 10 | value (TranslationBehaviourOptions): The translation behaviour. 11 | """ 12 | 13 | def __init__(self, value: TranslationBehaviourOptions): 14 | if not isinstance(value, TranslationBehaviourOptions): 15 | raise ValueError("The value must be a TranslationBehaviourOptions.") 16 | 17 | super().__init__(key="translation_behaviour", value=value) 18 | 19 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/validation/__init__.py: -------------------------------------------------------------------------------- 1 | from .rapids import Box 2 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/validation/rapidata_validation_set.py: -------------------------------------------------------------------------------- 1 | from rapidata.rapidata_client.validation.rapids.rapids import Rapid 2 | from rapidata.service.openapi_service import OpenAPIService 3 | from rapidata.rapidata_client.logging import logger 4 | from rapidata.api_client.models.update_dimensions_model import UpdateDimensionsModel 5 | from rapidata.rapidata_client.assets._sessions import SessionManager 6 | 7 | class RapidataValidationSet: 8 | """A class for interacting with a Rapidata validation set. 9 | 10 | Represents a set of all the validation tasks that can be added to an order. 11 | 12 | When added to an order, the tasks will be selected randomly from the set. 13 | 14 | Attributes: 15 | id (str): The ID of the validation set. 16 | name (str): The name of the validation set. 17 | """ 18 | 19 | def __init__(self, validation_set_id, name: str, openapi_service: OpenAPIService): 20 | self.id = validation_set_id 21 | self.name = name 22 | self.__openapi_service = openapi_service 23 | 24 | def add_rapid(self, rapid: Rapid): 25 | """Add a Rapid to the validation set. 26 | 27 | Args: 28 | rapid (Rapid): The Rapid to add to the validation set. 29 | """ 30 | rapid._add_to_validation_set(self.id, self.__openapi_service) 31 | return self 32 | 33 | def update_dimensions(self, dimensions: list[str]): 34 | """Update the dimensions of the validation set. 35 | 36 | Args: 37 | dimensions (list[str]): The new dimensions of the validation set. 38 | """ 39 | logger.debug(f"Updating dimensions for validation set {self.id} to {dimensions}") 40 | self.__openapi_service.validation_api.validation_validation_set_id_dimensions_patch(self.id, UpdateDimensionsModel(dimensions=dimensions)) 41 | return self 42 | 43 | def __str__(self): 44 | return f"name: '{self.name}' id: {self.id}" 45 | 46 | def __repr__(self): 47 | return f"name: '{self.name}' id: {self.id}" 48 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/validation/rapids/__init__.py: -------------------------------------------------------------------------------- 1 | from .box import Box 2 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/validation/rapids/box.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.box_shape import BoxShape 2 | 3 | class Box: 4 | """ 5 | Used in the Locate and Draw Validation sets. All coordinates are in pixels. 6 | 7 | Args: 8 | x_min (float): The minimum x value of the box. 9 | y_min (float): The minimum y value of the box. 10 | x_max (float): The maximum x value of the box. 11 | y_max (float): The maximum y value of the box. 12 | """ 13 | def __init__(self, x_min: float, y_min: float, x_max: float, y_max: float): 14 | self.x_min = x_min 15 | self.y_min = y_min 16 | self.x_max = x_max 17 | self.y_max = y_max 18 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/__init__.py: -------------------------------------------------------------------------------- 1 | from ._locate_workflow import LocateWorkflow 2 | from ._draw_workflow import DrawWorkflow 3 | from ._base_workflow import Workflow 4 | from ._classify_workflow import ClassifyWorkflow 5 | from ._compare_workflow import CompareWorkflow 6 | from ._free_text_workflow import FreeTextWorkflow 7 | from ._select_words_workflow import SelectWordsWorkflow 8 | from ._evaluation_workflow import EvaluationWorkflow 9 | from ._timestamp_workflow import TimestampWorkflow 10 | from ._ranking_workflow import RankingWorkflow 11 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_base_workflow.py: -------------------------------------------------------------------------------- 1 | from abc import ABC, abstractmethod 2 | from typing import Any 3 | 4 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 5 | from rapidata.api_client.models.evaluation_workflow_model import EvaluationWorkflowModel 6 | from rapidata.api_client.models.compare_workflow_model import CompareWorkflowModel 7 | from rapidata.rapidata_client.referee._base_referee import Referee 8 | 9 | 10 | class Workflow(ABC): 11 | 12 | def __init__(self, type: str): 13 | self._type = type 14 | self._target_country_codes: list[str] = [] 15 | 16 | def _to_dict(self) -> dict[str, Any]: 17 | return { 18 | "_t": self._type, 19 | } 20 | 21 | @abstractmethod 22 | def _to_model( 23 | self, 24 | ) -> SimpleWorkflowModel | CompareWorkflowModel | EvaluationWorkflowModel: 25 | pass 26 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_classify_workflow.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.api_client.models.attach_category_rapid_blueprint import AttachCategoryRapidBlueprint 3 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 4 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 5 | from rapidata.rapidata_client.workflow import Workflow 6 | 7 | 8 | class ClassifyWorkflow(Workflow): 9 | """ 10 | A workflow for classification tasks. 11 | 12 | This class represents a classification workflow where a question is presented 13 | along with a list of possible options for classification. 14 | 15 | Args: 16 | question (str): The classification question to be presented. 17 | options (list[str]): A list of possible classification options. 18 | 19 | Attributes: 20 | _question (str): The classification question. 21 | _options (list[str]): The list of classification options. 22 | """ 23 | 24 | def __init__(self, instruction: str, answer_options: list[str]): 25 | super().__init__(type="SimpleWorkflowConfig") 26 | self._question = instruction 27 | self._options = answer_options 28 | 29 | def _to_dict(self) -> dict[str, Any]: 30 | return { 31 | **super()._to_dict(), 32 | "blueprint": { 33 | "_t": "ClassifyBlueprint", 34 | "title": self._question, 35 | "possibleCategories": self._options, 36 | } 37 | } 38 | 39 | def _to_model(self) -> SimpleWorkflowModel: 40 | blueprint = AttachCategoryRapidBlueprint( 41 | _t="ClassifyBlueprint", 42 | title=self._question, 43 | possibleCategories=self._options, 44 | ) 45 | 46 | return SimpleWorkflowModel( 47 | _t="SimpleWorkflow", 48 | blueprint=SimpleWorkflowModelBlueprint(blueprint), 49 | ) 50 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_compare_workflow.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 3 | from rapidata.rapidata_client.workflow import Workflow 4 | from rapidata.api_client.models.compare_rapid_blueprint import CompareRapidBlueprint 5 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 6 | 7 | 8 | class CompareWorkflow(Workflow): 9 | """ 10 | A workflow for comparison tasks. 11 | 12 | This class represents a comparison workflow where items are compared based on 13 | specified instruction. 14 | 15 | Attributes: 16 | _instruction (str): The instruction used for comparison. 17 | 18 | Args: 19 | instruction (str): The instruction to be used for comparison. 20 | """ 21 | 22 | def __init__(self, instruction: str): 23 | super().__init__(type="CompareWorkflowConfig") 24 | self._instruction = instruction 25 | 26 | def _to_dict(self) -> dict[str, Any]: 27 | return { 28 | **super()._to_dict(), 29 | "criteria": self._instruction, 30 | } 31 | 32 | def _to_model(self) -> SimpleWorkflowModel: 33 | blueprint = CompareRapidBlueprint( 34 | _t="CompareBlueprint", 35 | criteria=self._instruction, 36 | ) 37 | 38 | return SimpleWorkflowModel( 39 | _t="SimpleWorkflow", 40 | blueprint=SimpleWorkflowModelBlueprint(blueprint), 41 | ) 42 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_draw_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 2 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 3 | from rapidata.api_client.models.line_rapid_blueprint import LineRapidBlueprint 4 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 5 | 6 | 7 | class DrawWorkflow(Workflow): 8 | 9 | def __init__(self, target: str): 10 | super().__init__(type="SimpleWorkflowConfig") 11 | self._target = target 12 | 13 | def _to_model(self) -> SimpleWorkflowModel: 14 | blueprint = LineRapidBlueprint( 15 | _t="LineBlueprint", 16 | target=self._target 17 | ) 18 | 19 | return SimpleWorkflowModel( 20 | _t="SimpleWorkflow", 21 | blueprint=SimpleWorkflowModelBlueprint(blueprint) 22 | ) 23 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_evaluation_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.evaluation_workflow_model import EvaluationWorkflowModel 2 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 3 | 4 | 5 | class EvaluationWorkflow(Workflow): 6 | """ 7 | A workflow to run evaluation orders. 8 | 9 | This is used internally only and should not be necessary to be used by clients. 10 | 11 | Args: 12 | validation_set_id (str): a source for the tasks that will be sent to the user 13 | should_accept_incorrect (bool): indicates if the user should get feedback on their answers if they answer wrong. If set to true the user will not notice that he was tested. 14 | """ 15 | 16 | def __init__(self, validation_set_id: str, should_accept_incorrect: bool): 17 | super().__init__("EvaluationWorkflow") 18 | self.validation_set_id = validation_set_id 19 | self.should_accept_incorrect = should_accept_incorrect 20 | 21 | def _to_model(self): 22 | return EvaluationWorkflowModel( 23 | _t="EvaluationWorkflow", 24 | validationSetId=self.validation_set_id, 25 | shouldAcceptIncorrect=self.should_accept_incorrect, 26 | ) 27 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_free_text_workflow.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 3 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 4 | from rapidata.rapidata_client.workflow import Workflow 5 | from rapidata.api_client.models.free_text_rapid_blueprint import FreeTextRapidBlueprint 6 | 7 | 8 | class FreeTextWorkflow(Workflow): 9 | """ 10 | A workflow for free text input tasks. 11 | 12 | This class represents a workflow where users can provide free-form text responses 13 | to a given instruction. 14 | 15 | Attributes: 16 | _instruction (str): The instruction to be answered with free text. 17 | 18 | Args: 19 | instruction (str): The instruction to be presented for free text input. 20 | """ 21 | 22 | def __init__(self, instruction: str): 23 | super().__init__(type="SimpleWorkflowConfig") 24 | self._instruction = instruction 25 | 26 | def _to_dict(self) -> dict[str, Any]: 27 | return { 28 | **super()._to_dict(), 29 | "blueprint": { 30 | "_t": "FreeTextBlueprint", 31 | "question": self._instruction, 32 | }, 33 | } 34 | 35 | def _to_model(self) -> SimpleWorkflowModel: 36 | blueprint = FreeTextRapidBlueprint( 37 | _t="FreeTextBlueprint", 38 | question=self._instruction, 39 | ) 40 | 41 | return SimpleWorkflowModel( 42 | _t="SimpleWorkflow", 43 | blueprint=SimpleWorkflowModelBlueprint(blueprint), 44 | ) 45 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_locate_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 2 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 3 | from rapidata.api_client.models.locate_rapid_blueprint import LocateRapidBlueprint 4 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 5 | 6 | 7 | class LocateWorkflow(Workflow): 8 | 9 | def __init__(self, target: str): 10 | super().__init__(type="SimpleWorkflowConfig") 11 | self._target = target 12 | 13 | def _to_model(self) -> SimpleWorkflowModel: 14 | blueprint = LocateRapidBlueprint( 15 | _t="LocateBlueprint", 16 | target=self._target 17 | ) 18 | 19 | return SimpleWorkflowModel( 20 | _t="SimpleWorkflow", 21 | blueprint=SimpleWorkflowModelBlueprint(blueprint) 22 | ) 23 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_ranking_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client import CompareWorkflowModelPairMakerConfig, OnlinePairMakerConfigModel, EloConfigModel 2 | from rapidata.api_client.models.compare_workflow_model import CompareWorkflowModel 3 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 4 | from rapidata.rapidata_client.metadata import PromptMetadata 5 | from rapidata.api_client.models.dataset_dataset_id_datapoints_post_request_metadata_inner import DatasetDatasetIdDatapointsPostRequestMetadataInner 6 | 7 | 8 | class RankingWorkflow(Workflow): 9 | def __init__(self, 10 | criteria: str, 11 | total_comparison_budget: int, 12 | random_comparisons_ratio, 13 | elo_start: int = 1200, 14 | elo_k_factor: int = 40, 15 | elo_scaling_factor: int = 400, 16 | context: str | None = None, 17 | ): 18 | super().__init__(type="CompareWorkflowConfig") 19 | 20 | self.context = [DatasetDatasetIdDatapointsPostRequestMetadataInner( 21 | PromptMetadata(context).to_model()) 22 | ] if context else None 23 | 24 | self.criteria = criteria 25 | self.pair_maker_config = CompareWorkflowModelPairMakerConfig( 26 | OnlinePairMakerConfigModel( 27 | _t='OnlinePairMaker', 28 | totalComparisonBudget=total_comparison_budget, 29 | randomMatchesRatio=random_comparisons_ratio, 30 | ) 31 | ) 32 | 33 | self.elo_config = EloConfigModel( 34 | startingElo=elo_start, 35 | kFactor=elo_k_factor, 36 | scalingFactor=elo_scaling_factor, 37 | ) 38 | 39 | def _to_model(self) -> CompareWorkflowModel: 40 | 41 | return CompareWorkflowModel( 42 | _t="CompareWorkflow", 43 | criteria=self.criteria, 44 | eloConfig=self.elo_config, 45 | pairMakerConfig=self.pair_maker_config, 46 | metadata=self.context, 47 | ) 48 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_select_words_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 2 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 3 | from rapidata.api_client.models.transcription_rapid_blueprint import TranscriptionRapidBlueprint 4 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 5 | 6 | 7 | class SelectWordsWorkflow(Workflow): 8 | """ 9 | A workflow for select words tasks. 10 | 11 | This class represents a select words workflow 12 | where datapoints have a sentence attached to them where words can be selected. 13 | 14 | Attributes: 15 | _instruction (str): The instruction for the select words task. 16 | 17 | Args: 18 | instruction (str): The instruction to be provided for the select words task. 19 | """ 20 | 21 | def __init__(self, instruction: str): 22 | super().__init__(type="SimpleWorkflowConfig") 23 | self._instruction = instruction 24 | 25 | def _to_model(self) -> SimpleWorkflowModel: 26 | blueprint = TranscriptionRapidBlueprint( 27 | _t="TranscriptionBlueprint", 28 | title=self._instruction 29 | ) 30 | 31 | return SimpleWorkflowModel( 32 | _t="SimpleWorkflow", 33 | blueprint=SimpleWorkflowModelBlueprint(blueprint) 34 | ) 35 | -------------------------------------------------------------------------------- /src/rapidata/rapidata_client/workflow/_timestamp_workflow.py: -------------------------------------------------------------------------------- 1 | from rapidata.api_client.models.simple_workflow_model import SimpleWorkflowModel 2 | from rapidata.api_client.models.simple_workflow_model_blueprint import SimpleWorkflowModelBlueprint 3 | from rapidata.api_client.models.scrub_rapid_blueprint import ScrubRapidBlueprint 4 | from rapidata.rapidata_client.workflow._base_workflow import Workflow 5 | 6 | 7 | class TimestampWorkflow(Workflow): 8 | """ 9 | A workflow for timestamp tasks. 10 | 11 | This class represents a timestamp workflow 12 | where audio or video content receives timestamps based on the instruction. 13 | 14 | Attributes: 15 | _instruction (str): The instruction for the timestamp task. 16 | 17 | Args: 18 | instruction (str): The instruction to be provided for the timestamp task. 19 | """ 20 | 21 | def __init__(self, instruction: str): 22 | super().__init__(type="SimpleWorkflowConfig") 23 | self._instruction = instruction 24 | 25 | def _to_model(self) -> SimpleWorkflowModel: 26 | blueprint = ScrubRapidBlueprint( 27 | _t="ScrubBlueprint", 28 | target=self._instruction 29 | ) 30 | 31 | return SimpleWorkflowModel( 32 | _t="SimpleWorkflow", 33 | blueprint=SimpleWorkflowModelBlueprint(blueprint) 34 | ) 35 | -------------------------------------------------------------------------------- /src/rapidata/service/__init__.py: -------------------------------------------------------------------------------- 1 | from .local_file_service import LocalFileService as LocalFileService -------------------------------------------------------------------------------- /src/rapidata/service/local_file_service.py: -------------------------------------------------------------------------------- 1 | import os 2 | from PIL import Image 3 | 4 | class LocalFileService: 5 | 6 | def load_image(self, image_path: str) -> Image.Image: 7 | self.check_file_exists(image_path) 8 | return Image.open(image_path) 9 | 10 | def load_images(self, image_paths: list[str]) -> list[Image.Image]: 11 | return [self.load_image(image_path) for image_path in image_paths] 12 | 13 | def load_video(self, video_path: str): 14 | self.check_file_exists(video_path) 15 | return open(video_path, 'rb') 16 | 17 | def load_videos(self, video_paths: list[str]): 18 | return [self.load_video(video_path) for video_path in video_paths] 19 | 20 | def _file_exists(self, file_path: str) -> bool: 21 | return os.path.exists(file_path) 22 | 23 | def check_file_exists(self, file_path: str): 24 | if not self._file_exists(file_path): 25 | raise FileNotFoundError(f"File {file_path} not found.") -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/tests/__init__.py -------------------------------------------------------------------------------- /tests/integration/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/tests/integration/__init__.py -------------------------------------------------------------------------------- /tests/integration/test_internal_orders.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from rapidata import MediaAsset, PromptMetadata, LabelingSelection, RapidataClient 3 | from rapidata.rapidata_client.workflow import EvaluationWorkflow 4 | 5 | 6 | class TestExampleOrders(unittest.TestCase): 7 | 8 | def setUp(self): 9 | self.rapi = RapidataClient() 10 | 11 | def test_evaluation_order(self): 12 | # Validation set 13 | validation_set = ( 14 | self.rapi.new_validation_set("Example Validation Set") 15 | .add_classify_rapid( 16 | asset=MediaAsset(path="examples/data/wallaby.jpg"), 17 | question="What kind of animal is this?", 18 | categories=["Fish", "Marsupial", "Bird", "Reptile"], 19 | truths=["Marsupial"], 20 | metadata=[PromptMetadata(prompt="Hint: It has a pouch")], 21 | ) 22 | .create() 23 | ) 24 | 25 | order = ( 26 | self.rapi.new_order("Test Evaluation Order") 27 | .workflow(EvaluationWorkflow(validation_set_id=validation_set.id)) 28 | .selections([LabelingSelection(amount=1)]) 29 | .create() 30 | ) 31 | 32 | print("Done") 33 | -------------------------------------------------------------------------------- /tests/order/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RapidataAI/rapidata-python-sdk/04912ca97ffbc2951cd0a37fec7ed60d5ee794f5/tests/order/__init__.py -------------------------------------------------------------------------------- /tests/order/test_order_builder.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from unittest.mock import MagicMock, Mock 3 | 4 | from src.rapidata.rapidata_client.order.rapidata_order_builder import RapidataOrderBuilder 5 | from src.rapidata.rapidata_client.workflow import ClassifyWorkflow 6 | 7 | 8 | class TestOrderBuilder(unittest.TestCase): 9 | def setUp(self): 10 | # Create a mock for the result of order_create_post 11 | mock_result = MagicMock() 12 | mock_result.order_id = "test_order_123" 13 | mock_result.dataset_id = "test_dataset_456" 14 | 15 | # Create a mock for the order_api 16 | mock_order_api = Mock() 17 | mock_order_api.order_create_post.return_value = mock_result 18 | 19 | # Create a mock for the openapi_service 20 | self.mock_openapi_service = Mock() 21 | self.mock_openapi_service.order_api = mock_order_api 22 | 23 | 24 | def test_raise_error_if_no_workflow(self): 25 | with self.assertRaises(ValueError): 26 | RapidataOrderBuilder( 27 | openapi_service=self.mock_openapi_service, name="Test Order" 28 | ).create() 29 | 30 | def test_basic_order_build(self): 31 | order_builder = ( 32 | RapidataOrderBuilder( 33 | openapi_service=self.mock_openapi_service, name="Test Order" 34 | ) 35 | .workflow( 36 | ClassifyWorkflow(question="Test Question?", options=["Yes", "No"]) 37 | ) 38 | ) 39 | 40 | self.assertEqual(order_builder._name, "Test Order") 41 | self.assertIsInstance(order_builder._workflow, ClassifyWorkflow) 42 | 43 | self.assertEqual(order_builder._workflow._question, "Test Question?") # type: ignore 44 | self.assertEqual(order_builder._workflow._options, ["Yes", "No"]) # type: ignore 45 | --------------------------------------------------------------------------------