anyscale 0.24.86__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anyscale/__init__.py +181 -0
- anyscale/_private/anyscale_client/README.md +16 -0
- anyscale/_private/anyscale_client/__init__.py +8 -0
- anyscale/_private/anyscale_client/anyscale_client.py +1847 -0
- anyscale/_private/anyscale_client/common.py +593 -0
- anyscale/_private/anyscale_client/fake_anyscale_client.py +1080 -0
- anyscale/_private/docgen/README.md +15 -0
- anyscale/_private/docgen/__main__.py +700 -0
- anyscale/_private/docgen/api.md +1106 -0
- anyscale/_private/docgen/generator.py +559 -0
- anyscale/_private/docgen/generator_legacy.py +104 -0
- anyscale/_private/docgen/models.md +2261 -0
- anyscale/_private/models/__init__.py +2 -0
- anyscale/_private/models/image_uri.py +116 -0
- anyscale/_private/models/model_base.py +251 -0
- anyscale/_private/sdk/__init__.py +102 -0
- anyscale/_private/sdk/base_sdk.py +35 -0
- anyscale/_private/sdk/timer.py +46 -0
- anyscale/_private/utils/__init__.py +0 -0
- anyscale/_private/utils/progress_util.py +85 -0
- anyscale/_private/workload/__init__.py +2 -0
- anyscale/_private/workload/workload_config.py +195 -0
- anyscale/_private/workload/workload_sdk.py +324 -0
- anyscale/aggregated_instance_usage/__init__.py +36 -0
- anyscale/aggregated_instance_usage/_private/aggregated_instance_usage_sdk.py +30 -0
- anyscale/aggregated_instance_usage/commands.py +42 -0
- anyscale/aggregated_instance_usage/models.py +85 -0
- anyscale/anyscale-cloud-setup-gcp-oa.yaml +88 -0
- anyscale/anyscale-cloud-setup-gcp.yaml +113 -0
- anyscale/anyscale-cloud-setup-oa.yaml +121 -0
- anyscale/anyscale-cloud-setup.yaml +327 -0
- anyscale/anyscale_pydantic/HISTORY.md +1254 -0
- anyscale/anyscale_pydantic/LICENSE +21 -0
- anyscale/anyscale_pydantic/PKG-INFO +1351 -0
- anyscale/anyscale_pydantic/README.md +7 -0
- anyscale/anyscale_pydantic/__init__.py +131 -0
- anyscale/anyscale_pydantic/_hypothesis_plugin.py +391 -0
- anyscale/anyscale_pydantic/annotated_types.py +72 -0
- anyscale/anyscale_pydantic/class_validators.py +361 -0
- anyscale/anyscale_pydantic/color.py +494 -0
- anyscale/anyscale_pydantic/config.py +191 -0
- anyscale/anyscale_pydantic/dataclasses.py +478 -0
- anyscale/anyscale_pydantic/datetime_parse.py +248 -0
- anyscale/anyscale_pydantic/decorator.py +264 -0
- anyscale/anyscale_pydantic/env_settings.py +350 -0
- anyscale/anyscale_pydantic/error_wrappers.py +162 -0
- anyscale/anyscale_pydantic/errors.py +646 -0
- anyscale/anyscale_pydantic/fields.py +1256 -0
- anyscale/anyscale_pydantic/generics.py +400 -0
- anyscale/anyscale_pydantic/json.py +112 -0
- anyscale/anyscale_pydantic/main.py +1109 -0
- anyscale/anyscale_pydantic/mypy.py +943 -0
- anyscale/anyscale_pydantic/networks.py +739 -0
- anyscale/anyscale_pydantic/parse.py +66 -0
- anyscale/anyscale_pydantic/py.typed +0 -0
- anyscale/anyscale_pydantic/schema.py +1164 -0
- anyscale/anyscale_pydantic/tools.py +92 -0
- anyscale/anyscale_pydantic/types.py +1206 -0
- anyscale/anyscale_pydantic/typing.py +603 -0
- anyscale/anyscale_pydantic/utils.py +803 -0
- anyscale/anyscale_pydantic/validators.py +765 -0
- anyscale/anyscale_pydantic/version.py +38 -0
- anyscale/anyscale_schema.json +9 -0
- anyscale/api.py +215 -0
- anyscale/api_utils/README.md +2 -0
- anyscale/api_utils/__init__.py +0 -0
- anyscale/api_utils/common_utils.py +81 -0
- anyscale/api_utils/exceptions/__init__.py +0 -0
- anyscale/api_utils/exceptions/job_errors.py +2 -0
- anyscale/api_utils/job_logs_util.py +116 -0
- anyscale/api_utils/job_util.py +22 -0
- anyscale/api_utils/logs_util.py +61 -0
- anyscale/authenticate.py +298 -0
- anyscale/aws_iam_policies.py +465 -0
- anyscale/background/__init__.py +0 -0
- anyscale/background/job_runner.py +64 -0
- anyscale/cli_logger.py +378 -0
- anyscale/client/.gitignore +66 -0
- anyscale/client/.openapi-generator/VERSION +1 -0
- anyscale/client/.openapi-generator-ignore +23 -0
- anyscale/client/README.md +1070 -0
- anyscale/client/git_push.sh +58 -0
- anyscale/client/openapi_client/__init__.py +667 -0
- anyscale/client/openapi_client/api/__init__.py +6 -0
- anyscale/client/openapi_client/api/default_api.py +40922 -0
- anyscale/client/openapi_client/api_client.py +647 -0
- anyscale/client/openapi_client/configuration.py +373 -0
- anyscale/client/openapi_client/exceptions.py +120 -0
- anyscale/client/openapi_client/models/__init__.py +652 -0
- anyscale/client/openapi_client/models/access_config.py +122 -0
- anyscale/client/openapi_client/models/aggregated_instance_usage_with_cost_model.py +733 -0
- anyscale/client/openapi_client/models/aggregatedinstanceusagewithcostmodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/aica_endpoint.py +527 -0
- anyscale/client/openapi_client/models/aica_endpoint_event.py +433 -0
- anyscale/client/openapi_client/models/aica_endpoint_event_level.py +103 -0
- anyscale/client/openapi_client/models/aica_endpoint_event_type.py +120 -0
- anyscale/client/openapi_client/models/aica_endpoint_scope.py +102 -0
- anyscale/client/openapi_client/models/aica_model.py +398 -0
- anyscale/client/openapi_client/models/aica_model_accelerator_map.py +123 -0
- anyscale/client/openapi_client/models/aica_model_configuration.py +209 -0
- anyscale/client/openapi_client/models/aica_observability_urls.py +178 -0
- anyscale/client/openapi_client/models/aicaendpoint_list_response.py +147 -0
- anyscale/client/openapi_client/models/aicaendpoint_response.py +121 -0
- anyscale/client/openapi_client/models/aicaendpointevent_list_response.py +147 -0
- anyscale/client/openapi_client/models/aicamodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/aicamodel_response.py +121 -0
- anyscale/client/openapi_client/models/aioa_cloud_waitlist_record.py +254 -0
- anyscale/client/openapi_client/models/aioacloudwaitlistrecord_response.py +121 -0
- anyscale/client/openapi_client/models/alert_type.py +103 -0
- anyscale/client/openapi_client/models/anyscale_aws_account.py +121 -0
- anyscale/client/openapi_client/models/anyscale_service_account.py +256 -0
- anyscale/client/openapi_client/models/anyscale_version_response.py +121 -0
- anyscale/client/openapi_client/models/anyscaleawsaccount_response.py +121 -0
- anyscale/client/openapi_client/models/anyscaled_credential_response.py +121 -0
- anyscale/client/openapi_client/models/anyscaledcredentialresponse_response.py +121 -0
- anyscale/client/openapi_client/models/anyscaleserviceaccount_response.py +121 -0
- anyscale/client/openapi_client/models/anyscaleversionresponse_response.py +121 -0
- anyscale/client/openapi_client/models/api_key_parameters.py +147 -0
- anyscale/client/openapi_client/models/app_config.py +436 -0
- anyscale/client/openapi_client/models/app_config_config_schema.py +235 -0
- anyscale/client/openapi_client/models/appconfig_list_response.py +147 -0
- anyscale/client/openapi_client/models/appconfig_response.py +121 -0
- anyscale/client/openapi_client/models/application_type.py +99 -0
- anyscale/client/openapi_client/models/applied_snapshot.py +175 -0
- anyscale/client/openapi_client/models/apply_production_service_v2_model.py +490 -0
- anyscale/client/openapi_client/models/archive_status.py +101 -0
- anyscale/client/openapi_client/models/archived_logs_info.py +164 -0
- anyscale/client/openapi_client/models/archivedlogsinfo_response.py +121 -0
- anyscale/client/openapi_client/models/attach_machine_pool_to_cloud_request.py +152 -0
- anyscale/client/openapi_client/models/attachmachinepooltocloudresponse_response.py +121 -0
- anyscale/client/openapi_client/models/aviary_model_config_v2.py +358 -0
- anyscale/client/openapi_client/models/aws_credentials.py +181 -0
- anyscale/client/openapi_client/models/aws_memory_db_cluster_config.py +148 -0
- anyscale/client/openapi_client/models/aws_region_and_zones.py +123 -0
- anyscale/client/openapi_client/models/aws_region_info.py +152 -0
- anyscale/client/openapi_client/models/awsregionandzones_response.py +121 -0
- anyscale/client/openapi_client/models/bank_account_information.py +239 -0
- anyscale/client/openapi_client/models/base_job_status.py +105 -0
- anyscale/client/openapi_client/models/baseimagesenum.py +2130 -0
- anyscale/client/openapi_client/models/batch_response_batched_result_organization_invitation_base.py +121 -0
- anyscale/client/openapi_client/models/batched_result_organization_invitation_base.py +173 -0
- anyscale/client/openapi_client/models/billing_information.py +181 -0
- anyscale/client/openapi_client/models/billing_version_code.py +100 -0
- anyscale/client/openapi_client/models/body_aws_marketplace_registration_api_v2_organization_billing_aws_marketplace_registration_post.py +121 -0
- anyscale/client/openapi_client/models/buffer_registration.py +285 -0
- anyscale/client/openapi_client/models/build.py +607 -0
- anyscale/client/openapi_client/models/build_log_response.py +123 -0
- anyscale/client/openapi_client/models/build_registration.py +285 -0
- anyscale/client/openapi_client/models/build_response.py +121 -0
- anyscale/client/openapi_client/models/build_status.py +104 -0
- anyscale/client/openapi_client/models/buildlogresponse_response.py +121 -0
- anyscale/client/openapi_client/models/card.py +181 -0
- anyscale/client/openapi_client/models/card_id.py +108 -0
- anyscale/client/openapi_client/models/card_list_response.py +147 -0
- anyscale/client/openapi_client/models/change_password_params.py +148 -0
- anyscale/client/openapi_client/models/cleanup_leaked_grafana_dashboard_response.py +208 -0
- anyscale/client/openapi_client/models/cleanupleakedgrafanadashboardresponse_response.py +121 -0
- anyscale/client/openapi_client/models/clone_experimental_workspace.py +151 -0
- anyscale/client/openapi_client/models/cloud.py +802 -0
- anyscale/client/openapi_client/models/cloud_analytics_event.py +351 -0
- anyscale/client/openapi_client/models/cloud_analytics_event_cloud_provider_error.py +152 -0
- anyscale/client/openapi_client/models/cloud_analytics_event_cloud_resource.py +117 -0
- anyscale/client/openapi_client/models/cloud_analytics_event_command_name.py +103 -0
- anyscale/client/openapi_client/models/cloud_analytics_event_error.py +150 -0
- anyscale/client/openapi_client/models/cloud_analytics_event_name.py +109 -0
- anyscale/client/openapi_client/models/cloud_collaborator.py +175 -0
- anyscale/client/openapi_client/models/cloud_collaborator_value.py +177 -0
- anyscale/client/openapi_client/models/cloud_collaborators_query.py +122 -0
- anyscale/client/openapi_client/models/cloud_config.py +206 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_access_mode.py +100 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_file_type.py +102 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_upload_info.py +268 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_upload_request.py +152 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_upload_scheme.py +100 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_url_request.py +209 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_url_response.py +296 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_presigned_url_scheme.py +100 -0
- anyscale/client/openapi_client/models/cloud_data_bucket_request_scope.py +100 -0
- anyscale/client/openapi_client/models/cloud_hosting_type.py +100 -0
- anyscale/client/openapi_client/models/cloud_list_response.py +147 -0
- anyscale/client/openapi_client/models/cloud_name_options.py +121 -0
- anyscale/client/openapi_client/models/cloud_overview_dashboard.py +175 -0
- anyscale/client/openapi_client/models/cloud_project_collaborator.py +175 -0
- anyscale/client/openapi_client/models/cloud_project_collaborator_value.py +121 -0
- anyscale/client/openapi_client/models/cloud_provider.py +102 -0
- anyscale/client/openapi_client/models/cloud_providers.py +103 -0
- anyscale/client/openapi_client/models/cloud_region_and_zones.py +123 -0
- anyscale/client/openapi_client/models/cloud_region_info.py +152 -0
- anyscale/client/openapi_client/models/cloud_resource.py +740 -0
- anyscale/client/openapi_client/models/cloud_resource_gcp.py +691 -0
- anyscale/client/openapi_client/models/cloud_response.py +121 -0
- anyscale/client/openapi_client/models/cloud_state.py +104 -0
- anyscale/client/openapi_client/models/cloud_status.py +100 -0
- anyscale/client/openapi_client/models/cloud_type.py +100 -0
- anyscale/client/openapi_client/models/cloud_types.py +100 -0
- anyscale/client/openapi_client/models/cloud_version.py +100 -0
- anyscale/client/openapi_client/models/cloud_waitlist_status.py +102 -0
- anyscale/client/openapi_client/models/cloud_with_cloud_resource.py +830 -0
- anyscale/client/openapi_client/models/cloud_with_cloud_resource_gcp.py +830 -0
- anyscale/client/openapi_client/models/cloudcollaborator_list_response.py +147 -0
- anyscale/client/openapi_client/models/clouddatabucketpresigneduploadinfo_response.py +121 -0
- anyscale/client/openapi_client/models/clouddatabucketpresignedurlresponse_response.py +121 -0
- anyscale/client/openapi_client/models/cloudoverviewdashboard_response.py +121 -0
- anyscale/client/openapi_client/models/cloudregionandzones_response.py +121 -0
- anyscale/client/openapi_client/models/cloudresource_response.py +121 -0
- anyscale/client/openapi_client/models/cloudresourcegcp_response.py +121 -0
- anyscale/client/openapi_client/models/cloudwithcloudresource_response.py +121 -0
- anyscale/client/openapi_client/models/cloudwithcloudresourcegcp_response.py +121 -0
- anyscale/client/openapi_client/models/cluster_auth_response.py +148 -0
- anyscale/client/openapi_client/models/cluster_config.py +178 -0
- anyscale/client/openapi_client/models/cluster_config_with_session_idle_timeout.py +204 -0
- anyscale/client/openapi_client/models/cluster_environments_query.py +290 -0
- anyscale/client/openapi_client/models/cluster_event.py +174 -0
- anyscale/client/openapi_client/models/cluster_events_output.py +175 -0
- anyscale/client/openapi_client/models/cluster_features.py +152 -0
- anyscale/client/openapi_client/models/cluster_management_stack_versions.py +100 -0
- anyscale/client/openapi_client/models/cluster_startup.py +208 -0
- anyscale/client/openapi_client/models/cluster_status.py +104 -0
- anyscale/client/openapi_client/models/cluster_status_details.py +100 -0
- anyscale/client/openapi_client/models/clusterauthresponse_response.py +121 -0
- anyscale/client/openapi_client/models/clusterconfig_response.py +121 -0
- anyscale/client/openapi_client/models/clusterconfigwithsessionidletimeout_response.py +121 -0
- anyscale/client/openapi_client/models/clustereventsoutput_response.py +121 -0
- anyscale/client/openapi_client/models/clusterfeatures_response.py +121 -0
- anyscale/client/openapi_client/models/company_size.py +103 -0
- anyscale/client/openapi_client/models/compute_node_type.py +292 -0
- anyscale/client/openapi_client/models/compute_stack.py +100 -0
- anyscale/client/openapi_client/models/compute_template.py +415 -0
- anyscale/client/openapi_client/models/compute_template_config.py +461 -0
- anyscale/client/openapi_client/models/compute_template_query.py +316 -0
- anyscale/client/openapi_client/models/computetemplate_response.py +121 -0
- anyscale/client/openapi_client/models/computetemplateconfig_response.py +121 -0
- anyscale/client/openapi_client/models/create_aica_endpoint.py +210 -0
- anyscale/client/openapi_client/models/create_aioa_cloud_waitlist.py +173 -0
- anyscale/client/openapi_client/models/create_analytics_event.py +122 -0
- anyscale/client/openapi_client/models/create_app_config.py +235 -0
- anyscale/client/openapi_client/models/create_app_config_configuration_schema.py +235 -0
- anyscale/client/openapi_client/models/create_billing_version.py +181 -0
- anyscale/client/openapi_client/models/create_bug_report_response.py +152 -0
- anyscale/client/openapi_client/models/create_build.py +263 -0
- anyscale/client/openapi_client/models/create_byod_app_config.py +180 -0
- anyscale/client/openapi_client/models/create_byod_app_config_configuration_schema.py +206 -0
- anyscale/client/openapi_client/models/create_byod_build.py +152 -0
- anyscale/client/openapi_client/models/create_cloud_collaborator.py +148 -0
- anyscale/client/openapi_client/models/create_cloud_resource.py +682 -0
- anyscale/client/openapi_client/models/create_cloud_resource_gcp.py +633 -0
- anyscale/client/openapi_client/models/create_cloud_with_cloud_resource.py +546 -0
- anyscale/client/openapi_client/models/create_cluster_compute_config.py +463 -0
- anyscale/client/openapi_client/models/create_compute_template.py +229 -0
- anyscale/client/openapi_client/models/create_compute_template_config.py +464 -0
- anyscale/client/openapi_client/models/create_dataset.py +200 -0
- anyscale/client/openapi_client/models/create_experimental_workspace.py +435 -0
- anyscale/client/openapi_client/models/create_experimental_workspace_from_job.py +123 -0
- anyscale/client/openapi_client/models/create_fine_tuning_hyperparameters.py +156 -0
- anyscale/client/openapi_client/models/create_fine_tuning_job_product_request.py +353 -0
- anyscale/client/openapi_client/models/create_instance_usage_budget.py +253 -0
- anyscale/client/openapi_client/models/create_internal_production_job.py +262 -0
- anyscale/client/openapi_client/models/create_job_queue_config.py +206 -0
- anyscale/client/openapi_client/models/create_job_queue_requests.py +323 -0
- anyscale/client/openapi_client/models/create_machine_pool_request.py +151 -0
- anyscale/client/openapi_client/models/create_machine_pool_response.py +123 -0
- anyscale/client/openapi_client/models/create_machine_request.py +151 -0
- anyscale/client/openapi_client/models/create_machine_response.py +123 -0
- anyscale/client/openapi_client/models/create_metronome_webhook_notification.py +175 -0
- anyscale/client/openapi_client/models/create_notification_channel_record.py +146 -0
- anyscale/client/openapi_client/models/create_organization_configuration.py +199 -0
- anyscale/client/openapi_client/models/create_organization_invitation.py +121 -0
- anyscale/client/openapi_client/models/create_otp_return_api_model.py +148 -0
- anyscale/client/openapi_client/models/create_production_job_config.py +347 -0
- anyscale/client/openapi_client/models/create_resource_quota.py +293 -0
- anyscale/client/openapi_client/models/create_schedule.py +263 -0
- anyscale/client/openapi_client/models/create_session_from_snapshot_options.py +565 -0
- anyscale/client/openapi_client/models/create_session_in_db.py +434 -0
- anyscale/client/openapi_client/models/create_session_response.py +174 -0
- anyscale/client/openapi_client/models/create_user.py +439 -0
- anyscale/client/openapi_client/models/create_user_project_collaborator.py +148 -0
- anyscale/client/openapi_client/models/create_user_project_collaborator_value.py +121 -0
- anyscale/client/openapi_client/models/create_workspace_from_template.py +263 -0
- anyscale/client/openapi_client/models/createbugreportresponse_response.py +121 -0
- anyscale/client/openapi_client/models/createcomputetemplateconfig_response.py +121 -0
- anyscale/client/openapi_client/models/createmachinepoolresponse_response.py +121 -0
- anyscale/client/openapi_client/models/createmachineresponse_response.py +121 -0
- anyscale/client/openapi_client/models/createotpreturnapimodel_response.py +121 -0
- anyscale/client/openapi_client/models/createsessionresponse_response.py +121 -0
- anyscale/client/openapi_client/models/credit_card_information.py +268 -0
- anyscale/client/openapi_client/models/customer_alert_status.py +101 -0
- anyscale/client/openapi_client/models/customer_billing_type.py +101 -0
- anyscale/client/openapi_client/models/dataplane_services.py +102 -0
- anyscale/client/openapi_client/models/dataset.py +416 -0
- anyscale/client/openapi_client/models/dataset_list_response.py +150 -0
- anyscale/client/openapi_client/models/dataset_response.py +121 -0
- anyscale/client/openapi_client/models/dataset_upload.py +148 -0
- anyscale/client/openapi_client/models/datasetupload_response.py +121 -0
- anyscale/client/openapi_client/models/decorated_application_template.py +493 -0
- anyscale/client/openapi_client/models/decorated_build.py +664 -0
- anyscale/client/openapi_client/models/decorated_compute_template.py +446 -0
- anyscale/client/openapi_client/models/decorated_compute_template_config.py +490 -0
- anyscale/client/openapi_client/models/decorated_interactive_session.py +793 -0
- anyscale/client/openapi_client/models/decorated_job.py +793 -0
- anyscale/client/openapi_client/models/decorated_job_queue.py +639 -0
- anyscale/client/openapi_client/models/decorated_job_submission.py +575 -0
- anyscale/client/openapi_client/models/decorated_list_service_api_model.py +670 -0
- anyscale/client/openapi_client/models/decorated_production_job.py +805 -0
- anyscale/client/openapi_client/models/decorated_production_job_state_transition.py +319 -0
- anyscale/client/openapi_client/models/decorated_production_service_v2_api_model.py +641 -0
- anyscale/client/openapi_client/models/decorated_production_service_v2_version_api_model.py +437 -0
- anyscale/client/openapi_client/models/decorated_runtime_env.py +488 -0
- anyscale/client/openapi_client/models/decorated_schedule.py +552 -0
- anyscale/client/openapi_client/models/decorated_serve_deployment.py +711 -0
- anyscale/client/openapi_client/models/decorated_service_event_api_model.py +513 -0
- anyscale/client/openapi_client/models/decorated_session.py +1789 -0
- anyscale/client/openapi_client/models/decorated_support_request.py +283 -0
- anyscale/client/openapi_client/models/decorated_unified_job.py +466 -0
- anyscale/client/openapi_client/models/decoratedapplicationtemplate_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedapplicationtemplate_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedbuild_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedbuild_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedcomputetemplate_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedcomputetemplate_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedinteractivesession_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedinteractivesession_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedjob_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedjob_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedjobqueue_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedjobqueue_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedjobsubmission_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedjobsubmission_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedlistserviceapimodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedproductionjob_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedproductionjob_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedproductionjobstatetransition_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedproductionservicev2_apimodel_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedproductionservicev2_versionapimodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedruntimeenv_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedruntimeenv_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedschedule_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedschedule_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedservedeployment_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedservedeployment_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedserviceeventapimodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedsession_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedsession_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedsupportrequest_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedsupportrequest_response.py +121 -0
- anyscale/client/openapi_client/models/decoratedunifiedjob_list_response.py +147 -0
- anyscale/client/openapi_client/models/decoratedunifiedjob_response.py +121 -0
- anyscale/client/openapi_client/models/delete_machine_pool_request.py +123 -0
- anyscale/client/openapi_client/models/delete_machine_request.py +206 -0
- anyscale/client/openapi_client/models/deleted_platform_fine_tuned_model.py +148 -0
- anyscale/client/openapi_client/models/deletedplatformfinetunedmodel_response.py +121 -0
- anyscale/client/openapi_client/models/deletemachinepoolresponse_response.py +121 -0
- anyscale/client/openapi_client/models/detach_machine_pool_from_cloud_request.py +152 -0
- anyscale/client/openapi_client/models/detachmachinepoolfromcloudresponse_response.py +121 -0
- anyscale/client/openapi_client/models/dismissal_type.py +100 -0
- anyscale/client/openapi_client/models/editable_cloud_resource.py +206 -0
- anyscale/client/openapi_client/models/editable_cloud_resource_gcp.py +178 -0
- anyscale/client/openapi_client/models/error.py +174 -0
- anyscale/client/openapi_client/models/event_level.py +104 -0
- anyscale/client/openapi_client/models/execute_command_response.py +175 -0
- anyscale/client/openapi_client/models/execute_interactive_command_options.py +147 -0
- anyscale/client/openapi_client/models/execute_shell_command_options.py +121 -0
- anyscale/client/openapi_client/models/executecommandresponse_response.py +121 -0
- anyscale/client/openapi_client/models/experimental_workspace.py +748 -0
- anyscale/client/openapi_client/models/experimental_workspaces_sort_field.py +100 -0
- anyscale/client/openapi_client/models/experimentalworkspace_list_response.py +147 -0
- anyscale/client/openapi_client/models/experimentalworkspace_response.py +121 -0
- anyscale/client/openapi_client/models/external_service_status.py +147 -0
- anyscale/client/openapi_client/models/external_service_status_response.py +250 -0
- anyscale/client/openapi_client/models/external_terminal_command.py +280 -0
- anyscale/client/openapi_client/models/externalservicestatusresponse_response.py +121 -0
- anyscale/client/openapi_client/models/feature_compatibility.py +152 -0
- anyscale/client/openapi_client/models/feature_flag_response.py +121 -0
- anyscale/client/openapi_client/models/featureflagresponse_response.py +121 -0
- anyscale/client/openapi_client/models/fine_tune_type.py +100 -0
- anyscale/client/openapi_client/models/fine_tuned_model.py +412 -0
- anyscale/client/openapi_client/models/fine_tuning_job_status.py +103 -0
- anyscale/client/openapi_client/models/finetunedmodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/finetunedmodel_response.py +121 -0
- anyscale/client/openapi_client/models/finish_ft_job_request.py +204 -0
- anyscale/client/openapi_client/models/finish_ft_job_request_v2.py +183 -0
- anyscale/client/openapi_client/models/gcp_file_store_config.py +175 -0
- anyscale/client/openapi_client/models/gcp_memorystore_instance_config.py +148 -0
- anyscale/client/openapi_client/models/grafana_dashboard.py +201 -0
- anyscale/client/openapi_client/models/grpc_protocol_config.py +178 -0
- anyscale/client/openapi_client/models/ha_job_error_types.py +103 -0
- anyscale/client/openapi_client/models/ha_job_event_level.py +101 -0
- anyscale/client/openapi_client/models/ha_job_event_origin.py +100 -0
- anyscale/client/openapi_client/models/ha_job_goal_states.py +102 -0
- anyscale/client/openapi_client/models/ha_job_states.py +109 -0
- anyscale/client/openapi_client/models/ha_job_type.py +100 -0
- anyscale/client/openapi_client/models/ha_jobs_sort_field.py +105 -0
- anyscale/client/openapi_client/models/head_ip.py +121 -0
- anyscale/client/openapi_client/models/headip_response.py +121 -0
- anyscale/client/openapi_client/models/http_protocol_config.py +150 -0
- anyscale/client/openapi_client/models/http_validation_error.py +120 -0
- anyscale/client/openapi_client/models/idle_termination_status.py +104 -0
- anyscale/client/openapi_client/models/import_aica_model.py +241 -0
- anyscale/client/openapi_client/models/instance_usage_budget.py +572 -0
- anyscale/client/openapi_client/models/instance_usage_budget_evaluation_period.py +100 -0
- anyscale/client/openapi_client/models/instanceusagebudget_list_response.py +147 -0
- anyscale/client/openapi_client/models/instanceusagebudget_response.py +121 -0
- anyscale/client/openapi_client/models/integration_details.py +120 -0
- anyscale/client/openapi_client/models/interactive_session_logs.py +152 -0
- anyscale/client/openapi_client/models/interactivesessionlogs_response.py +121 -0
- anyscale/client/openapi_client/models/internal_production_job.py +663 -0
- anyscale/client/openapi_client/models/internalproductionjob_response.py +121 -0
- anyscale/client/openapi_client/models/invoice.py +413 -0
- anyscale/client/openapi_client/models/invoice_list_response.py +147 -0
- anyscale/client/openapi_client/models/invoice_status.py +102 -0
- anyscale/client/openapi_client/models/invoices_query.py +150 -0
- anyscale/client/openapi_client/models/job_access.py +102 -0
- anyscale/client/openapi_client/models/job_queue.py +467 -0
- anyscale/client/openapi_client/models/job_queue_config.py +122 -0
- anyscale/client/openapi_client/models/job_queue_execution_mode.py +101 -0
- anyscale/client/openapi_client/models/job_queue_spec.py +263 -0
- anyscale/client/openapi_client/models/job_queue_state.py +100 -0
- anyscale/client/openapi_client/models/job_queues_query.py +262 -0
- anyscale/client/openapi_client/models/job_run_type.py +101 -0
- anyscale/client/openapi_client/models/job_state_log_level_types.py +100 -0
- anyscale/client/openapi_client/models/job_status.py +105 -0
- anyscale/client/openapi_client/models/job_submissions_sort_field.py +101 -0
- anyscale/client/openapi_client/models/jobqueue_response.py +121 -0
- anyscale/client/openapi_client/models/jobs_logs.py +152 -0
- anyscale/client/openapi_client/models/jobs_logs_query_info.py +181 -0
- anyscale/client/openapi_client/models/jobs_sort_field.py +104 -0
- anyscale/client/openapi_client/models/jobslogs_response.py +121 -0
- anyscale/client/openapi_client/models/jobslogsqueryinfo_response.py +121 -0
- anyscale/client/openapi_client/models/json_patch_operation.py +200 -0
- anyscale/client/openapi_client/models/kubernetes_manager_registration_request.py +123 -0
- anyscale/client/openapi_client/models/kubernetes_manager_registration_response.py +123 -0
- anyscale/client/openapi_client/models/kubernetesmanagerregistrationresponse_response.py +121 -0
- anyscale/client/openapi_client/models/lb_resource.py +123 -0
- anyscale/client/openapi_client/models/lbresource_response.py +121 -0
- anyscale/client/openapi_client/models/list_machine_pools_response.py +123 -0
- anyscale/client/openapi_client/models/list_machines_response.py +121 -0
- anyscale/client/openapi_client/models/list_resource_quotas_query.py +234 -0
- anyscale/client/openapi_client/models/list_response_metadata.py +146 -0
- anyscale/client/openapi_client/models/listmachinepoolsresponse_response.py +121 -0
- anyscale/client/openapi_client/models/listmachinesresponse_response.py +121 -0
- anyscale/client/openapi_client/models/log_detail.py +187 -0
- anyscale/client/openapi_client/models/log_details.py +151 -0
- anyscale/client/openapi_client/models/log_download_config.py +206 -0
- anyscale/client/openapi_client/models/log_download_request.py +150 -0
- anyscale/client/openapi_client/models/log_download_result.py +207 -0
- anyscale/client/openapi_client/models/log_file_chunk.py +439 -0
- anyscale/client/openapi_client/models/log_filter.py +430 -0
- anyscale/client/openapi_client/models/log_item.py +181 -0
- anyscale/client/openapi_client/models/log_item_batch.py +151 -0
- anyscale/client/openapi_client/models/log_level_types.py +100 -0
- anyscale/client/openapi_client/models/log_stream.py +151 -0
- anyscale/client/openapi_client/models/logdetails_response.py +121 -0
- anyscale/client/openapi_client/models/logdownloadresult_response.py +121 -0
- anyscale/client/openapi_client/models/login_user_params.py +205 -0
- anyscale/client/openapi_client/models/logitembatch_response.py +121 -0
- anyscale/client/openapi_client/models/logs_output.py +202 -0
- anyscale/client/openapi_client/models/logsoutput_response.py +121 -0
- anyscale/client/openapi_client/models/logstream_response.py +121 -0
- anyscale/client/openapi_client/models/long_running_workload.py +256 -0
- anyscale/client/openapi_client/models/longrunningworkload_list_response.py +147 -0
- anyscale/client/openapi_client/models/machine_allocation_state.py +100 -0
- anyscale/client/openapi_client/models/machine_connection_state.py +100 -0
- anyscale/client/openapi_client/models/machine_info.py +466 -0
- anyscale/client/openapi_client/models/machine_pool.py +266 -0
- anyscale/client/openapi_client/models/metronome_customer_info_model.py +148 -0
- anyscale/client/openapi_client/models/metronome_dashboard_type.py +101 -0
- anyscale/client/openapi_client/models/metronomecustomerinfomodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/metronomecustomerinfomodel_response.py +121 -0
- anyscale/client/openapi_client/models/mini_build.py +267 -0
- anyscale/client/openapi_client/models/mini_cloud.py +321 -0
- anyscale/client/openapi_client/models/mini_cluster.py +148 -0
- anyscale/client/openapi_client/models/mini_compute_template.py +228 -0
- anyscale/client/openapi_client/models/mini_compute_template_config.py +121 -0
- anyscale/client/openapi_client/models/mini_job_run.py +599 -0
- anyscale/client/openapi_client/models/mini_namespace.py +148 -0
- anyscale/client/openapi_client/models/mini_organization.py +148 -0
- anyscale/client/openapi_client/models/mini_production_job.py +202 -0
- anyscale/client/openapi_client/models/mini_project.py +205 -0
- anyscale/client/openapi_client/models/mini_runtime_environment.py +147 -0
- anyscale/client/openapi_client/models/mini_schedule.py +180 -0
- anyscale/client/openapi_client/models/mini_user.py +266 -0
- anyscale/client/openapi_client/models/minibuild_list_response.py +147 -0
- anyscale/client/openapi_client/models/minicomputetemplate_list_response.py +147 -0
- anyscale/client/openapi_client/models/miniproject_list_response.py +147 -0
- anyscale/client/openapi_client/models/monitor_logs_extension.py +100 -0
- anyscale/client/openapi_client/models/named_entity.py +148 -0
- anyscale/client/openapi_client/models/nfs_mount_target.py +151 -0
- anyscale/client/openapi_client/models/node_registration_aws.py +152 -0
- anyscale/client/openapi_client/models/node_registration_gcp.py +123 -0
- anyscale/client/openapi_client/models/node_registration_k8_s.py +178 -0
- anyscale/client/openapi_client/models/node_registration_provisioned.py +150 -0
- anyscale/client/openapi_client/models/node_registration_v2.py +279 -0
- anyscale/client/openapi_client/models/node_type.py +100 -0
- anyscale/client/openapi_client/models/notification_channel_email_config.py +121 -0
- anyscale/client/openapi_client/models/notification_channel_webhook_config.py +121 -0
- anyscale/client/openapi_client/models/onboarding_user_cards_query.py +122 -0
- anyscale/client/openapi_client/models/organization.py +490 -0
- anyscale/client/openapi_client/models/organization_availability.py +148 -0
- anyscale/client/openapi_client/models/organization_collaborator.py +259 -0
- anyscale/client/openapi_client/models/organization_configuration.py +280 -0
- anyscale/client/openapi_client/models/organization_configuration_response.py +227 -0
- anyscale/client/openapi_client/models/organization_invitation.py +255 -0
- anyscale/client/openapi_client/models/organization_invitation_base.py +121 -0
- anyscale/client/openapi_client/models/organization_marketing_questions.py +198 -0
- anyscale/client/openapi_client/models/organization_permission_level.py +100 -0
- anyscale/client/openapi_client/models/organization_project_collaborator.py +175 -0
- anyscale/client/openapi_client/models/organization_project_collaborator_value.py +148 -0
- anyscale/client/openapi_client/models/organization_public_identifier.py +121 -0
- anyscale/client/openapi_client/models/organization_response.py +121 -0
- anyscale/client/openapi_client/models/organization_summary.py +229 -0
- anyscale/client/openapi_client/models/organization_usage_alert.py +210 -0
- anyscale/client/openapi_client/models/organization_usage_alert_severity.py +100 -0
- anyscale/client/openapi_client/models/organizationavailability_response.py +121 -0
- anyscale/client/openapi_client/models/organizationcollaborator_list_response.py +147 -0
- anyscale/client/openapi_client/models/organizationconfiguration_list_response.py +147 -0
- anyscale/client/openapi_client/models/organizationconfigurationresponse_response.py +121 -0
- anyscale/client/openapi_client/models/organizationinvitation_list_response.py +147 -0
- anyscale/client/openapi_client/models/organizationinvitation_response.py +121 -0
- anyscale/client/openapi_client/models/organizationinvitationbase_response.py +121 -0
- anyscale/client/openapi_client/models/organizationprojectcollaborator_list_response.py +147 -0
- anyscale/client/openapi_client/models/organizationpublicidentifier_response.py +121 -0
- anyscale/client/openapi_client/models/organizationusagealert_list_response.py +147 -0
- anyscale/client/openapi_client/models/page_query.py +153 -0
- anyscale/client/openapi_client/models/pause_schedule.py +123 -0
- anyscale/client/openapi_client/models/permission_level.py +101 -0
- anyscale/client/openapi_client/models/platform_fine_tuning_job.py +577 -0
- anyscale/client/openapi_client/models/platformfinetuningjob_list_response.py +147 -0
- anyscale/client/openapi_client/models/platformfinetuningjob_response.py +121 -0
- anyscale/client/openapi_client/models/product_autoscaler_flag.py +122 -0
- anyscale/client/openapi_client/models/product_type.py +100 -0
- anyscale/client/openapi_client/models/productautoscalerflag_response.py +121 -0
- anyscale/client/openapi_client/models/production_job.py +437 -0
- anyscale/client/openapi_client/models/production_job_config.py +348 -0
- anyscale/client/openapi_client/models/production_job_event.py +378 -0
- anyscale/client/openapi_client/models/production_job_event_scope_filter.py +101 -0
- anyscale/client/openapi_client/models/production_job_state_transition.py +293 -0
- anyscale/client/openapi_client/models/productionjob_response.py +121 -0
- anyscale/client/openapi_client/models/productionjobevent_list_response.py +147 -0
- anyscale/client/openapi_client/models/project.py +554 -0
- anyscale/client/openapi_client/models/project_base.py +121 -0
- anyscale/client/openapi_client/models/project_collaborator.py +175 -0
- anyscale/client/openapi_client/models/project_collaborator_value.py +175 -0
- anyscale/client/openapi_client/models/project_collaborators_put_message.py +121 -0
- anyscale/client/openapi_client/models/project_create_message.py +148 -0
- anyscale/client/openapi_client/models/project_default_session_name.py +121 -0
- anyscale/client/openapi_client/models/project_delete_message.py +121 -0
- anyscale/client/openapi_client/models/project_list_response.py +147 -0
- anyscale/client/openapi_client/models/project_patch_message.py +121 -0
- anyscale/client/openapi_client/models/project_response.py +121 -0
- anyscale/client/openapi_client/models/projectbase_response.py +121 -0
- anyscale/client/openapi_client/models/projectcollaborator_list_response.py +147 -0
- anyscale/client/openapi_client/models/projectdefaultsessionname_response.py +121 -0
- anyscale/client/openapi_client/models/projects_sort_field.py +101 -0
- anyscale/client/openapi_client/models/projects_violating_tree_hierarchy_response.py +121 -0
- anyscale/client/openapi_client/models/projectsviolatingtreehierarchyresponse_response.py +121 -0
- anyscale/client/openapi_client/models/protocols.py +150 -0
- anyscale/client/openapi_client/models/provider_metadata.py +205 -0
- anyscale/client/openapi_client/models/providermetadata_response.py +121 -0
- anyscale/client/openapi_client/models/python_modules.py +150 -0
- anyscale/client/openapi_client/models/quota.py +198 -0
- anyscale/client/openapi_client/models/ray_gcs_external_storage_config.py +178 -0
- anyscale/client/openapi_client/models/ray_runtime_env_config.py +262 -0
- anyscale/client/openapi_client/models/read_billing_version.py +210 -0
- anyscale/client/openapi_client/models/readbillingversion_list_response.py +147 -0
- anyscale/client/openapi_client/models/replica_details.py +152 -0
- anyscale/client/openapi_client/models/replica_state.py +104 -0
- anyscale/client/openapi_client/models/request_email_magic_link_response.py +147 -0
- anyscale/client/openapi_client/models/request_otp_return_api_model.py +148 -0
- anyscale/client/openapi_client/models/request_password_reset_params.py +147 -0
- anyscale/client/openapi_client/models/requestemailmagiclinkresponse_response.py +121 -0
- anyscale/client/openapi_client/models/requestotpreturnapimodel_response.py +121 -0
- anyscale/client/openapi_client/models/reset_password_params.py +148 -0
- anyscale/client/openapi_client/models/resource_quota.py +465 -0
- anyscale/client/openapi_client/models/resource_quota_status.py +123 -0
- anyscale/client/openapi_client/models/resourcequota_list_response.py +147 -0
- anyscale/client/openapi_client/models/resourcequota_response.py +121 -0
- anyscale/client/openapi_client/models/resources.py +234 -0
- anyscale/client/openapi_client/models/resubmit_ft_job_request.py +121 -0
- anyscale/client/openapi_client/models/rollback_service_model.py +122 -0
- anyscale/client/openapi_client/models/rollout_strategy.py +100 -0
- anyscale/client/openapi_client/models/s3_download_location.py +148 -0
- anyscale/client/openapi_client/models/schedule_config.py +151 -0
- anyscale/client/openapi_client/models/serve_deployment_grafana_dashboard_status.py +101 -0
- anyscale/client/openapi_client/models/serve_deployment_logs.py +152 -0
- anyscale/client/openapi_client/models/serve_deployment_state.py +104 -0
- anyscale/client/openapi_client/models/servedeploymentlogs_response.py +121 -0
- anyscale/client/openapi_client/models/server_session_token.py +121 -0
- anyscale/client/openapi_client/models/serversessiontoken_response.py +121 -0
- anyscale/client/openapi_client/models/service_config.py +178 -0
- anyscale/client/openapi_client/models/service_event_current_state.py +108 -0
- anyscale/client/openapi_client/models/service_event_level.py +102 -0
- anyscale/client/openapi_client/models/service_event_origin.py +103 -0
- anyscale/client/openapi_client/models/service_event_scope.py +103 -0
- anyscale/client/openapi_client/models/service_event_scope_filter.py +104 -0
- anyscale/client/openapi_client/models/service_event_type.py +125 -0
- anyscale/client/openapi_client/models/service_event_verbose_message_model.py +180 -0
- anyscale/client/openapi_client/models/service_goal_states.py +100 -0
- anyscale/client/openapi_client/models/service_observability_urls.py +206 -0
- anyscale/client/openapi_client/models/service_sort_field.py +101 -0
- anyscale/client/openapi_client/models/service_type.py +100 -0
- anyscale/client/openapi_client/models/service_usage.py +353 -0
- anyscale/client/openapi_client/models/service_version_state.py +106 -0
- anyscale/client/openapi_client/models/serviceeventverbosemessagemodel_list_response.py +147 -0
- anyscale/client/openapi_client/models/session.py +834 -0
- anyscale/client/openapi_client/models/session_access.py +102 -0
- anyscale/client/openapi_client/models/session_autosync_sessions_update_message.py +121 -0
- anyscale/client/openapi_client/models/session_command.py +413 -0
- anyscale/client/openapi_client/models/session_command_finish_options.py +226 -0
- anyscale/client/openapi_client/models/session_command_id.py +121 -0
- anyscale/client/openapi_client/models/session_command_types.py +100 -0
- anyscale/client/openapi_client/models/session_create_message.py +148 -0
- anyscale/client/openapi_client/models/session_delete_message.py +121 -0
- anyscale/client/openapi_client/models/session_describe.py +175 -0
- anyscale/client/openapi_client/models/session_details.py +148 -0
- anyscale/client/openapi_client/models/session_event.py +267 -0
- anyscale/client/openapi_client/models/session_event_cause.py +150 -0
- anyscale/client/openapi_client/models/session_event_types.py +111 -0
- anyscale/client/openapi_client/models/session_execute_message.py +121 -0
- anyscale/client/openapi_client/models/session_finish_command_message.py +175 -0
- anyscale/client/openapi_client/models/session_history_item.py +146 -0
- anyscale/client/openapi_client/models/session_kill_command_message.py +121 -0
- anyscale/client/openapi_client/models/session_list_response.py +147 -0
- anyscale/client/openapi_client/models/session_patch_message.py +121 -0
- anyscale/client/openapi_client/models/session_response.py +121 -0
- anyscale/client/openapi_client/models/session_ssh_key.py +148 -0
- anyscale/client/openapi_client/models/session_starting_up_data.py +146 -0
- anyscale/client/openapi_client/models/session_state.py +111 -0
- anyscale/client/openapi_client/models/session_state_change_message.py +121 -0
- anyscale/client/openapi_client/models/session_state_data.py +146 -0
- anyscale/client/openapi_client/models/session_stopping_data.py +146 -0
- anyscale/client/openapi_client/models/sessioncommand_list_response.py +147 -0
- anyscale/client/openapi_client/models/sessioncommandid_response.py +121 -0
- anyscale/client/openapi_client/models/sessiondescribe_response.py +121 -0
- anyscale/client/openapi_client/models/sessiondetails_response.py +121 -0
- anyscale/client/openapi_client/models/sessionevent_list_response.py +147 -0
- anyscale/client/openapi_client/models/sessionhistoryitem_list_response.py +147 -0
- anyscale/client/openapi_client/models/sessions_sort_field.py +104 -0
- anyscale/client/openapi_client/models/sessionsshkey_response.py +121 -0
- anyscale/client/openapi_client/models/setup_initialize_session_options.py +225 -0
- anyscale/client/openapi_client/models/show_otp_source_return_api_model.py +121 -0
- anyscale/client/openapi_client/models/showotpsourcereturnapimodel_response.py +121 -0
- anyscale/client/openapi_client/models/snapshot_create_message.py +148 -0
- anyscale/client/openapi_client/models/snapshot_delete_message.py +148 -0
- anyscale/client/openapi_client/models/snapshot_patch_message.py +148 -0
- anyscale/client/openapi_client/models/socket_message_schemas.py +499 -0
- anyscale/client/openapi_client/models/socket_message_types.py +113 -0
- anyscale/client/openapi_client/models/socketmessageschemas_response.py +121 -0
- anyscale/client/openapi_client/models/socketmessagetypes_response.py +121 -0
- anyscale/client/openapi_client/models/sort_order.py +100 -0
- anyscale/client/openapi_client/models/sso_login_info.py +151 -0
- anyscale/client/openapi_client/models/ssologininfo_response.py +121 -0
- anyscale/client/openapi_client/models/start_session_options.py +146 -0
- anyscale/client/openapi_client/models/stop_session_options.py +227 -0
- anyscale/client/openapi_client/models/stream_publish_request.py +239 -0
- anyscale/client/openapi_client/models/subnet_id_with_availability_zone_aws.py +148 -0
- anyscale/client/openapi_client/models/support_requests_query.py +178 -0
- anyscale/client/openapi_client/models/supportedbaseimagesenum.py +1570 -0
- anyscale/client/openapi_client/models/templatized_compute_configs.py +202 -0
- anyscale/client/openapi_client/models/templatized_decorated_application_templates.py +202 -0
- anyscale/client/openapi_client/models/templatizedcomputeconfigs_response.py +121 -0
- anyscale/client/openapi_client/models/templatizeddecoratedapplicationtemplates_response.py +121 -0
- anyscale/client/openapi_client/models/text_query.py +178 -0
- anyscale/client/openapi_client/models/timestamped_logs_output.py +148 -0
- anyscale/client/openapi_client/models/timestampedlogsoutput_response.py +121 -0
- anyscale/client/openapi_client/models/tool.py +100 -0
- anyscale/client/openapi_client/models/tracing_config.py +178 -0
- anyscale/client/openapi_client/models/try_login_email_response.py +208 -0
- anyscale/client/openapi_client/models/tryloginemailresponse_response.py +121 -0
- anyscale/client/openapi_client/models/unified_job_sort_field.py +103 -0
- anyscale/client/openapi_client/models/unified_job_status.py +114 -0
- anyscale/client/openapi_client/models/unified_job_type.py +100 -0
- anyscale/client/openapi_client/models/update_cloud_with_cloud_resource.py +178 -0
- anyscale/client/openapi_client/models/update_cloud_with_cloud_resource_gcp.py +178 -0
- anyscale/client/openapi_client/models/update_cluster_dns.py +152 -0
- anyscale/client/openapi_client/models/update_compute_template.py +146 -0
- anyscale/client/openapi_client/models/update_compute_template_config.py +464 -0
- anyscale/client/openapi_client/models/update_endpoint.py +152 -0
- anyscale/client/openapi_client/models/update_machine_pool_request.py +151 -0
- anyscale/client/openapi_client/models/update_model_deployment.py +152 -0
- anyscale/client/openapi_client/models/update_organization_collaborator.py +121 -0
- anyscale/client/openapi_client/models/update_project_collaborator.py +121 -0
- anyscale/client/openapi_client/models/update_resource_quota.py +122 -0
- anyscale/client/openapi_client/models/updatemachinepoolresponse_response.py +121 -0
- anyscale/client/openapi_client/models/upload_session_command_logs_locations.py +148 -0
- anyscale/client/openapi_client/models/uploadsessioncommandlogslocations_response.py +121 -0
- anyscale/client/openapi_client/models/user_info.py +569 -0
- anyscale/client/openapi_client/models/user_resend_email_options.py +147 -0
- anyscale/client/openapi_client/models/user_service_access_types.py +100 -0
- anyscale/client/openapi_client/models/userinfo_response.py +121 -0
- anyscale/client/openapi_client/models/utm_fields.py +224 -0
- anyscale/client/openapi_client/models/ux_instance.py +468 -0
- anyscale/client/openapi_client/models/validate_otp_params_api_model.py +121 -0
- anyscale/client/openapi_client/models/validation_error.py +175 -0
- anyscale/client/openapi_client/models/verify_response.py +147 -0
- anyscale/client/openapi_client/models/verifyresponse_response.py +121 -0
- anyscale/client/openapi_client/models/visibility.py +100 -0
- anyscale/client/openapi_client/models/waitlist_status_response.py +121 -0
- anyscale/client/openapi_client/models/waitlist_status_type.py +100 -0
- anyscale/client/openapi_client/models/waitliststatusresponse_response.py +121 -0
- anyscale/client/openapi_client/models/wand_b_run_details.py +147 -0
- anyscale/client/openapi_client/models/web_terminal.py +121 -0
- anyscale/client/openapi_client/models/webterminal_list_response.py +147 -0
- anyscale/client/openapi_client/models/webterminal_response.py +121 -0
- anyscale/client/openapi_client/models/worker_node_type.py +404 -0
- anyscale/client/openapi_client/models/workload_type.py +102 -0
- anyscale/client/openapi_client/models/workspace_dataplane_artifact.py +181 -0
- anyscale/client/openapi_client/models/workspace_dataplane_artifacts.py +123 -0
- anyscale/client/openapi_client/models/workspace_dataplane_proxied_artifacts.py +178 -0
- anyscale/client/openapi_client/models/workspace_event.py +325 -0
- anyscale/client/openapi_client/models/workspace_event_source.py +100 -0
- anyscale/client/openapi_client/models/workspace_event_source_filter.py +101 -0
- anyscale/client/openapi_client/models/workspace_readme.py +123 -0
- anyscale/client/openapi_client/models/workspace_snapshot_states.py +108 -0
- anyscale/client/openapi_client/models/workspace_template.py +353 -0
- anyscale/client/openapi_client/models/workspace_template_cluster_environment_metadata.py +178 -0
- anyscale/client/openapi_client/models/workspacedataplaneartifacts_response.py +121 -0
- anyscale/client/openapi_client/models/workspacedataplaneproxiedartifacts_response.py +121 -0
- anyscale/client/openapi_client/models/workspaceevent_list_response.py +147 -0
- anyscale/client/openapi_client/models/workspacereadme_response.py +121 -0
- anyscale/client/openapi_client/models/workspacetemplate_list_response.py +147 -0
- anyscale/client/openapi_client/models/workspacetemplateclusterenvironmentmetadata_response.py +121 -0
- anyscale/client/openapi_client/models/write_cloud.py +546 -0
- anyscale/client/openapi_client/models/write_cluster_config.py +123 -0
- anyscale/client/openapi_client/models/write_project.py +226 -0
- anyscale/client/openapi_client/models/write_session.py +147 -0
- anyscale/client/openapi_client/models/write_support_request.py +121 -0
- anyscale/client/openapi_client/rest.py +296 -0
- anyscale/client/requirements.txt +6 -0
- anyscale/client/setup.cfg +2 -0
- anyscale/client/setup.py +40 -0
- anyscale/client/test-requirements.txt +3 -0
- anyscale/client/tox.ini +9 -0
- anyscale/cloud.py +216 -0
- anyscale/cloud_resource.py +1032 -0
- anyscale/cluster.py +138 -0
- anyscale/cluster_compute.py +167 -0
- anyscale/cluster_env.py +173 -0
- anyscale/commands/__init__.py +0 -0
- anyscale/commands/aggregated_instance_usage_commands.py +86 -0
- anyscale/commands/anyscale_api/__init__.py +0 -0
- anyscale/commands/anyscale_api/api_commands.py +23 -0
- anyscale/commands/anyscale_api/session_commands_commands.py +80 -0
- anyscale/commands/anyscale_api/session_operations_commands.py +28 -0
- anyscale/commands/anyscale_api/sessions_commands.py +152 -0
- anyscale/commands/auth_commands.py +41 -0
- anyscale/commands/cloud_commands.py +1011 -0
- anyscale/commands/cloud_commands_util.py +10 -0
- anyscale/commands/cluster_commands.py +476 -0
- anyscale/commands/cluster_env_commands.py +139 -0
- anyscale/commands/command_examples.py +495 -0
- anyscale/commands/compute_config_commands.py +252 -0
- anyscale/commands/config_commands.py +213 -0
- anyscale/commands/exec_commands.py +14 -0
- anyscale/commands/experimental_integrations_commands.py +70 -0
- anyscale/commands/image_commands.py +125 -0
- anyscale/commands/job_commands.py +745 -0
- anyscale/commands/list_commands.py +85 -0
- anyscale/commands/llm/dataset_commands.py +269 -0
- anyscale/commands/llm/group.py +15 -0
- anyscale/commands/llm/models_commands.py +123 -0
- anyscale/commands/login_commands.py +79 -0
- anyscale/commands/logs_commands.py +312 -0
- anyscale/commands/machine_commands.py +116 -0
- anyscale/commands/machine_pool_commands.py +163 -0
- anyscale/commands/migrate_commands.py +84 -0
- anyscale/commands/project_commands.py +203 -0
- anyscale/commands/resource_quota_commands.py +214 -0
- anyscale/commands/schedule_commands.py +436 -0
- anyscale/commands/service_account_commands.py +72 -0
- anyscale/commands/service_commands.py +738 -0
- anyscale/commands/session_commands_hidden.py +179 -0
- anyscale/commands/util.py +152 -0
- anyscale/commands/workspace_commands.py +511 -0
- anyscale/commands/workspace_commands_v2.py +874 -0
- anyscale/component_activity_util.py +83 -0
- anyscale/compute_config/__init__.py +84 -0
- anyscale/compute_config/_private/compute_config_sdk.py +433 -0
- anyscale/compute_config/commands.py +122 -0
- anyscale/compute_config/models.py +630 -0
- anyscale/conf.py +23 -0
- anyscale/connect.py +1323 -0
- anyscale/connect_utils/__init__.py +0 -0
- anyscale/connect_utils/prepare_cluster.py +962 -0
- anyscale/connect_utils/project.py +298 -0
- anyscale/connect_utils/start_interactive_session.py +437 -0
- anyscale/controllers/__init__.py +0 -0
- anyscale/controllers/auth_controller.py +134 -0
- anyscale/controllers/base_controller.py +52 -0
- anyscale/controllers/cloud_controller.py +3609 -0
- anyscale/controllers/cloud_functional_verification_controller.py +858 -0
- anyscale/controllers/cluster_controller.py +720 -0
- anyscale/controllers/cluster_env_controller.py +219 -0
- anyscale/controllers/compute_config_controller.py +351 -0
- anyscale/controllers/config_controller.py +422 -0
- anyscale/controllers/experimental_integrations_controller.py +80 -0
- anyscale/controllers/job_controller.py +647 -0
- anyscale/controllers/jobs_bg_controller.py +0 -0
- anyscale/controllers/list_controller.py +290 -0
- anyscale/controllers/llm/__init__.py +0 -0
- anyscale/controllers/llm/models_controller.py +144 -0
- anyscale/controllers/logs_controller.py +449 -0
- anyscale/controllers/machine_controller.py +37 -0
- anyscale/controllers/machine_pool_controller.py +86 -0
- anyscale/controllers/project_controller.py +281 -0
- anyscale/controllers/resource_quota_controller.py +183 -0
- anyscale/controllers/schedule_controller.py +333 -0
- anyscale/controllers/service_account_controller.py +168 -0
- anyscale/controllers/service_controller.py +453 -0
- anyscale/controllers/workspace_controller.py +253 -0
- anyscale/feature_flags.py +4 -0
- anyscale/fingerprint.py +62 -0
- anyscale/formatters/__init__.py +0 -0
- anyscale/formatters/clouds_formatter.py +65 -0
- anyscale/formatters/common_formatter.py +22 -0
- anyscale/gcp_verification.py +792 -0
- anyscale/image/__init__.py +73 -0
- anyscale/image/_private/image_sdk.py +202 -0
- anyscale/image/commands.py +117 -0
- anyscale/image/models.py +57 -0
- anyscale/integrations.py +329 -0
- anyscale/job/__init__.py +166 -0
- anyscale/job/_private/job_sdk.py +497 -0
- anyscale/job/commands.py +267 -0
- anyscale/job/models.py +500 -0
- anyscale/links.py +4 -0
- anyscale/llm/__init__.py +2 -0
- anyscale/llm/dataset/__init__.py +2 -0
- anyscale/llm/dataset/_private/__init__.py +0 -0
- anyscale/llm/dataset/_private/docs.py +63 -0
- anyscale/llm/dataset/_private/models.py +71 -0
- anyscale/llm/dataset/_private/sdk.py +147 -0
- anyscale/llm/model/__init__.py +2 -0
- anyscale/llm/model/_private/models_sdk.py +62 -0
- anyscale/llm/model/commands.py +93 -0
- anyscale/llm/model/models.py +171 -0
- anyscale/llm/model/sdk.py +62 -0
- anyscale/llm/sdk.py +27 -0
- anyscale/memorydb_supported_zones.json +22 -0
- anyscale/models/job_model.py +457 -0
- anyscale/models/service_model.py +125 -0
- anyscale/project.py +501 -0
- anyscale/schedule/__init__.py +91 -0
- anyscale/schedule/_private/schedule_sdk.py +165 -0
- anyscale/schedule/commands.py +149 -0
- anyscale/schedule/models.py +145 -0
- anyscale/scripts.py +164 -0
- anyscale/sdk/anyscale_client/__init__.py +235 -0
- anyscale/sdk/anyscale_client/api/__init__.py +6 -0
- anyscale/sdk/anyscale_client/api/default_api.py +11625 -0
- anyscale/sdk/anyscale_client/api_client.py +647 -0
- anyscale/sdk/anyscale_client/configuration.py +373 -0
- anyscale/sdk/anyscale_client/exceptions.py +120 -0
- anyscale/sdk/anyscale_client/models/__init__.py +220 -0
- anyscale/sdk/anyscale_client/models/access_config.py +122 -0
- anyscale/sdk/anyscale_client/models/app_config.py +436 -0
- anyscale/sdk/anyscale_client/models/app_config_config_schema.py +235 -0
- anyscale/sdk/anyscale_client/models/appconfig_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/appconfig_response.py +121 -0
- anyscale/sdk/anyscale_client/models/apply_production_service_v2_model.py +490 -0
- anyscale/sdk/anyscale_client/models/apply_service_model.py +490 -0
- anyscale/sdk/anyscale_client/models/archive_status.py +101 -0
- anyscale/sdk/anyscale_client/models/base_job_status.py +105 -0
- anyscale/sdk/anyscale_client/models/baseimagesenum.py +2130 -0
- anyscale/sdk/anyscale_client/models/build.py +607 -0
- anyscale/sdk/anyscale_client/models/build_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/build_log_response.py +123 -0
- anyscale/sdk/anyscale_client/models/build_response.py +121 -0
- anyscale/sdk/anyscale_client/models/build_status.py +104 -0
- anyscale/sdk/anyscale_client/models/buildlogresponse_response.py +121 -0
- anyscale/sdk/anyscale_client/models/cloud.py +802 -0
- anyscale/sdk/anyscale_client/models/cloud_config.py +206 -0
- anyscale/sdk/anyscale_client/models/cloud_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/cloud_providers.py +103 -0
- anyscale/sdk/anyscale_client/models/cloud_response.py +121 -0
- anyscale/sdk/anyscale_client/models/cloud_state.py +104 -0
- anyscale/sdk/anyscale_client/models/cloud_status.py +100 -0
- anyscale/sdk/anyscale_client/models/cloud_type.py +100 -0
- anyscale/sdk/anyscale_client/models/cloud_types.py +100 -0
- anyscale/sdk/anyscale_client/models/cloud_version.py +100 -0
- anyscale/sdk/anyscale_client/models/clouds_query.py +150 -0
- anyscale/sdk/anyscale_client/models/cluster.py +721 -0
- anyscale/sdk/anyscale_client/models/cluster_compute.py +415 -0
- anyscale/sdk/anyscale_client/models/cluster_compute_config.py +461 -0
- anyscale/sdk/anyscale_client/models/cluster_computes_query.py +293 -0
- anyscale/sdk/anyscale_client/models/cluster_environment.py +380 -0
- anyscale/sdk/anyscale_client/models/cluster_environment_build.py +578 -0
- anyscale/sdk/anyscale_client/models/cluster_environment_build_log_response.py +123 -0
- anyscale/sdk/anyscale_client/models/cluster_environment_build_operation.py +237 -0
- anyscale/sdk/anyscale_client/models/cluster_environment_build_status.py +104 -0
- anyscale/sdk/anyscale_client/models/cluster_environments_query.py +290 -0
- anyscale/sdk/anyscale_client/models/cluster_head_node_info.py +152 -0
- anyscale/sdk/anyscale_client/models/cluster_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/cluster_management_stack_versions.py +100 -0
- anyscale/sdk/anyscale_client/models/cluster_operation.py +266 -0
- anyscale/sdk/anyscale_client/models/cluster_operation_type.py +101 -0
- anyscale/sdk/anyscale_client/models/cluster_response.py +121 -0
- anyscale/sdk/anyscale_client/models/cluster_services_urls.py +430 -0
- anyscale/sdk/anyscale_client/models/cluster_state.py +108 -0
- anyscale/sdk/anyscale_client/models/cluster_status.py +104 -0
- anyscale/sdk/anyscale_client/models/cluster_status_details.py +100 -0
- anyscale/sdk/anyscale_client/models/clustercompute_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/clustercompute_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusterenvironment_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/clusterenvironment_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusterenvironmentbuild_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/clusterenvironmentbuild_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusterenvironmentbuildlogresponse_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusterenvironmentbuildoperation_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusteroperation_response.py +121 -0
- anyscale/sdk/anyscale_client/models/clusters_query.py +234 -0
- anyscale/sdk/anyscale_client/models/compute_node_type.py +292 -0
- anyscale/sdk/anyscale_client/models/compute_stack.py +100 -0
- anyscale/sdk/anyscale_client/models/compute_template.py +415 -0
- anyscale/sdk/anyscale_client/models/compute_template_config.py +461 -0
- anyscale/sdk/anyscale_client/models/compute_template_query.py +316 -0
- anyscale/sdk/anyscale_client/models/computetemplate_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/computetemplate_response.py +121 -0
- anyscale/sdk/anyscale_client/models/computetemplateconfig_response.py +121 -0
- anyscale/sdk/anyscale_client/models/create_app_config.py +235 -0
- anyscale/sdk/anyscale_client/models/create_app_config_configuration_schema.py +235 -0
- anyscale/sdk/anyscale_client/models/create_build.py +263 -0
- anyscale/sdk/anyscale_client/models/create_byod_app_config_configuration_schema.py +206 -0
- anyscale/sdk/anyscale_client/models/create_byod_cluster_environment.py +180 -0
- anyscale/sdk/anyscale_client/models/create_byod_cluster_environment_build.py +152 -0
- anyscale/sdk/anyscale_client/models/create_byod_cluster_environment_configuration_schema.py +208 -0
- anyscale/sdk/anyscale_client/models/create_cloud.py +518 -0
- anyscale/sdk/anyscale_client/models/create_cluster.py +376 -0
- anyscale/sdk/anyscale_client/models/create_cluster_compute.py +229 -0
- anyscale/sdk/anyscale_client/models/create_cluster_compute_config.py +463 -0
- anyscale/sdk/anyscale_client/models/create_cluster_environment.py +235 -0
- anyscale/sdk/anyscale_client/models/create_cluster_environment_build.py +263 -0
- anyscale/sdk/anyscale_client/models/create_cluster_environment_configuration_schema.py +235 -0
- anyscale/sdk/anyscale_client/models/create_compute_template.py +229 -0
- anyscale/sdk/anyscale_client/models/create_compute_template_config.py +464 -0
- anyscale/sdk/anyscale_client/models/create_job_queue_config.py +206 -0
- anyscale/sdk/anyscale_client/models/create_production_job.py +234 -0
- anyscale/sdk/anyscale_client/models/create_production_job_config.py +347 -0
- anyscale/sdk/anyscale_client/models/create_project.py +207 -0
- anyscale/sdk/anyscale_client/models/create_schedule.py +263 -0
- anyscale/sdk/anyscale_client/models/create_session.py +432 -0
- anyscale/sdk/anyscale_client/models/create_session_command.py +152 -0
- anyscale/sdk/anyscale_client/models/create_sso_config.py +150 -0
- anyscale/sdk/anyscale_client/models/grpc_protocol_config.py +178 -0
- anyscale/sdk/anyscale_client/models/ha_job_goal_states.py +102 -0
- anyscale/sdk/anyscale_client/models/ha_job_states.py +109 -0
- anyscale/sdk/anyscale_client/models/http_protocol_config.py +150 -0
- anyscale/sdk/anyscale_client/models/http_validation_error.py +120 -0
- anyscale/sdk/anyscale_client/models/idle_termination_status.py +104 -0
- anyscale/sdk/anyscale_client/models/job.py +466 -0
- anyscale/sdk/anyscale_client/models/job_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/job_queue_config.py +122 -0
- anyscale/sdk/anyscale_client/models/job_queue_execution_mode.py +101 -0
- anyscale/sdk/anyscale_client/models/job_queue_spec.py +263 -0
- anyscale/sdk/anyscale_client/models/job_run_type.py +101 -0
- anyscale/sdk/anyscale_client/models/job_status.py +105 -0
- anyscale/sdk/anyscale_client/models/jobs_query.py +458 -0
- anyscale/sdk/anyscale_client/models/jobs_sort_field.py +104 -0
- anyscale/sdk/anyscale_client/models/list_response_metadata.py +146 -0
- anyscale/sdk/anyscale_client/models/list_service_model.py +347 -0
- anyscale/sdk/anyscale_client/models/listservicemodel_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/log_download_result.py +207 -0
- anyscale/sdk/anyscale_client/models/log_file_chunk.py +439 -0
- anyscale/sdk/anyscale_client/models/log_level_types.py +100 -0
- anyscale/sdk/anyscale_client/models/log_stream.py +151 -0
- anyscale/sdk/anyscale_client/models/logdownloadresult_response.py +121 -0
- anyscale/sdk/anyscale_client/models/logstream_response.py +121 -0
- anyscale/sdk/anyscale_client/models/node_type.py +100 -0
- anyscale/sdk/anyscale_client/models/object_storage_config.py +122 -0
- anyscale/sdk/anyscale_client/models/object_storage_config_s3.py +256 -0
- anyscale/sdk/anyscale_client/models/objectstorageconfig_response.py +121 -0
- anyscale/sdk/anyscale_client/models/operation_error.py +123 -0
- anyscale/sdk/anyscale_client/models/operation_progress.py +123 -0
- anyscale/sdk/anyscale_client/models/operation_result.py +150 -0
- anyscale/sdk/anyscale_client/models/organization.py +209 -0
- anyscale/sdk/anyscale_client/models/organization_response.py +121 -0
- anyscale/sdk/anyscale_client/models/page_query.py +153 -0
- anyscale/sdk/anyscale_client/models/pause_schedule.py +123 -0
- anyscale/sdk/anyscale_client/models/production_job.py +437 -0
- anyscale/sdk/anyscale_client/models/production_job_config.py +348 -0
- anyscale/sdk/anyscale_client/models/production_job_state_transition.py +293 -0
- anyscale/sdk/anyscale_client/models/production_service_v2_model.py +612 -0
- anyscale/sdk/anyscale_client/models/production_service_v2_version_model.py +437 -0
- anyscale/sdk/anyscale_client/models/productionjob_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/productionjob_response.py +121 -0
- anyscale/sdk/anyscale_client/models/productionservicev2_model_response.py +121 -0
- anyscale/sdk/anyscale_client/models/project.py +467 -0
- anyscale/sdk/anyscale_client/models/project_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/project_response.py +121 -0
- anyscale/sdk/anyscale_client/models/projects_query.py +234 -0
- anyscale/sdk/anyscale_client/models/protocols.py +150 -0
- anyscale/sdk/anyscale_client/models/python_modules.py +150 -0
- anyscale/sdk/anyscale_client/models/python_version.py +105 -0
- anyscale/sdk/anyscale_client/models/ray_gcs_external_storage_config.py +178 -0
- anyscale/sdk/anyscale_client/models/ray_runtime_env_config.py +262 -0
- anyscale/sdk/anyscale_client/models/resources.py +234 -0
- anyscale/sdk/anyscale_client/models/rollback_service_model.py +122 -0
- anyscale/sdk/anyscale_client/models/rollout_strategy.py +100 -0
- anyscale/sdk/anyscale_client/models/runtime_environment.py +406 -0
- anyscale/sdk/anyscale_client/models/runtimeenvironment_response.py +121 -0
- anyscale/sdk/anyscale_client/models/schedule_api_model.py +467 -0
- anyscale/sdk/anyscale_client/models/schedule_config.py +151 -0
- anyscale/sdk/anyscale_client/models/scheduleapimodel_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/scheduleapimodel_response.py +121 -0
- anyscale/sdk/anyscale_client/models/service_config.py +178 -0
- anyscale/sdk/anyscale_client/models/service_event_current_state.py +108 -0
- anyscale/sdk/anyscale_client/models/service_goal_states.py +100 -0
- anyscale/sdk/anyscale_client/models/service_model.py +612 -0
- anyscale/sdk/anyscale_client/models/service_observability_urls.py +206 -0
- anyscale/sdk/anyscale_client/models/service_sort_field.py +101 -0
- anyscale/sdk/anyscale_client/models/service_type.py +100 -0
- anyscale/sdk/anyscale_client/models/service_version_state.py +106 -0
- anyscale/sdk/anyscale_client/models/servicemodel_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/servicemodel_response.py +121 -0
- anyscale/sdk/anyscale_client/models/session.py +1535 -0
- anyscale/sdk/anyscale_client/models/session_command.py +350 -0
- anyscale/sdk/anyscale_client/models/session_command_types.py +100 -0
- anyscale/sdk/anyscale_client/models/session_event.py +267 -0
- anyscale/sdk/anyscale_client/models/session_event_cause.py +150 -0
- anyscale/sdk/anyscale_client/models/session_event_types.py +111 -0
- anyscale/sdk/anyscale_client/models/session_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/session_operation.py +266 -0
- anyscale/sdk/anyscale_client/models/session_operation_type.py +101 -0
- anyscale/sdk/anyscale_client/models/session_response.py +121 -0
- anyscale/sdk/anyscale_client/models/session_starting_up_data.py +146 -0
- anyscale/sdk/anyscale_client/models/session_state.py +111 -0
- anyscale/sdk/anyscale_client/models/session_state_data.py +146 -0
- anyscale/sdk/anyscale_client/models/session_stopping_data.py +146 -0
- anyscale/sdk/anyscale_client/models/sessioncommand_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/sessioncommand_response.py +121 -0
- anyscale/sdk/anyscale_client/models/sessionevent_list_response.py +147 -0
- anyscale/sdk/anyscale_client/models/sessionoperation_response.py +121 -0
- anyscale/sdk/anyscale_client/models/sessions_query.py +206 -0
- anyscale/sdk/anyscale_client/models/sort_by_clause_jobs_sort_field.py +148 -0
- anyscale/sdk/anyscale_client/models/sort_order.py +100 -0
- anyscale/sdk/anyscale_client/models/sso_config.py +237 -0
- anyscale/sdk/anyscale_client/models/sso_mode.py +101 -0
- anyscale/sdk/anyscale_client/models/ssoconfig_response.py +121 -0
- anyscale/sdk/anyscale_client/models/start_cluster_options.py +178 -0
- anyscale/sdk/anyscale_client/models/start_session_options.py +206 -0
- anyscale/sdk/anyscale_client/models/static_sso_config.py +210 -0
- anyscale/sdk/anyscale_client/models/supportedbaseimagesenum.py +1570 -0
- anyscale/sdk/anyscale_client/models/terminate_cluster_options.py +122 -0
- anyscale/sdk/anyscale_client/models/terminate_session_options.py +206 -0
- anyscale/sdk/anyscale_client/models/text_query.py +178 -0
- anyscale/sdk/anyscale_client/models/tracing_config.py +178 -0
- anyscale/sdk/anyscale_client/models/update_app_config.py +122 -0
- anyscale/sdk/anyscale_client/models/update_cloud.py +150 -0
- anyscale/sdk/anyscale_client/models/update_cluster.py +206 -0
- anyscale/sdk/anyscale_client/models/update_compute_template.py +146 -0
- anyscale/sdk/anyscale_client/models/update_compute_template_config.py +464 -0
- anyscale/sdk/anyscale_client/models/update_organization.py +123 -0
- anyscale/sdk/anyscale_client/models/update_project.py +150 -0
- anyscale/sdk/anyscale_client/models/update_session.py +150 -0
- anyscale/sdk/anyscale_client/models/user_service_access_types.py +100 -0
- anyscale/sdk/anyscale_client/models/ux_instance.py +468 -0
- anyscale/sdk/anyscale_client/models/validation_error.py +175 -0
- anyscale/sdk/anyscale_client/models/worker_node_type.py +404 -0
- anyscale/sdk/anyscale_client/rest.py +296 -0
- anyscale/sdk/anyscale_client/sdk.py +634 -0
- anyscale/service/__init__.py +168 -0
- anyscale/service/_private/service_sdk.py +702 -0
- anyscale/service/commands.py +261 -0
- anyscale/service/models.py +671 -0
- anyscale/shared_anyscale_utils/__init__.py +1 -0
- anyscale/shared_anyscale_utils/aws.py +153 -0
- anyscale/shared_anyscale_utils/bytes_util.py +10 -0
- anyscale/shared_anyscale_utils/conf.py +47 -0
- anyscale/shared_anyscale_utils/default_anyscale_aws.yaml +74 -0
- anyscale/shared_anyscale_utils/default_anyscale_gcp.yaml +80 -0
- anyscale/shared_anyscale_utils/headers.py +38 -0
- anyscale/shared_anyscale_utils/latest_ray_version.py +2 -0
- anyscale/shared_anyscale_utils/project.py +15 -0
- anyscale/shared_anyscale_utils/test_util.py +22 -0
- anyscale/shared_anyscale_utils/tests/__init__.py +1 -0
- anyscale/shared_anyscale_utils/tests/test_asyncio.py +41 -0
- anyscale/shared_anyscale_utils/tests/test_ray_semver.py +63 -0
- anyscale/shared_anyscale_utils/util.py +50 -0
- anyscale/shared_anyscale_utils/utils/__init__.py +2 -0
- anyscale/shared_anyscale_utils/utils/asyncio.py +120 -0
- anyscale/shared_anyscale_utils/utils/byod.py +40 -0
- anyscale/shared_anyscale_utils/utils/collections.py +33 -0
- anyscale/shared_anyscale_utils/utils/id_gen.py +147 -0
- anyscale/shared_anyscale_utils/utils/protected_string.py +89 -0
- anyscale/shared_anyscale_utils/utils/ray_semver.py +81 -0
- anyscale/snapshot.py +46 -0
- anyscale/tables.py +82 -0
- anyscale/util.py +1155 -0
- anyscale/utils/__init__.py +0 -0
- anyscale/utils/cli_version_check_util.py +63 -0
- anyscale/utils/cloud_update_utils.py +862 -0
- anyscale/utils/cloud_utils.py +317 -0
- anyscale/utils/cluster_debug.py +191 -0
- anyscale/utils/connect_helpers.py +155 -0
- anyscale/utils/deprecation_util.py +32 -0
- anyscale/utils/entity_arg_utils.py +43 -0
- anyscale/utils/env_utils.py +17 -0
- anyscale/utils/gcp_managed_setup_utils.py +888 -0
- anyscale/utils/gcp_utils.py +312 -0
- anyscale/utils/imports/__init__.py +0 -0
- anyscale/utils/imports/all.py +13 -0
- anyscale/utils/imports/azure.py +14 -0
- anyscale/utils/imports/gcp.py +59 -0
- anyscale/utils/logs_utils.py +141 -0
- anyscale/utils/name_utils.py +33 -0
- anyscale/utils/network_verification.py +153 -0
- anyscale/utils/ray_utils.py +128 -0
- anyscale/utils/ray_version_checker.py +48 -0
- anyscale/utils/ray_version_utils.py +53 -0
- anyscale/utils/runtime_env.py +487 -0
- anyscale/utils/s3.py +92 -0
- anyscale/utils/user_utils.py +17 -0
- anyscale/utils/workload_types.py +7 -0
- anyscale/utils/workspace_notification.py +39 -0
- anyscale/utils/workspace_utils.py +65 -0
- anyscale/version.py +1 -0
- anyscale/webterminal/__init__.py +0 -0
- anyscale/webterminal/bash-preexec.sh +370 -0
- anyscale/webterminal/command_persister.py +164 -0
- anyscale/webterminal/utils.py +176 -0
- anyscale/webterminal/webterminal.py +311 -0
- anyscale/workspace/__init__.py +270 -0
- anyscale/workspace/_private/workspace_sdk.py +737 -0
- anyscale/workspace/commands.py +472 -0
- anyscale/workspace/models.py +296 -0
- anyscale/workspace_utils.py +35 -0
- anyscale-0.24.86.dist-info/LICENSE +68 -0
- anyscale-0.24.86.dist-info/METADATA +82 -0
- anyscale-0.24.86.dist-info/NOTICE +6 -0
- anyscale-0.24.86.dist-info/RECORD +1131 -0
- anyscale-0.24.86.dist-info/WHEEL +5 -0
- anyscale-0.24.86.dist-info/entry_points.txt +2 -0
- anyscale-0.24.86.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1164 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import warnings
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from dataclasses import is_dataclass
|
|
5
|
+
from datetime import date, datetime, time, timedelta
|
|
6
|
+
from decimal import Decimal
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from ipaddress import IPv4Address, IPv4Interface, IPv4Network, IPv6Address, IPv6Interface, IPv6Network
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import (
|
|
11
|
+
TYPE_CHECKING,
|
|
12
|
+
Any,
|
|
13
|
+
Callable,
|
|
14
|
+
Dict,
|
|
15
|
+
ForwardRef,
|
|
16
|
+
FrozenSet,
|
|
17
|
+
Generic,
|
|
18
|
+
Iterable,
|
|
19
|
+
List,
|
|
20
|
+
Optional,
|
|
21
|
+
Pattern,
|
|
22
|
+
Sequence,
|
|
23
|
+
Set,
|
|
24
|
+
Tuple,
|
|
25
|
+
Type,
|
|
26
|
+
TypeVar,
|
|
27
|
+
Union,
|
|
28
|
+
cast,
|
|
29
|
+
)
|
|
30
|
+
from uuid import UUID
|
|
31
|
+
|
|
32
|
+
from typing_extensions import Annotated, Literal
|
|
33
|
+
|
|
34
|
+
from .fields import (
|
|
35
|
+
MAPPING_LIKE_SHAPES,
|
|
36
|
+
SHAPE_DEQUE,
|
|
37
|
+
SHAPE_FROZENSET,
|
|
38
|
+
SHAPE_GENERIC,
|
|
39
|
+
SHAPE_ITERABLE,
|
|
40
|
+
SHAPE_LIST,
|
|
41
|
+
SHAPE_SEQUENCE,
|
|
42
|
+
SHAPE_SET,
|
|
43
|
+
SHAPE_SINGLETON,
|
|
44
|
+
SHAPE_TUPLE,
|
|
45
|
+
SHAPE_TUPLE_ELLIPSIS,
|
|
46
|
+
FieldInfo,
|
|
47
|
+
ModelField,
|
|
48
|
+
)
|
|
49
|
+
from .json import pydantic_encoder
|
|
50
|
+
from .networks import AnyUrl, EmailStr
|
|
51
|
+
from .types import (
|
|
52
|
+
ConstrainedDecimal,
|
|
53
|
+
ConstrainedFloat,
|
|
54
|
+
ConstrainedFrozenSet,
|
|
55
|
+
ConstrainedInt,
|
|
56
|
+
ConstrainedList,
|
|
57
|
+
ConstrainedSet,
|
|
58
|
+
ConstrainedStr,
|
|
59
|
+
SecretBytes,
|
|
60
|
+
SecretStr,
|
|
61
|
+
StrictBytes,
|
|
62
|
+
StrictStr,
|
|
63
|
+
conbytes,
|
|
64
|
+
condecimal,
|
|
65
|
+
confloat,
|
|
66
|
+
confrozenset,
|
|
67
|
+
conint,
|
|
68
|
+
conlist,
|
|
69
|
+
conset,
|
|
70
|
+
constr,
|
|
71
|
+
)
|
|
72
|
+
from .typing import (
|
|
73
|
+
all_literal_values,
|
|
74
|
+
get_args,
|
|
75
|
+
get_origin,
|
|
76
|
+
get_sub_types,
|
|
77
|
+
is_callable_type,
|
|
78
|
+
is_literal_type,
|
|
79
|
+
is_namedtuple,
|
|
80
|
+
is_none_type,
|
|
81
|
+
is_union,
|
|
82
|
+
)
|
|
83
|
+
from .utils import ROOT_KEY, get_model, lenient_issubclass
|
|
84
|
+
|
|
85
|
+
if TYPE_CHECKING:
|
|
86
|
+
from .dataclasses import Dataclass
|
|
87
|
+
from .main import BaseModel
|
|
88
|
+
|
|
89
|
+
default_prefix = '#/definitions/'
|
|
90
|
+
default_ref_template = '#/definitions/{model}'
|
|
91
|
+
|
|
92
|
+
TypeModelOrEnum = Union[Type['BaseModel'], Type[Enum]]
|
|
93
|
+
TypeModelSet = Set[TypeModelOrEnum]
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _apply_modify_schema(
|
|
97
|
+
modify_schema: Callable[..., None], field: Optional[ModelField], field_schema: Dict[str, Any]
|
|
98
|
+
) -> None:
|
|
99
|
+
from inspect import signature
|
|
100
|
+
|
|
101
|
+
sig = signature(modify_schema)
|
|
102
|
+
args = set(sig.parameters.keys())
|
|
103
|
+
if 'field' in args or 'kwargs' in args:
|
|
104
|
+
modify_schema(field_schema, field=field)
|
|
105
|
+
else:
|
|
106
|
+
modify_schema(field_schema)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def schema(
|
|
110
|
+
models: Sequence[Union[Type['BaseModel'], Type['Dataclass']]],
|
|
111
|
+
*,
|
|
112
|
+
by_alias: bool = True,
|
|
113
|
+
title: Optional[str] = None,
|
|
114
|
+
description: Optional[str] = None,
|
|
115
|
+
ref_prefix: Optional[str] = None,
|
|
116
|
+
ref_template: str = default_ref_template,
|
|
117
|
+
) -> Dict[str, Any]:
|
|
118
|
+
"""
|
|
119
|
+
Process a list of models and generate a single JSON Schema with all of them defined in the ``definitions``
|
|
120
|
+
top-level JSON key, including their sub-models.
|
|
121
|
+
|
|
122
|
+
:param models: a list of models to include in the generated JSON Schema
|
|
123
|
+
:param by_alias: generate the schemas using the aliases defined, if any
|
|
124
|
+
:param title: title for the generated schema that includes the definitions
|
|
125
|
+
:param description: description for the generated schema
|
|
126
|
+
:param ref_prefix: the JSON Pointer prefix for schema references with ``$ref``, if None, will be set to the
|
|
127
|
+
default of ``#/definitions/``. Update it if you want the schemas to reference the definitions somewhere
|
|
128
|
+
else, e.g. for OpenAPI use ``#/components/schemas/``. The resulting generated schemas will still be at the
|
|
129
|
+
top-level key ``definitions``, so you can extract them from there. But all the references will have the set
|
|
130
|
+
prefix.
|
|
131
|
+
:param ref_template: Use a ``string.format()`` template for ``$ref`` instead of a prefix. This can be useful
|
|
132
|
+
for references that cannot be represented by ``ref_prefix`` such as a definition stored in another file. For
|
|
133
|
+
a sibling json file in a ``/schemas`` directory use ``"/schemas/${model}.json#"``.
|
|
134
|
+
:return: dict with the JSON Schema with a ``definitions`` top-level key including the schema definitions for
|
|
135
|
+
the models and sub-models passed in ``models``.
|
|
136
|
+
"""
|
|
137
|
+
clean_models = [get_model(model) for model in models]
|
|
138
|
+
flat_models = get_flat_models_from_models(clean_models)
|
|
139
|
+
model_name_map = get_model_name_map(flat_models)
|
|
140
|
+
definitions = {}
|
|
141
|
+
output_schema: Dict[str, Any] = {}
|
|
142
|
+
if title:
|
|
143
|
+
output_schema['title'] = title
|
|
144
|
+
if description:
|
|
145
|
+
output_schema['description'] = description
|
|
146
|
+
for model in clean_models:
|
|
147
|
+
m_schema, m_definitions, m_nested_models = model_process_schema(
|
|
148
|
+
model,
|
|
149
|
+
by_alias=by_alias,
|
|
150
|
+
model_name_map=model_name_map,
|
|
151
|
+
ref_prefix=ref_prefix,
|
|
152
|
+
ref_template=ref_template,
|
|
153
|
+
)
|
|
154
|
+
definitions.update(m_definitions)
|
|
155
|
+
model_name = model_name_map[model]
|
|
156
|
+
definitions[model_name] = m_schema
|
|
157
|
+
if definitions:
|
|
158
|
+
output_schema['definitions'] = definitions
|
|
159
|
+
return output_schema
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def model_schema(
|
|
163
|
+
model: Union[Type['BaseModel'], Type['Dataclass']],
|
|
164
|
+
by_alias: bool = True,
|
|
165
|
+
ref_prefix: Optional[str] = None,
|
|
166
|
+
ref_template: str = default_ref_template,
|
|
167
|
+
) -> Dict[str, Any]:
|
|
168
|
+
"""
|
|
169
|
+
Generate a JSON Schema for one model. With all the sub-models defined in the ``definitions`` top-level
|
|
170
|
+
JSON key.
|
|
171
|
+
|
|
172
|
+
:param model: a Pydantic model (a class that inherits from BaseModel)
|
|
173
|
+
:param by_alias: generate the schemas using the aliases defined, if any
|
|
174
|
+
:param ref_prefix: the JSON Pointer prefix for schema references with ``$ref``, if None, will be set to the
|
|
175
|
+
default of ``#/definitions/``. Update it if you want the schemas to reference the definitions somewhere
|
|
176
|
+
else, e.g. for OpenAPI use ``#/components/schemas/``. The resulting generated schemas will still be at the
|
|
177
|
+
top-level key ``definitions``, so you can extract them from there. But all the references will have the set
|
|
178
|
+
prefix.
|
|
179
|
+
:param ref_template: Use a ``string.format()`` template for ``$ref`` instead of a prefix. This can be useful for
|
|
180
|
+
references that cannot be represented by ``ref_prefix`` such as a definition stored in another file. For a
|
|
181
|
+
sibling json file in a ``/schemas`` directory use ``"/schemas/${model}.json#"``.
|
|
182
|
+
:return: dict with the JSON Schema for the passed ``model``
|
|
183
|
+
"""
|
|
184
|
+
model = get_model(model)
|
|
185
|
+
flat_models = get_flat_models_from_model(model)
|
|
186
|
+
model_name_map = get_model_name_map(flat_models)
|
|
187
|
+
model_name = model_name_map[model]
|
|
188
|
+
m_schema, m_definitions, nested_models = model_process_schema(
|
|
189
|
+
model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix, ref_template=ref_template
|
|
190
|
+
)
|
|
191
|
+
if model_name in nested_models:
|
|
192
|
+
# model_name is in Nested models, it has circular references
|
|
193
|
+
m_definitions[model_name] = m_schema
|
|
194
|
+
m_schema = get_schema_ref(model_name, ref_prefix, ref_template, False)
|
|
195
|
+
if m_definitions:
|
|
196
|
+
m_schema.update({'definitions': m_definitions})
|
|
197
|
+
return m_schema
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def get_field_info_schema(field: ModelField, schema_overrides: bool = False) -> Tuple[Dict[str, Any], bool]:
|
|
201
|
+
|
|
202
|
+
# If no title is explicitly set, we don't set title in the schema for enums.
|
|
203
|
+
# The behaviour is the same as `BaseModel` reference, where the default title
|
|
204
|
+
# is in the definitions part of the schema.
|
|
205
|
+
schema_: Dict[str, Any] = {}
|
|
206
|
+
if field.field_info.title or not lenient_issubclass(field.type_, Enum):
|
|
207
|
+
schema_['title'] = field.field_info.title or field.alias.title().replace('_', ' ')
|
|
208
|
+
|
|
209
|
+
if field.field_info.title:
|
|
210
|
+
schema_overrides = True
|
|
211
|
+
|
|
212
|
+
if field.field_info.description:
|
|
213
|
+
schema_['description'] = field.field_info.description
|
|
214
|
+
schema_overrides = True
|
|
215
|
+
|
|
216
|
+
if not field.required and field.default is not None and not is_callable_type(field.outer_type_):
|
|
217
|
+
schema_['default'] = encode_default(field.default)
|
|
218
|
+
schema_overrides = True
|
|
219
|
+
|
|
220
|
+
return schema_, schema_overrides
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def field_schema(
|
|
224
|
+
field: ModelField,
|
|
225
|
+
*,
|
|
226
|
+
by_alias: bool = True,
|
|
227
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
228
|
+
ref_prefix: Optional[str] = None,
|
|
229
|
+
ref_template: str = default_ref_template,
|
|
230
|
+
known_models: Optional[TypeModelSet] = None,
|
|
231
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
232
|
+
"""
|
|
233
|
+
Process a Pydantic field and return a tuple with a JSON Schema for it as the first item.
|
|
234
|
+
Also return a dictionary of definitions with models as keys and their schemas as values. If the passed field
|
|
235
|
+
is a model and has sub-models, and those sub-models don't have overrides (as ``title``, ``default``, etc), they
|
|
236
|
+
will be included in the definitions and referenced in the schema instead of included recursively.
|
|
237
|
+
|
|
238
|
+
:param field: a Pydantic ``ModelField``
|
|
239
|
+
:param by_alias: use the defined alias (if any) in the returned schema
|
|
240
|
+
:param model_name_map: used to generate the JSON Schema references to other models included in the definitions
|
|
241
|
+
:param ref_prefix: the JSON Pointer prefix to use for references to other schemas, if None, the default of
|
|
242
|
+
#/definitions/ will be used
|
|
243
|
+
:param ref_template: Use a ``string.format()`` template for ``$ref`` instead of a prefix. This can be useful for
|
|
244
|
+
references that cannot be represented by ``ref_prefix`` such as a definition stored in another file. For a
|
|
245
|
+
sibling json file in a ``/schemas`` directory use ``"/schemas/${model}.json#"``.
|
|
246
|
+
:param known_models: used to solve circular references
|
|
247
|
+
:return: tuple of the schema for this field and additional definitions
|
|
248
|
+
"""
|
|
249
|
+
s, schema_overrides = get_field_info_schema(field)
|
|
250
|
+
|
|
251
|
+
validation_schema = get_field_schema_validations(field)
|
|
252
|
+
if validation_schema:
|
|
253
|
+
s.update(validation_schema)
|
|
254
|
+
schema_overrides = True
|
|
255
|
+
|
|
256
|
+
f_schema, f_definitions, f_nested_models = field_type_schema(
|
|
257
|
+
field,
|
|
258
|
+
by_alias=by_alias,
|
|
259
|
+
model_name_map=model_name_map,
|
|
260
|
+
schema_overrides=schema_overrides,
|
|
261
|
+
ref_prefix=ref_prefix,
|
|
262
|
+
ref_template=ref_template,
|
|
263
|
+
known_models=known_models or set(),
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
# $ref will only be returned when there are no schema_overrides
|
|
267
|
+
if '$ref' in f_schema:
|
|
268
|
+
return f_schema, f_definitions, f_nested_models
|
|
269
|
+
else:
|
|
270
|
+
s.update(f_schema)
|
|
271
|
+
return s, f_definitions, f_nested_models
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
numeric_types = (int, float, Decimal)
|
|
275
|
+
_str_types_attrs: Tuple[Tuple[str, Union[type, Tuple[type, ...]], str], ...] = (
|
|
276
|
+
('max_length', numeric_types, 'maxLength'),
|
|
277
|
+
('min_length', numeric_types, 'minLength'),
|
|
278
|
+
('regex', str, 'pattern'),
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
_numeric_types_attrs: Tuple[Tuple[str, Union[type, Tuple[type, ...]], str], ...] = (
|
|
282
|
+
('gt', numeric_types, 'exclusiveMinimum'),
|
|
283
|
+
('lt', numeric_types, 'exclusiveMaximum'),
|
|
284
|
+
('ge', numeric_types, 'minimum'),
|
|
285
|
+
('le', numeric_types, 'maximum'),
|
|
286
|
+
('multiple_of', numeric_types, 'multipleOf'),
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
def get_field_schema_validations(field: ModelField) -> Dict[str, Any]:
|
|
291
|
+
"""
|
|
292
|
+
Get the JSON Schema validation keywords for a ``field`` with an annotation of
|
|
293
|
+
a Pydantic ``FieldInfo`` with validation arguments.
|
|
294
|
+
"""
|
|
295
|
+
f_schema: Dict[str, Any] = {}
|
|
296
|
+
|
|
297
|
+
if lenient_issubclass(field.type_, Enum):
|
|
298
|
+
# schema is already updated by `enum_process_schema`; just update with field extra
|
|
299
|
+
if field.field_info.extra:
|
|
300
|
+
f_schema.update(field.field_info.extra)
|
|
301
|
+
return f_schema
|
|
302
|
+
|
|
303
|
+
if lenient_issubclass(field.type_, (str, bytes)):
|
|
304
|
+
for attr_name, t, keyword in _str_types_attrs:
|
|
305
|
+
attr = getattr(field.field_info, attr_name, None)
|
|
306
|
+
if isinstance(attr, t):
|
|
307
|
+
f_schema[keyword] = attr
|
|
308
|
+
if lenient_issubclass(field.type_, numeric_types) and not issubclass(field.type_, bool):
|
|
309
|
+
for attr_name, t, keyword in _numeric_types_attrs:
|
|
310
|
+
attr = getattr(field.field_info, attr_name, None)
|
|
311
|
+
if isinstance(attr, t):
|
|
312
|
+
f_schema[keyword] = attr
|
|
313
|
+
if field.field_info is not None and field.field_info.const:
|
|
314
|
+
f_schema['const'] = field.default
|
|
315
|
+
if field.field_info.extra:
|
|
316
|
+
f_schema.update(field.field_info.extra)
|
|
317
|
+
modify_schema = getattr(field.outer_type_, '__modify_schema__', None)
|
|
318
|
+
if modify_schema:
|
|
319
|
+
_apply_modify_schema(modify_schema, field, f_schema)
|
|
320
|
+
return f_schema
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def get_model_name_map(unique_models: TypeModelSet) -> Dict[TypeModelOrEnum, str]:
|
|
324
|
+
"""
|
|
325
|
+
Process a set of models and generate unique names for them to be used as keys in the JSON Schema
|
|
326
|
+
definitions. By default the names are the same as the class name. But if two models in different Python
|
|
327
|
+
modules have the same name (e.g. "users.Model" and "items.Model"), the generated names will be
|
|
328
|
+
based on the Python module path for those conflicting models to prevent name collisions.
|
|
329
|
+
|
|
330
|
+
:param unique_models: a Python set of models
|
|
331
|
+
:return: dict mapping models to names
|
|
332
|
+
"""
|
|
333
|
+
name_model_map = {}
|
|
334
|
+
conflicting_names: Set[str] = set()
|
|
335
|
+
for model in unique_models:
|
|
336
|
+
model_name = normalize_name(model.__name__)
|
|
337
|
+
if model_name in conflicting_names:
|
|
338
|
+
model_name = get_long_model_name(model)
|
|
339
|
+
name_model_map[model_name] = model
|
|
340
|
+
elif model_name in name_model_map:
|
|
341
|
+
conflicting_names.add(model_name)
|
|
342
|
+
conflicting_model = name_model_map.pop(model_name)
|
|
343
|
+
name_model_map[get_long_model_name(conflicting_model)] = conflicting_model
|
|
344
|
+
name_model_map[get_long_model_name(model)] = model
|
|
345
|
+
else:
|
|
346
|
+
name_model_map[model_name] = model
|
|
347
|
+
return {v: k for k, v in name_model_map.items()}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def get_flat_models_from_model(model: Type['BaseModel'], known_models: Optional[TypeModelSet] = None) -> TypeModelSet:
|
|
351
|
+
"""
|
|
352
|
+
Take a single ``model`` and generate a set with itself and all the sub-models in the tree. I.e. if you pass
|
|
353
|
+
model ``Foo`` (subclass of Pydantic ``BaseModel``) as ``model``, and it has a field of type ``Bar`` (also
|
|
354
|
+
subclass of ``BaseModel``) and that model ``Bar`` has a field of type ``Baz`` (also subclass of ``BaseModel``),
|
|
355
|
+
the return value will be ``set([Foo, Bar, Baz])``.
|
|
356
|
+
|
|
357
|
+
:param model: a Pydantic ``BaseModel`` subclass
|
|
358
|
+
:param known_models: used to solve circular references
|
|
359
|
+
:return: a set with the initial model and all its sub-models
|
|
360
|
+
"""
|
|
361
|
+
known_models = known_models or set()
|
|
362
|
+
flat_models: TypeModelSet = set()
|
|
363
|
+
flat_models.add(model)
|
|
364
|
+
known_models |= flat_models
|
|
365
|
+
fields = cast(Sequence[ModelField], model.__fields__.values())
|
|
366
|
+
flat_models |= get_flat_models_from_fields(fields, known_models=known_models)
|
|
367
|
+
return flat_models
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def get_flat_models_from_field(field: ModelField, known_models: TypeModelSet) -> TypeModelSet:
|
|
371
|
+
"""
|
|
372
|
+
Take a single Pydantic ``ModelField`` (from a model) that could have been declared as a subclass of BaseModel
|
|
373
|
+
(so, it could be a submodel), and generate a set with its model and all the sub-models in the tree.
|
|
374
|
+
I.e. if you pass a field that was declared to be of type ``Foo`` (subclass of BaseModel) as ``field``, and that
|
|
375
|
+
model ``Foo`` has a field of type ``Bar`` (also subclass of ``BaseModel``) and that model ``Bar`` has a field of
|
|
376
|
+
type ``Baz`` (also subclass of ``BaseModel``), the return value will be ``set([Foo, Bar, Baz])``.
|
|
377
|
+
|
|
378
|
+
:param field: a Pydantic ``ModelField``
|
|
379
|
+
:param known_models: used to solve circular references
|
|
380
|
+
:return: a set with the model used in the declaration for this field, if any, and all its sub-models
|
|
381
|
+
"""
|
|
382
|
+
from .main import BaseModel
|
|
383
|
+
|
|
384
|
+
flat_models: TypeModelSet = set()
|
|
385
|
+
|
|
386
|
+
field_type = field.type_
|
|
387
|
+
if lenient_issubclass(getattr(field_type, '__pydantic_model__', None), BaseModel):
|
|
388
|
+
field_type = field_type.__pydantic_model__
|
|
389
|
+
|
|
390
|
+
if field.sub_fields and not lenient_issubclass(field_type, BaseModel):
|
|
391
|
+
flat_models |= get_flat_models_from_fields(field.sub_fields, known_models=known_models)
|
|
392
|
+
elif lenient_issubclass(field_type, BaseModel) and field_type not in known_models:
|
|
393
|
+
flat_models |= get_flat_models_from_model(field_type, known_models=known_models)
|
|
394
|
+
elif lenient_issubclass(field_type, Enum):
|
|
395
|
+
flat_models.add(field_type)
|
|
396
|
+
return flat_models
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def get_flat_models_from_fields(fields: Sequence[ModelField], known_models: TypeModelSet) -> TypeModelSet:
|
|
400
|
+
"""
|
|
401
|
+
Take a list of Pydantic ``ModelField``s (from a model) that could have been declared as subclasses of ``BaseModel``
|
|
402
|
+
(so, any of them could be a submodel), and generate a set with their models and all the sub-models in the tree.
|
|
403
|
+
I.e. if you pass a the fields of a model ``Foo`` (subclass of ``BaseModel``) as ``fields``, and on of them has a
|
|
404
|
+
field of type ``Bar`` (also subclass of ``BaseModel``) and that model ``Bar`` has a field of type ``Baz`` (also
|
|
405
|
+
subclass of ``BaseModel``), the return value will be ``set([Foo, Bar, Baz])``.
|
|
406
|
+
|
|
407
|
+
:param fields: a list of Pydantic ``ModelField``s
|
|
408
|
+
:param known_models: used to solve circular references
|
|
409
|
+
:return: a set with any model declared in the fields, and all their sub-models
|
|
410
|
+
"""
|
|
411
|
+
flat_models: TypeModelSet = set()
|
|
412
|
+
for field in fields:
|
|
413
|
+
flat_models |= get_flat_models_from_field(field, known_models=known_models)
|
|
414
|
+
return flat_models
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def get_flat_models_from_models(models: Sequence[Type['BaseModel']]) -> TypeModelSet:
|
|
418
|
+
"""
|
|
419
|
+
Take a list of ``models`` and generate a set with them and all their sub-models in their trees. I.e. if you pass
|
|
420
|
+
a list of two models, ``Foo`` and ``Bar``, both subclasses of Pydantic ``BaseModel`` as models, and ``Bar`` has
|
|
421
|
+
a field of type ``Baz`` (also subclass of ``BaseModel``), the return value will be ``set([Foo, Bar, Baz])``.
|
|
422
|
+
"""
|
|
423
|
+
flat_models: TypeModelSet = set()
|
|
424
|
+
for model in models:
|
|
425
|
+
flat_models |= get_flat_models_from_model(model)
|
|
426
|
+
return flat_models
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def get_long_model_name(model: TypeModelOrEnum) -> str:
|
|
430
|
+
return f'{model.__module__}__{model.__qualname__}'.replace('.', '__')
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def field_type_schema(
|
|
434
|
+
field: ModelField,
|
|
435
|
+
*,
|
|
436
|
+
by_alias: bool,
|
|
437
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
438
|
+
ref_template: str,
|
|
439
|
+
schema_overrides: bool = False,
|
|
440
|
+
ref_prefix: Optional[str] = None,
|
|
441
|
+
known_models: TypeModelSet,
|
|
442
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
443
|
+
"""
|
|
444
|
+
Used by ``field_schema()``, you probably should be using that function.
|
|
445
|
+
|
|
446
|
+
Take a single ``field`` and generate the schema for its type only, not including additional
|
|
447
|
+
information as title, etc. Also return additional schema definitions, from sub-models.
|
|
448
|
+
"""
|
|
449
|
+
from .main import BaseModel # noqa: F811
|
|
450
|
+
|
|
451
|
+
definitions = {}
|
|
452
|
+
nested_models: Set[str] = set()
|
|
453
|
+
f_schema: Dict[str, Any]
|
|
454
|
+
if field.shape in {
|
|
455
|
+
SHAPE_LIST,
|
|
456
|
+
SHAPE_TUPLE_ELLIPSIS,
|
|
457
|
+
SHAPE_SEQUENCE,
|
|
458
|
+
SHAPE_SET,
|
|
459
|
+
SHAPE_FROZENSET,
|
|
460
|
+
SHAPE_ITERABLE,
|
|
461
|
+
SHAPE_DEQUE,
|
|
462
|
+
}:
|
|
463
|
+
items_schema, f_definitions, f_nested_models = field_singleton_schema(
|
|
464
|
+
field,
|
|
465
|
+
by_alias=by_alias,
|
|
466
|
+
model_name_map=model_name_map,
|
|
467
|
+
ref_prefix=ref_prefix,
|
|
468
|
+
ref_template=ref_template,
|
|
469
|
+
known_models=known_models,
|
|
470
|
+
)
|
|
471
|
+
definitions.update(f_definitions)
|
|
472
|
+
nested_models.update(f_nested_models)
|
|
473
|
+
f_schema = {'type': 'array', 'items': items_schema}
|
|
474
|
+
if field.shape in {SHAPE_SET, SHAPE_FROZENSET}:
|
|
475
|
+
f_schema['uniqueItems'] = True
|
|
476
|
+
|
|
477
|
+
elif field.shape in MAPPING_LIKE_SHAPES:
|
|
478
|
+
f_schema = {'type': 'object'}
|
|
479
|
+
key_field = cast(ModelField, field.key_field)
|
|
480
|
+
regex = getattr(key_field.type_, 'regex', None)
|
|
481
|
+
items_schema, f_definitions, f_nested_models = field_singleton_schema(
|
|
482
|
+
field,
|
|
483
|
+
by_alias=by_alias,
|
|
484
|
+
model_name_map=model_name_map,
|
|
485
|
+
ref_prefix=ref_prefix,
|
|
486
|
+
ref_template=ref_template,
|
|
487
|
+
known_models=known_models,
|
|
488
|
+
)
|
|
489
|
+
definitions.update(f_definitions)
|
|
490
|
+
nested_models.update(f_nested_models)
|
|
491
|
+
if regex:
|
|
492
|
+
# Dict keys have a regex pattern
|
|
493
|
+
# items_schema might be a schema or empty dict, add it either way
|
|
494
|
+
f_schema['patternProperties'] = {ConstrainedStr._get_pattern(regex): items_schema}
|
|
495
|
+
if items_schema:
|
|
496
|
+
# The dict values are not simply Any, so they need a schema
|
|
497
|
+
f_schema['additionalProperties'] = items_schema
|
|
498
|
+
elif field.shape == SHAPE_TUPLE or (field.shape == SHAPE_GENERIC and not issubclass(field.type_, BaseModel)):
|
|
499
|
+
sub_schema = []
|
|
500
|
+
sub_fields = cast(List[ModelField], field.sub_fields)
|
|
501
|
+
for sf in sub_fields:
|
|
502
|
+
sf_schema, sf_definitions, sf_nested_models = field_type_schema(
|
|
503
|
+
sf,
|
|
504
|
+
by_alias=by_alias,
|
|
505
|
+
model_name_map=model_name_map,
|
|
506
|
+
ref_prefix=ref_prefix,
|
|
507
|
+
ref_template=ref_template,
|
|
508
|
+
known_models=known_models,
|
|
509
|
+
)
|
|
510
|
+
definitions.update(sf_definitions)
|
|
511
|
+
nested_models.update(sf_nested_models)
|
|
512
|
+
sub_schema.append(sf_schema)
|
|
513
|
+
|
|
514
|
+
sub_fields_len = len(sub_fields)
|
|
515
|
+
if field.shape == SHAPE_GENERIC:
|
|
516
|
+
all_of_schemas = sub_schema[0] if sub_fields_len == 1 else {'type': 'array', 'items': sub_schema}
|
|
517
|
+
f_schema = {'allOf': [all_of_schemas]}
|
|
518
|
+
else:
|
|
519
|
+
f_schema = {
|
|
520
|
+
'type': 'array',
|
|
521
|
+
'minItems': sub_fields_len,
|
|
522
|
+
'maxItems': sub_fields_len,
|
|
523
|
+
}
|
|
524
|
+
if sub_fields_len >= 1:
|
|
525
|
+
f_schema['items'] = sub_schema
|
|
526
|
+
else:
|
|
527
|
+
assert field.shape in {SHAPE_SINGLETON, SHAPE_GENERIC}, field.shape
|
|
528
|
+
f_schema, f_definitions, f_nested_models = field_singleton_schema(
|
|
529
|
+
field,
|
|
530
|
+
by_alias=by_alias,
|
|
531
|
+
model_name_map=model_name_map,
|
|
532
|
+
schema_overrides=schema_overrides,
|
|
533
|
+
ref_prefix=ref_prefix,
|
|
534
|
+
ref_template=ref_template,
|
|
535
|
+
known_models=known_models,
|
|
536
|
+
)
|
|
537
|
+
definitions.update(f_definitions)
|
|
538
|
+
nested_models.update(f_nested_models)
|
|
539
|
+
|
|
540
|
+
# check field type to avoid repeated calls to the same __modify_schema__ method
|
|
541
|
+
if field.type_ != field.outer_type_:
|
|
542
|
+
if field.shape == SHAPE_GENERIC:
|
|
543
|
+
field_type = field.type_
|
|
544
|
+
else:
|
|
545
|
+
field_type = field.outer_type_
|
|
546
|
+
modify_schema = getattr(field_type, '__modify_schema__', None)
|
|
547
|
+
if modify_schema:
|
|
548
|
+
_apply_modify_schema(modify_schema, field, f_schema)
|
|
549
|
+
return f_schema, definitions, nested_models
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
def model_process_schema(
|
|
553
|
+
model: TypeModelOrEnum,
|
|
554
|
+
*,
|
|
555
|
+
by_alias: bool = True,
|
|
556
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
557
|
+
ref_prefix: Optional[str] = None,
|
|
558
|
+
ref_template: str = default_ref_template,
|
|
559
|
+
known_models: Optional[TypeModelSet] = None,
|
|
560
|
+
field: Optional[ModelField] = None,
|
|
561
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
562
|
+
"""
|
|
563
|
+
Used by ``model_schema()``, you probably should be using that function.
|
|
564
|
+
|
|
565
|
+
Take a single ``model`` and generate its schema. Also return additional schema definitions, from sub-models. The
|
|
566
|
+
sub-models of the returned schema will be referenced, but their definitions will not be included in the schema. All
|
|
567
|
+
the definitions are returned as the second value.
|
|
568
|
+
"""
|
|
569
|
+
from inspect import getdoc, signature
|
|
570
|
+
|
|
571
|
+
known_models = known_models or set()
|
|
572
|
+
if lenient_issubclass(model, Enum):
|
|
573
|
+
model = cast(Type[Enum], model)
|
|
574
|
+
s = enum_process_schema(model, field=field)
|
|
575
|
+
return s, {}, set()
|
|
576
|
+
model = cast(Type['BaseModel'], model)
|
|
577
|
+
s = {'title': model.__config__.title or model.__name__}
|
|
578
|
+
doc = getdoc(model)
|
|
579
|
+
if doc:
|
|
580
|
+
s['description'] = doc
|
|
581
|
+
known_models.add(model)
|
|
582
|
+
m_schema, m_definitions, nested_models = model_type_schema(
|
|
583
|
+
model,
|
|
584
|
+
by_alias=by_alias,
|
|
585
|
+
model_name_map=model_name_map,
|
|
586
|
+
ref_prefix=ref_prefix,
|
|
587
|
+
ref_template=ref_template,
|
|
588
|
+
known_models=known_models,
|
|
589
|
+
)
|
|
590
|
+
s.update(m_schema)
|
|
591
|
+
schema_extra = model.__config__.schema_extra
|
|
592
|
+
if callable(schema_extra):
|
|
593
|
+
if len(signature(schema_extra).parameters) == 1:
|
|
594
|
+
schema_extra(s)
|
|
595
|
+
else:
|
|
596
|
+
schema_extra(s, model)
|
|
597
|
+
else:
|
|
598
|
+
s.update(schema_extra)
|
|
599
|
+
return s, m_definitions, nested_models
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def model_type_schema(
|
|
603
|
+
model: Type['BaseModel'],
|
|
604
|
+
*,
|
|
605
|
+
by_alias: bool,
|
|
606
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
607
|
+
ref_template: str,
|
|
608
|
+
ref_prefix: Optional[str] = None,
|
|
609
|
+
known_models: TypeModelSet,
|
|
610
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
611
|
+
"""
|
|
612
|
+
You probably should be using ``model_schema()``, this function is indirectly used by that function.
|
|
613
|
+
|
|
614
|
+
Take a single ``model`` and generate the schema for its type only, not including additional
|
|
615
|
+
information as title, etc. Also return additional schema definitions, from sub-models.
|
|
616
|
+
"""
|
|
617
|
+
properties = {}
|
|
618
|
+
required = []
|
|
619
|
+
definitions: Dict[str, Any] = {}
|
|
620
|
+
nested_models: Set[str] = set()
|
|
621
|
+
for k, f in model.__fields__.items():
|
|
622
|
+
try:
|
|
623
|
+
f_schema, f_definitions, f_nested_models = field_schema(
|
|
624
|
+
f,
|
|
625
|
+
by_alias=by_alias,
|
|
626
|
+
model_name_map=model_name_map,
|
|
627
|
+
ref_prefix=ref_prefix,
|
|
628
|
+
ref_template=ref_template,
|
|
629
|
+
known_models=known_models,
|
|
630
|
+
)
|
|
631
|
+
except SkipField as skip:
|
|
632
|
+
warnings.warn(skip.message, UserWarning)
|
|
633
|
+
continue
|
|
634
|
+
definitions.update(f_definitions)
|
|
635
|
+
nested_models.update(f_nested_models)
|
|
636
|
+
if by_alias:
|
|
637
|
+
properties[f.alias] = f_schema
|
|
638
|
+
if f.required:
|
|
639
|
+
required.append(f.alias)
|
|
640
|
+
else:
|
|
641
|
+
properties[k] = f_schema
|
|
642
|
+
if f.required:
|
|
643
|
+
required.append(k)
|
|
644
|
+
if ROOT_KEY in properties:
|
|
645
|
+
out_schema = properties[ROOT_KEY]
|
|
646
|
+
out_schema['title'] = model.__config__.title or model.__name__
|
|
647
|
+
else:
|
|
648
|
+
out_schema = {'type': 'object', 'properties': properties}
|
|
649
|
+
if required:
|
|
650
|
+
out_schema['required'] = required
|
|
651
|
+
if model.__config__.extra == 'forbid':
|
|
652
|
+
out_schema['additionalProperties'] = False
|
|
653
|
+
return out_schema, definitions, nested_models
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
def enum_process_schema(enum: Type[Enum], *, field: Optional[ModelField] = None) -> Dict[str, Any]:
|
|
657
|
+
"""
|
|
658
|
+
Take a single `enum` and generate its schema.
|
|
659
|
+
|
|
660
|
+
This is similar to the `model_process_schema` function, but applies to ``Enum`` objects.
|
|
661
|
+
"""
|
|
662
|
+
import inspect
|
|
663
|
+
|
|
664
|
+
schema_: Dict[str, Any] = {
|
|
665
|
+
'title': enum.__name__,
|
|
666
|
+
# Python assigns all enums a default docstring value of 'An enumeration', so
|
|
667
|
+
# all enums will have a description field even if not explicitly provided.
|
|
668
|
+
'description': inspect.cleandoc(enum.__doc__ or 'An enumeration.'),
|
|
669
|
+
# Add enum values and the enum field type to the schema.
|
|
670
|
+
'enum': [item.value for item in cast(Iterable[Enum], enum)],
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
add_field_type_to_schema(enum, schema_)
|
|
674
|
+
|
|
675
|
+
modify_schema = getattr(enum, '__modify_schema__', None)
|
|
676
|
+
if modify_schema:
|
|
677
|
+
_apply_modify_schema(modify_schema, field, schema_)
|
|
678
|
+
|
|
679
|
+
return schema_
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
def field_singleton_sub_fields_schema(
|
|
683
|
+
field: ModelField,
|
|
684
|
+
*,
|
|
685
|
+
by_alias: bool,
|
|
686
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
687
|
+
ref_template: str,
|
|
688
|
+
schema_overrides: bool = False,
|
|
689
|
+
ref_prefix: Optional[str] = None,
|
|
690
|
+
known_models: TypeModelSet,
|
|
691
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
692
|
+
"""
|
|
693
|
+
This function is indirectly used by ``field_schema()``, you probably should be using that function.
|
|
694
|
+
|
|
695
|
+
Take a list of Pydantic ``ModelField`` from the declaration of a type with parameters, and generate their
|
|
696
|
+
schema. I.e., fields used as "type parameters", like ``str`` and ``int`` in ``Tuple[str, int]``.
|
|
697
|
+
"""
|
|
698
|
+
sub_fields = cast(List[ModelField], field.sub_fields)
|
|
699
|
+
definitions = {}
|
|
700
|
+
nested_models: Set[str] = set()
|
|
701
|
+
if len(sub_fields) == 1:
|
|
702
|
+
return field_type_schema(
|
|
703
|
+
sub_fields[0],
|
|
704
|
+
by_alias=by_alias,
|
|
705
|
+
model_name_map=model_name_map,
|
|
706
|
+
schema_overrides=schema_overrides,
|
|
707
|
+
ref_prefix=ref_prefix,
|
|
708
|
+
ref_template=ref_template,
|
|
709
|
+
known_models=known_models,
|
|
710
|
+
)
|
|
711
|
+
else:
|
|
712
|
+
s: Dict[str, Any] = {}
|
|
713
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminator-object
|
|
714
|
+
field_has_discriminator: bool = field.discriminator_key is not None
|
|
715
|
+
if field_has_discriminator:
|
|
716
|
+
assert field.sub_fields_mapping is not None
|
|
717
|
+
|
|
718
|
+
discriminator_models_refs: Dict[str, Union[str, Dict[str, Any]]] = {}
|
|
719
|
+
|
|
720
|
+
for discriminator_value, sub_field in field.sub_fields_mapping.items():
|
|
721
|
+
if isinstance(discriminator_value, Enum):
|
|
722
|
+
discriminator_value = str(discriminator_value.value)
|
|
723
|
+
# sub_field is either a `BaseModel` or directly an `Annotated` `Union` of many
|
|
724
|
+
if is_union(get_origin(sub_field.type_)):
|
|
725
|
+
sub_models = get_sub_types(sub_field.type_)
|
|
726
|
+
discriminator_models_refs[discriminator_value] = {
|
|
727
|
+
model_name_map[sub_model]: get_schema_ref(
|
|
728
|
+
model_name_map[sub_model], ref_prefix, ref_template, False
|
|
729
|
+
)
|
|
730
|
+
for sub_model in sub_models
|
|
731
|
+
}
|
|
732
|
+
else:
|
|
733
|
+
sub_field_type = sub_field.type_
|
|
734
|
+
if hasattr(sub_field_type, '__pydantic_model__'):
|
|
735
|
+
sub_field_type = sub_field_type.__pydantic_model__
|
|
736
|
+
|
|
737
|
+
discriminator_model_name = model_name_map[sub_field_type]
|
|
738
|
+
discriminator_model_ref = get_schema_ref(discriminator_model_name, ref_prefix, ref_template, False)
|
|
739
|
+
discriminator_models_refs[discriminator_value] = discriminator_model_ref['$ref']
|
|
740
|
+
|
|
741
|
+
s['discriminator'] = {
|
|
742
|
+
'propertyName': field.discriminator_alias,
|
|
743
|
+
'mapping': discriminator_models_refs,
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
sub_field_schemas = []
|
|
747
|
+
for sf in sub_fields:
|
|
748
|
+
sub_schema, sub_definitions, sub_nested_models = field_type_schema(
|
|
749
|
+
sf,
|
|
750
|
+
by_alias=by_alias,
|
|
751
|
+
model_name_map=model_name_map,
|
|
752
|
+
schema_overrides=schema_overrides,
|
|
753
|
+
ref_prefix=ref_prefix,
|
|
754
|
+
ref_template=ref_template,
|
|
755
|
+
known_models=known_models,
|
|
756
|
+
)
|
|
757
|
+
definitions.update(sub_definitions)
|
|
758
|
+
if schema_overrides and 'allOf' in sub_schema:
|
|
759
|
+
# if the sub_field is a referenced schema we only need the referenced
|
|
760
|
+
# object. Otherwise we will end up with several allOf inside anyOf/oneOf.
|
|
761
|
+
# See https://github.com/pydantic/pydantic/issues/1209
|
|
762
|
+
sub_schema = sub_schema['allOf'][0]
|
|
763
|
+
|
|
764
|
+
if sub_schema.keys() == {'discriminator', 'oneOf'}:
|
|
765
|
+
# we don't want discriminator information inside oneOf choices, this is dealt with elsewhere
|
|
766
|
+
sub_schema.pop('discriminator')
|
|
767
|
+
sub_field_schemas.append(sub_schema)
|
|
768
|
+
nested_models.update(sub_nested_models)
|
|
769
|
+
s['oneOf' if field_has_discriminator else 'anyOf'] = sub_field_schemas
|
|
770
|
+
return s, definitions, nested_models
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
# Order is important, e.g. subclasses of str must go before str
|
|
774
|
+
# this is used only for standard library types, custom types should use __modify_schema__ instead
|
|
775
|
+
field_class_to_schema: Tuple[Tuple[Any, Dict[str, Any]], ...] = (
|
|
776
|
+
(Path, {'type': 'string', 'format': 'path'}),
|
|
777
|
+
(datetime, {'type': 'string', 'format': 'date-time'}),
|
|
778
|
+
(date, {'type': 'string', 'format': 'date'}),
|
|
779
|
+
(time, {'type': 'string', 'format': 'time'}),
|
|
780
|
+
(timedelta, {'type': 'number', 'format': 'time-delta'}),
|
|
781
|
+
(IPv4Network, {'type': 'string', 'format': 'ipv4network'}),
|
|
782
|
+
(IPv6Network, {'type': 'string', 'format': 'ipv6network'}),
|
|
783
|
+
(IPv4Interface, {'type': 'string', 'format': 'ipv4interface'}),
|
|
784
|
+
(IPv6Interface, {'type': 'string', 'format': 'ipv6interface'}),
|
|
785
|
+
(IPv4Address, {'type': 'string', 'format': 'ipv4'}),
|
|
786
|
+
(IPv6Address, {'type': 'string', 'format': 'ipv6'}),
|
|
787
|
+
(Pattern, {'type': 'string', 'format': 'regex'}),
|
|
788
|
+
(str, {'type': 'string'}),
|
|
789
|
+
(bytes, {'type': 'string', 'format': 'binary'}),
|
|
790
|
+
(bool, {'type': 'boolean'}),
|
|
791
|
+
(int, {'type': 'integer'}),
|
|
792
|
+
(float, {'type': 'number'}),
|
|
793
|
+
(Decimal, {'type': 'number'}),
|
|
794
|
+
(UUID, {'type': 'string', 'format': 'uuid'}),
|
|
795
|
+
(dict, {'type': 'object'}),
|
|
796
|
+
(list, {'type': 'array', 'items': {}}),
|
|
797
|
+
(tuple, {'type': 'array', 'items': {}}),
|
|
798
|
+
(set, {'type': 'array', 'items': {}, 'uniqueItems': True}),
|
|
799
|
+
(frozenset, {'type': 'array', 'items': {}, 'uniqueItems': True}),
|
|
800
|
+
)
|
|
801
|
+
|
|
802
|
+
json_scheme = {'type': 'string', 'format': 'json-string'}
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
def add_field_type_to_schema(field_type: Any, schema_: Dict[str, Any]) -> None:
|
|
806
|
+
"""
|
|
807
|
+
Update the given `schema` with the type-specific metadata for the given `field_type`.
|
|
808
|
+
|
|
809
|
+
This function looks through `field_class_to_schema` for a class that matches the given `field_type`,
|
|
810
|
+
and then modifies the given `schema` with the information from that type.
|
|
811
|
+
"""
|
|
812
|
+
for type_, t_schema in field_class_to_schema:
|
|
813
|
+
# Fallback for `typing.Pattern` and `re.Pattern` as they are not a valid class
|
|
814
|
+
if lenient_issubclass(field_type, type_) or field_type is type_ is Pattern:
|
|
815
|
+
schema_.update(t_schema)
|
|
816
|
+
break
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def get_schema_ref(name: str, ref_prefix: Optional[str], ref_template: str, schema_overrides: bool) -> Dict[str, Any]:
|
|
820
|
+
if ref_prefix:
|
|
821
|
+
schema_ref = {'$ref': ref_prefix + name}
|
|
822
|
+
else:
|
|
823
|
+
schema_ref = {'$ref': ref_template.format(model=name)}
|
|
824
|
+
return {'allOf': [schema_ref]} if schema_overrides else schema_ref
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
def field_singleton_schema( # noqa: C901 (ignore complexity)
|
|
828
|
+
field: ModelField,
|
|
829
|
+
*,
|
|
830
|
+
by_alias: bool,
|
|
831
|
+
model_name_map: Dict[TypeModelOrEnum, str],
|
|
832
|
+
ref_template: str,
|
|
833
|
+
schema_overrides: bool = False,
|
|
834
|
+
ref_prefix: Optional[str] = None,
|
|
835
|
+
known_models: TypeModelSet,
|
|
836
|
+
) -> Tuple[Dict[str, Any], Dict[str, Any], Set[str]]:
|
|
837
|
+
"""
|
|
838
|
+
This function is indirectly used by ``field_schema()``, you should probably be using that function.
|
|
839
|
+
|
|
840
|
+
Take a single Pydantic ``ModelField``, and return its schema and any additional definitions from sub-models.
|
|
841
|
+
"""
|
|
842
|
+
from .main import BaseModel
|
|
843
|
+
|
|
844
|
+
definitions: Dict[str, Any] = {}
|
|
845
|
+
nested_models: Set[str] = set()
|
|
846
|
+
field_type = field.type_
|
|
847
|
+
|
|
848
|
+
# Recurse into this field if it contains sub_fields and is NOT a
|
|
849
|
+
# BaseModel OR that BaseModel is a const
|
|
850
|
+
if field.sub_fields and (
|
|
851
|
+
(field.field_info and field.field_info.const) or not lenient_issubclass(field_type, BaseModel)
|
|
852
|
+
):
|
|
853
|
+
return field_singleton_sub_fields_schema(
|
|
854
|
+
field,
|
|
855
|
+
by_alias=by_alias,
|
|
856
|
+
model_name_map=model_name_map,
|
|
857
|
+
schema_overrides=schema_overrides,
|
|
858
|
+
ref_prefix=ref_prefix,
|
|
859
|
+
ref_template=ref_template,
|
|
860
|
+
known_models=known_models,
|
|
861
|
+
)
|
|
862
|
+
if field_type is Any or field_type is object or field_type.__class__ == TypeVar or get_origin(field_type) is type:
|
|
863
|
+
return {}, definitions, nested_models # no restrictions
|
|
864
|
+
if is_none_type(field_type):
|
|
865
|
+
return {'type': 'null'}, definitions, nested_models
|
|
866
|
+
if is_callable_type(field_type):
|
|
867
|
+
raise SkipField(f'Callable {field.name} was excluded from schema since JSON schema has no equivalent type.')
|
|
868
|
+
f_schema: Dict[str, Any] = {}
|
|
869
|
+
if field.field_info is not None and field.field_info.const:
|
|
870
|
+
f_schema['const'] = field.default
|
|
871
|
+
|
|
872
|
+
if is_literal_type(field_type):
|
|
873
|
+
values = tuple(x.value if isinstance(x, Enum) else x for x in all_literal_values(field_type))
|
|
874
|
+
|
|
875
|
+
if len({v.__class__ for v in values}) > 1:
|
|
876
|
+
return field_schema(
|
|
877
|
+
multitypes_literal_field_for_schema(values, field),
|
|
878
|
+
by_alias=by_alias,
|
|
879
|
+
model_name_map=model_name_map,
|
|
880
|
+
ref_prefix=ref_prefix,
|
|
881
|
+
ref_template=ref_template,
|
|
882
|
+
known_models=known_models,
|
|
883
|
+
)
|
|
884
|
+
|
|
885
|
+
# All values have the same type
|
|
886
|
+
field_type = values[0].__class__
|
|
887
|
+
f_schema['enum'] = list(values)
|
|
888
|
+
add_field_type_to_schema(field_type, f_schema)
|
|
889
|
+
elif lenient_issubclass(field_type, Enum):
|
|
890
|
+
enum_name = model_name_map[field_type]
|
|
891
|
+
f_schema, schema_overrides = get_field_info_schema(field, schema_overrides)
|
|
892
|
+
f_schema.update(get_schema_ref(enum_name, ref_prefix, ref_template, schema_overrides))
|
|
893
|
+
definitions[enum_name] = enum_process_schema(field_type, field=field)
|
|
894
|
+
elif is_namedtuple(field_type):
|
|
895
|
+
sub_schema, *_ = model_process_schema(
|
|
896
|
+
field_type.__pydantic_model__,
|
|
897
|
+
by_alias=by_alias,
|
|
898
|
+
model_name_map=model_name_map,
|
|
899
|
+
ref_prefix=ref_prefix,
|
|
900
|
+
ref_template=ref_template,
|
|
901
|
+
known_models=known_models,
|
|
902
|
+
field=field,
|
|
903
|
+
)
|
|
904
|
+
items_schemas = list(sub_schema['properties'].values())
|
|
905
|
+
f_schema.update(
|
|
906
|
+
{
|
|
907
|
+
'type': 'array',
|
|
908
|
+
'items': items_schemas,
|
|
909
|
+
'minItems': len(items_schemas),
|
|
910
|
+
'maxItems': len(items_schemas),
|
|
911
|
+
}
|
|
912
|
+
)
|
|
913
|
+
elif not hasattr(field_type, '__pydantic_model__'):
|
|
914
|
+
add_field_type_to_schema(field_type, f_schema)
|
|
915
|
+
|
|
916
|
+
modify_schema = getattr(field_type, '__modify_schema__', None)
|
|
917
|
+
if modify_schema:
|
|
918
|
+
_apply_modify_schema(modify_schema, field, f_schema)
|
|
919
|
+
|
|
920
|
+
if f_schema:
|
|
921
|
+
return f_schema, definitions, nested_models
|
|
922
|
+
|
|
923
|
+
# Handle dataclass-based models
|
|
924
|
+
if lenient_issubclass(getattr(field_type, '__pydantic_model__', None), BaseModel):
|
|
925
|
+
field_type = field_type.__pydantic_model__
|
|
926
|
+
|
|
927
|
+
if issubclass(field_type, BaseModel):
|
|
928
|
+
model_name = model_name_map[field_type]
|
|
929
|
+
if field_type not in known_models:
|
|
930
|
+
sub_schema, sub_definitions, sub_nested_models = model_process_schema(
|
|
931
|
+
field_type,
|
|
932
|
+
by_alias=by_alias,
|
|
933
|
+
model_name_map=model_name_map,
|
|
934
|
+
ref_prefix=ref_prefix,
|
|
935
|
+
ref_template=ref_template,
|
|
936
|
+
known_models=known_models,
|
|
937
|
+
field=field,
|
|
938
|
+
)
|
|
939
|
+
definitions.update(sub_definitions)
|
|
940
|
+
definitions[model_name] = sub_schema
|
|
941
|
+
nested_models.update(sub_nested_models)
|
|
942
|
+
else:
|
|
943
|
+
nested_models.add(model_name)
|
|
944
|
+
schema_ref = get_schema_ref(model_name, ref_prefix, ref_template, schema_overrides)
|
|
945
|
+
return schema_ref, definitions, nested_models
|
|
946
|
+
|
|
947
|
+
# For generics with no args
|
|
948
|
+
args = get_args(field_type)
|
|
949
|
+
if args is not None and not args and Generic in field_type.__bases__:
|
|
950
|
+
return f_schema, definitions, nested_models
|
|
951
|
+
|
|
952
|
+
raise ValueError(f'Value not declarable with JSON Schema, field: {field}')
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
def multitypes_literal_field_for_schema(values: Tuple[Any, ...], field: ModelField) -> ModelField:
|
|
956
|
+
"""
|
|
957
|
+
To support `Literal` with values of different types, we split it into multiple `Literal` with same type
|
|
958
|
+
e.g. `Literal['qwe', 'asd', 1, 2]` becomes `Union[Literal['qwe', 'asd'], Literal[1, 2]]`
|
|
959
|
+
"""
|
|
960
|
+
literal_distinct_types = defaultdict(list)
|
|
961
|
+
for v in values:
|
|
962
|
+
literal_distinct_types[v.__class__].append(v)
|
|
963
|
+
distinct_literals = (Literal[tuple(same_type_values)] for same_type_values in literal_distinct_types.values())
|
|
964
|
+
|
|
965
|
+
return ModelField(
|
|
966
|
+
name=field.name,
|
|
967
|
+
type_=Union[tuple(distinct_literals)], # type: ignore
|
|
968
|
+
class_validators=field.class_validators,
|
|
969
|
+
model_config=field.model_config,
|
|
970
|
+
default=field.default,
|
|
971
|
+
required=field.required,
|
|
972
|
+
alias=field.alias,
|
|
973
|
+
field_info=field.field_info,
|
|
974
|
+
)
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
def encode_default(dft: Any) -> Any:
|
|
978
|
+
from .main import BaseModel
|
|
979
|
+
|
|
980
|
+
if isinstance(dft, BaseModel) or is_dataclass(dft):
|
|
981
|
+
dft = cast('dict[str, Any]', pydantic_encoder(dft))
|
|
982
|
+
|
|
983
|
+
if isinstance(dft, dict):
|
|
984
|
+
return {encode_default(k): encode_default(v) for k, v in dft.items()}
|
|
985
|
+
elif isinstance(dft, Enum):
|
|
986
|
+
return dft.value
|
|
987
|
+
elif isinstance(dft, (int, float, str)):
|
|
988
|
+
return dft
|
|
989
|
+
elif isinstance(dft, (list, tuple)):
|
|
990
|
+
t = dft.__class__
|
|
991
|
+
seq_args = (encode_default(v) for v in dft)
|
|
992
|
+
return t(*seq_args) if is_namedtuple(t) else t(seq_args)
|
|
993
|
+
elif dft is None:
|
|
994
|
+
return None
|
|
995
|
+
else:
|
|
996
|
+
return pydantic_encoder(dft)
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
_map_types_constraint: Dict[Any, Callable[..., type]] = {int: conint, float: confloat, Decimal: condecimal}
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
def get_annotation_from_field_info(
|
|
1003
|
+
annotation: Any, field_info: FieldInfo, field_name: str, validate_assignment: bool = False
|
|
1004
|
+
) -> Type[Any]:
|
|
1005
|
+
"""
|
|
1006
|
+
Get an annotation with validation implemented for numbers and strings based on the field_info.
|
|
1007
|
+
:param annotation: an annotation from a field specification, as ``str``, ``ConstrainedStr``
|
|
1008
|
+
:param field_info: an instance of FieldInfo, possibly with declarations for validations and JSON Schema
|
|
1009
|
+
:param field_name: name of the field for use in error messages
|
|
1010
|
+
:param validate_assignment: default False, flag for BaseModel Config value of validate_assignment
|
|
1011
|
+
:return: the same ``annotation`` if unmodified or a new annotation with validation in place
|
|
1012
|
+
"""
|
|
1013
|
+
constraints = field_info.get_constraints()
|
|
1014
|
+
used_constraints: Set[str] = set()
|
|
1015
|
+
if constraints:
|
|
1016
|
+
annotation, used_constraints = get_annotation_with_constraints(annotation, field_info)
|
|
1017
|
+
if validate_assignment:
|
|
1018
|
+
used_constraints.add('allow_mutation')
|
|
1019
|
+
|
|
1020
|
+
unused_constraints = constraints - used_constraints
|
|
1021
|
+
if unused_constraints:
|
|
1022
|
+
raise ValueError(
|
|
1023
|
+
f'On field "{field_name}" the following field constraints are set but not enforced: '
|
|
1024
|
+
f'{", ".join(unused_constraints)}. '
|
|
1025
|
+
f'\nFor more details see https://docs.pydantic.dev/usage/schema/#unenforced-field-constraints'
|
|
1026
|
+
)
|
|
1027
|
+
|
|
1028
|
+
return annotation
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
def get_annotation_with_constraints(annotation: Any, field_info: FieldInfo) -> Tuple[Type[Any], Set[str]]: # noqa: C901
|
|
1032
|
+
"""
|
|
1033
|
+
Get an annotation with used constraints implemented for numbers and strings based on the field_info.
|
|
1034
|
+
|
|
1035
|
+
:param annotation: an annotation from a field specification, as ``str``, ``ConstrainedStr``
|
|
1036
|
+
:param field_info: an instance of FieldInfo, possibly with declarations for validations and JSON Schema
|
|
1037
|
+
:return: the same ``annotation`` if unmodified or a new annotation along with the used constraints.
|
|
1038
|
+
"""
|
|
1039
|
+
used_constraints: Set[str] = set()
|
|
1040
|
+
|
|
1041
|
+
def go(type_: Any) -> Type[Any]:
|
|
1042
|
+
if (
|
|
1043
|
+
is_literal_type(type_)
|
|
1044
|
+
or isinstance(type_, ForwardRef)
|
|
1045
|
+
or lenient_issubclass(type_, (ConstrainedList, ConstrainedSet, ConstrainedFrozenSet))
|
|
1046
|
+
):
|
|
1047
|
+
return type_
|
|
1048
|
+
origin = get_origin(type_)
|
|
1049
|
+
if origin is not None:
|
|
1050
|
+
args: Tuple[Any, ...] = get_args(type_)
|
|
1051
|
+
if any(isinstance(a, ForwardRef) for a in args):
|
|
1052
|
+
# forward refs cause infinite recursion below
|
|
1053
|
+
return type_
|
|
1054
|
+
|
|
1055
|
+
if origin is Annotated:
|
|
1056
|
+
return go(args[0])
|
|
1057
|
+
if is_union(origin):
|
|
1058
|
+
return Union[tuple(go(a) for a in args)] # type: ignore
|
|
1059
|
+
|
|
1060
|
+
if issubclass(origin, List) and (
|
|
1061
|
+
field_info.min_items is not None
|
|
1062
|
+
or field_info.max_items is not None
|
|
1063
|
+
or field_info.unique_items is not None
|
|
1064
|
+
):
|
|
1065
|
+
used_constraints.update({'min_items', 'max_items', 'unique_items'})
|
|
1066
|
+
return conlist(
|
|
1067
|
+
go(args[0]),
|
|
1068
|
+
min_items=field_info.min_items,
|
|
1069
|
+
max_items=field_info.max_items,
|
|
1070
|
+
unique_items=field_info.unique_items,
|
|
1071
|
+
)
|
|
1072
|
+
|
|
1073
|
+
if issubclass(origin, Set) and (field_info.min_items is not None or field_info.max_items is not None):
|
|
1074
|
+
used_constraints.update({'min_items', 'max_items'})
|
|
1075
|
+
return conset(go(args[0]), min_items=field_info.min_items, max_items=field_info.max_items)
|
|
1076
|
+
|
|
1077
|
+
if issubclass(origin, FrozenSet) and (field_info.min_items is not None or field_info.max_items is not None):
|
|
1078
|
+
used_constraints.update({'min_items', 'max_items'})
|
|
1079
|
+
return confrozenset(go(args[0]), min_items=field_info.min_items, max_items=field_info.max_items)
|
|
1080
|
+
|
|
1081
|
+
for t in (Tuple, List, Set, FrozenSet, Sequence):
|
|
1082
|
+
if issubclass(origin, t): # type: ignore
|
|
1083
|
+
return t[tuple(go(a) for a in args)] # type: ignore
|
|
1084
|
+
|
|
1085
|
+
if issubclass(origin, Dict):
|
|
1086
|
+
return Dict[args[0], go(args[1])] # type: ignore
|
|
1087
|
+
|
|
1088
|
+
attrs: Optional[Tuple[str, ...]] = None
|
|
1089
|
+
constraint_func: Optional[Callable[..., type]] = None
|
|
1090
|
+
if isinstance(type_, type):
|
|
1091
|
+
if issubclass(type_, (SecretStr, SecretBytes)):
|
|
1092
|
+
attrs = ('max_length', 'min_length')
|
|
1093
|
+
|
|
1094
|
+
def constraint_func(**kw: Any) -> Type[Any]:
|
|
1095
|
+
return type(type_.__name__, (type_,), kw)
|
|
1096
|
+
|
|
1097
|
+
elif issubclass(type_, str) and not issubclass(type_, (EmailStr, AnyUrl)):
|
|
1098
|
+
attrs = ('max_length', 'min_length', 'regex')
|
|
1099
|
+
if issubclass(type_, StrictStr):
|
|
1100
|
+
|
|
1101
|
+
def constraint_func(**kw: Any) -> Type[Any]:
|
|
1102
|
+
return type(type_.__name__, (type_,), kw)
|
|
1103
|
+
|
|
1104
|
+
else:
|
|
1105
|
+
constraint_func = constr
|
|
1106
|
+
elif issubclass(type_, bytes):
|
|
1107
|
+
attrs = ('max_length', 'min_length', 'regex')
|
|
1108
|
+
if issubclass(type_, StrictBytes):
|
|
1109
|
+
|
|
1110
|
+
def constraint_func(**kw: Any) -> Type[Any]:
|
|
1111
|
+
return type(type_.__name__, (type_,), kw)
|
|
1112
|
+
|
|
1113
|
+
else:
|
|
1114
|
+
constraint_func = conbytes
|
|
1115
|
+
elif issubclass(type_, numeric_types) and not issubclass(
|
|
1116
|
+
type_,
|
|
1117
|
+
(
|
|
1118
|
+
ConstrainedInt,
|
|
1119
|
+
ConstrainedFloat,
|
|
1120
|
+
ConstrainedDecimal,
|
|
1121
|
+
ConstrainedList,
|
|
1122
|
+
ConstrainedSet,
|
|
1123
|
+
ConstrainedFrozenSet,
|
|
1124
|
+
bool,
|
|
1125
|
+
),
|
|
1126
|
+
):
|
|
1127
|
+
# Is numeric type
|
|
1128
|
+
attrs = ('gt', 'lt', 'ge', 'le', 'multiple_of')
|
|
1129
|
+
if issubclass(type_, float):
|
|
1130
|
+
attrs += ('allow_inf_nan',)
|
|
1131
|
+
if issubclass(type_, Decimal):
|
|
1132
|
+
attrs += ('max_digits', 'decimal_places')
|
|
1133
|
+
numeric_type = next(t for t in numeric_types if issubclass(type_, t)) # pragma: no branch
|
|
1134
|
+
constraint_func = _map_types_constraint[numeric_type]
|
|
1135
|
+
|
|
1136
|
+
if attrs:
|
|
1137
|
+
used_constraints.update(set(attrs))
|
|
1138
|
+
kwargs = {
|
|
1139
|
+
attr_name: attr
|
|
1140
|
+
for attr_name, attr in ((attr_name, getattr(field_info, attr_name)) for attr_name in attrs)
|
|
1141
|
+
if attr is not None
|
|
1142
|
+
}
|
|
1143
|
+
if kwargs:
|
|
1144
|
+
constraint_func = cast(Callable[..., type], constraint_func)
|
|
1145
|
+
return constraint_func(**kwargs)
|
|
1146
|
+
return type_
|
|
1147
|
+
|
|
1148
|
+
return go(annotation), used_constraints
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
def normalize_name(name: str) -> str:
|
|
1152
|
+
"""
|
|
1153
|
+
Normalizes the given name. This can be applied to either a model *or* enum.
|
|
1154
|
+
"""
|
|
1155
|
+
return re.sub(r'[^a-zA-Z0-9.\-_]', '_', name)
|
|
1156
|
+
|
|
1157
|
+
|
|
1158
|
+
class SkipField(Exception):
|
|
1159
|
+
"""
|
|
1160
|
+
Utility exception used to exclude fields from schema.
|
|
1161
|
+
"""
|
|
1162
|
+
|
|
1163
|
+
def __init__(self, message: str) -> None:
|
|
1164
|
+
self.message = message
|