truefoundry 0.3.4rc1__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of truefoundry might be problematic. Click here for more details.
- truefoundry/__init__.py +2 -0
- truefoundry/autodeploy/agents/developer.py +1 -1
- truefoundry/autodeploy/agents/project_identifier.py +2 -2
- truefoundry/autodeploy/agents/tester.py +1 -1
- truefoundry/autodeploy/cli.py +1 -1
- truefoundry/autodeploy/tools/list_files.py +1 -1
- truefoundry/cli/__main__.py +3 -17
- truefoundry/common/__init__.py +0 -0
- truefoundry/{deploy/lib/auth → common}/auth_service_client.py +50 -40
- truefoundry/common/constants.py +12 -0
- truefoundry/{deploy/lib/auth → common}/credential_file_manager.py +7 -7
- truefoundry/{deploy/lib/auth → common}/credential_provider.py +10 -23
- truefoundry/common/entities.py +124 -0
- truefoundry/common/exceptions.py +12 -0
- truefoundry/common/request_utils.py +84 -0
- truefoundry/common/servicefoundry_client.py +91 -0
- truefoundry/common/utils.py +56 -0
- truefoundry/deploy/auto_gen/models.py +4 -6
- truefoundry/deploy/cli/cli.py +3 -1
- truefoundry/deploy/cli/commands/apply_command.py +1 -1
- truefoundry/deploy/cli/commands/build_command.py +1 -1
- truefoundry/deploy/cli/commands/deploy_command.py +1 -1
- truefoundry/deploy/cli/commands/login_command.py +2 -2
- truefoundry/deploy/cli/commands/patch_application_command.py +1 -1
- truefoundry/deploy/cli/commands/patch_command.py +1 -1
- truefoundry/deploy/cli/commands/terminate_comand.py +1 -1
- truefoundry/deploy/cli/util.py +1 -1
- truefoundry/deploy/function_service/remote/remote.py +1 -1
- truefoundry/deploy/lib/auth/servicefoundry_session.py +2 -2
- truefoundry/deploy/lib/clients/servicefoundry_client.py +120 -159
- truefoundry/deploy/lib/const.py +1 -35
- truefoundry/deploy/lib/exceptions.py +0 -16
- truefoundry/deploy/lib/model/entity.py +1 -112
- truefoundry/deploy/lib/session.py +14 -42
- truefoundry/deploy/lib/util.py +0 -37
- truefoundry/{python_deploy_codegen.py → deploy/python_deploy_codegen.py} +2 -2
- truefoundry/deploy/v2/lib/deploy.py +3 -3
- truefoundry/deploy/v2/lib/deployable_patched_models.py +1 -1
- truefoundry/langchain/truefoundry_chat.py +1 -1
- truefoundry/langchain/truefoundry_embeddings.py +1 -1
- truefoundry/langchain/truefoundry_llm.py +1 -1
- truefoundry/langchain/utils.py +0 -41
- truefoundry/ml/__init__.py +37 -6
- truefoundry/ml/artifact/__init__.py +0 -0
- truefoundry/ml/artifact/truefoundry_artifact_repo.py +1161 -0
- truefoundry/ml/autogen/__init__.py +0 -0
- truefoundry/ml/autogen/client/__init__.py +370 -0
- truefoundry/ml/autogen/client/api/__init__.py +16 -0
- truefoundry/ml/autogen/client/api/auth_api.py +184 -0
- truefoundry/ml/autogen/client/api/deprecated_api.py +605 -0
- truefoundry/ml/autogen/client/api/experiments_api.py +1944 -0
- truefoundry/ml/autogen/client/api/health_api.py +299 -0
- truefoundry/ml/autogen/client/api/metrics_api.py +371 -0
- truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +7213 -0
- truefoundry/ml/autogen/client/api/python_deployment_config_api.py +201 -0
- truefoundry/ml/autogen/client/api/run_artifacts_api.py +231 -0
- truefoundry/ml/autogen/client/api/runs_api.py +2919 -0
- truefoundry/ml/autogen/client/api_client.py +822 -0
- truefoundry/ml/autogen/client/api_response.py +30 -0
- truefoundry/ml/autogen/client/configuration.py +489 -0
- truefoundry/ml/autogen/client/exceptions.py +161 -0
- truefoundry/ml/autogen/client/models/__init__.py +341 -0
- truefoundry/ml/autogen/client/models/add_custom_metrics_to_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/add_features_to_model_version_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/agent.py +125 -0
- truefoundry/ml/autogen/client/models/agent_app.py +118 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool.py +143 -0
- truefoundry/ml/autogen/client/models/agent_open_api_tool_with_fqn.py +144 -0
- truefoundry/ml/autogen/client/models/agent_with_fqn.py +127 -0
- truefoundry/ml/autogen/client/models/artifact_dto.py +115 -0
- truefoundry/ml/autogen/client/models/artifact_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/artifact_type.py +39 -0
- truefoundry/ml/autogen/client/models/artifact_version_dto.py +141 -0
- truefoundry/ml/autogen/client/models/artifact_version_response_dto.py +77 -0
- truefoundry/ml/autogen/client/models/artifact_version_status.py +35 -0
- truefoundry/ml/autogen/client/models/assistant_message.py +89 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/authorize_user_for_model_version_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/blob_storage_reference.py +93 -0
- truefoundry/ml/autogen/client/models/body_get_search_runs_get.py +72 -0
- truefoundry/ml/autogen/client/models/chat_prompt.py +156 -0
- truefoundry/ml/autogen/client/models/chat_prompt_messages_inner.py +171 -0
- truefoundry/ml/autogen/client/models/columns_dto.py +73 -0
- truefoundry/ml/autogen/client/models/content.py +153 -0
- truefoundry/ml/autogen/client/models/content1.py +153 -0
- truefoundry/ml/autogen/client/models/content2.py +174 -0
- truefoundry/ml/autogen/client/models/content2_any_of_inner.py +150 -0
- truefoundry/ml/autogen/client/models/create_artifact_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +65 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +65 -0
- truefoundry/ml/autogen/client/models/create_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/create_experiment_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/create_experiment_response_dto.py +67 -0
- truefoundry/ml/autogen/client/models/create_model_version_request_dto.py +95 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/create_multi_part_upload_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +72 -0
- truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +67 -0
- truefoundry/ml/autogen/client/models/create_run_request_dto.py +97 -0
- truefoundry/ml/autogen/client/models/create_run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/dataset_dto.py +112 -0
- truefoundry/ml/autogen/client/models/dataset_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/delete_artifact_versions_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/delete_model_version_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/delete_run_request.py +65 -0
- truefoundry/ml/autogen/client/models/delete_tag_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/experiment_dto.py +127 -0
- truefoundry/ml/autogen/client/models/experiment_id_request_dto.py +67 -0
- truefoundry/ml/autogen/client/models/experiment_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/experiment_tag_dto.py +69 -0
- truefoundry/ml/autogen/client/models/feature_dto.py +68 -0
- truefoundry/ml/autogen/client/models/feature_value_type.py +35 -0
- truefoundry/ml/autogen/client/models/file_info_dto.py +76 -0
- truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +101 -0
- truefoundry/ml/autogen/client/models/get_experiment_response_dto.py +88 -0
- truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/get_metric_history_response.py +79 -0
- truefoundry/ml/autogen/client/models/get_signed_url_for_dataset_write_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_response_dto.py +83 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_request_dto.py +68 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_write_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +73 -0
- truefoundry/ml/autogen/client/models/http_validation_error.py +82 -0
- truefoundry/ml/autogen/client/models/image_content_part.py +87 -0
- truefoundry/ml/autogen/client/models/image_url.py +75 -0
- truefoundry/ml/autogen/client/models/internal_metadata.py +180 -0
- truefoundry/ml/autogen/client/models/latest_run_log_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_request_dto.py +107 -0
- truefoundry/ml/autogen/client/models/list_artifact_versions_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_artifacts_request_dto.py +96 -0
- truefoundry/ml/autogen/client/models/list_artifacts_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_colums_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/list_datasets_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/list_datasets_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_experiments_response_dto.py +86 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_version_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_artifact_versions_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/list_files_for_dataset_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_latest_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_metric_history_request_dto.py +69 -0
- truefoundry/ml/autogen/client/models/list_metric_history_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_model_version_response_dto.py +87 -0
- truefoundry/ml/autogen/client/models/list_model_versions_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/list_models_request_dto.py +89 -0
- truefoundry/ml/autogen/client/models/list_models_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_artifacts_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/list_run_logs_response_dto.py +82 -0
- truefoundry/ml/autogen/client/models/list_seed_experiments_response_dto.py +81 -0
- truefoundry/ml/autogen/client/models/log_batch_request_dto.py +106 -0
- truefoundry/ml/autogen/client/models/log_metric_request_dto.py +80 -0
- truefoundry/ml/autogen/client/models/log_param_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/method.py +37 -0
- truefoundry/ml/autogen/client/models/metric_collection_dto.py +82 -0
- truefoundry/ml/autogen/client/models/metric_dto.py +76 -0
- truefoundry/ml/autogen/client/models/mime_type.py +37 -0
- truefoundry/ml/autogen/client/models/model_configuration.py +103 -0
- truefoundry/ml/autogen/client/models/model_dto.py +122 -0
- truefoundry/ml/autogen/client/models/model_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/model_schema_dto.py +85 -0
- truefoundry/ml/autogen/client/models/model_version_dto.py +170 -0
- truefoundry/ml/autogen/client/models/model_version_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_dto.py +107 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py +79 -0
- truefoundry/ml/autogen/client/models/multi_part_upload_storage_provider.py +34 -0
- truefoundry/ml/autogen/client/models/notify_artifact_version_failure_dto.py +65 -0
- truefoundry/ml/autogen/client/models/openapi_spec.py +152 -0
- truefoundry/ml/autogen/client/models/param_dto.py +66 -0
- truefoundry/ml/autogen/client/models/parameters.py +84 -0
- truefoundry/ml/autogen/client/models/prediction_type.py +34 -0
- truefoundry/ml/autogen/client/models/resolve_agent_app_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/restore_run_request_dto.py +65 -0
- truefoundry/ml/autogen/client/models/run_data_dto.py +104 -0
- truefoundry/ml/autogen/client/models/run_dto.py +84 -0
- truefoundry/ml/autogen/client/models/run_info_dto.py +105 -0
- truefoundry/ml/autogen/client/models/run_log_dto.py +90 -0
- truefoundry/ml/autogen/client/models/run_log_input_dto.py +80 -0
- truefoundry/ml/autogen/client/models/run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/run_tag_dto.py +66 -0
- truefoundry/ml/autogen/client/models/search_runs_request_dto.py +94 -0
- truefoundry/ml/autogen/client/models/search_runs_response_dto.py +84 -0
- truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py +73 -0
- truefoundry/ml/autogen/client/models/set_tag_request_dto.py +76 -0
- truefoundry/ml/autogen/client/models/signed_url_dto.py +69 -0
- truefoundry/ml/autogen/client/models/stop.py +152 -0
- truefoundry/ml/autogen/client/models/store_run_logs_request_dto.py +83 -0
- truefoundry/ml/autogen/client/models/system_message.py +89 -0
- truefoundry/ml/autogen/client/models/text.py +153 -0
- truefoundry/ml/autogen/client/models/text_content_part.py +84 -0
- truefoundry/ml/autogen/client/models/update_artifact_version_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_dataset_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_experiment_request_dto.py +74 -0
- truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +93 -0
- truefoundry/ml/autogen/client/models/update_run_request_dto.py +78 -0
- truefoundry/ml/autogen/client/models/update_run_response_dto.py +75 -0
- truefoundry/ml/autogen/client/models/url.py +153 -0
- truefoundry/ml/autogen/client/models/user_message.py +89 -0
- truefoundry/ml/autogen/client/models/validation_error.py +87 -0
- truefoundry/ml/autogen/client/models/validation_error_loc_inner.py +154 -0
- truefoundry/ml/autogen/client/rest.py +426 -0
- truefoundry/ml/autogen/client_README.md +320 -0
- truefoundry/ml/cli/__init__.py +0 -0
- truefoundry/ml/cli/cli.py +18 -0
- truefoundry/ml/cli/commands/__init__.py +3 -0
- truefoundry/ml/cli/commands/download.py +87 -0
- truefoundry/ml/clients/__init__.py +0 -0
- truefoundry/ml/clients/entities.py +8 -0
- truefoundry/ml/clients/servicefoundry_client.py +45 -0
- truefoundry/ml/clients/utils.py +122 -0
- truefoundry/ml/constants.py +84 -0
- truefoundry/ml/entities.py +62 -0
- truefoundry/ml/enums.py +70 -0
- truefoundry/ml/env_vars.py +9 -0
- truefoundry/ml/exceptions.py +8 -0
- truefoundry/ml/git_info.py +60 -0
- truefoundry/ml/internal_namespace.py +52 -0
- truefoundry/ml/log_types/__init__.py +4 -0
- truefoundry/ml/log_types/artifacts/artifact.py +431 -0
- truefoundry/ml/log_types/artifacts/constants.py +33 -0
- truefoundry/ml/log_types/artifacts/dataset.py +384 -0
- truefoundry/ml/log_types/artifacts/general_artifact.py +110 -0
- truefoundry/ml/log_types/artifacts/model.py +611 -0
- truefoundry/ml/log_types/artifacts/model_extras.py +48 -0
- truefoundry/ml/log_types/artifacts/utils.py +161 -0
- truefoundry/ml/log_types/image/__init__.py +3 -0
- truefoundry/ml/log_types/image/constants.py +8 -0
- truefoundry/ml/log_types/image/image.py +357 -0
- truefoundry/ml/log_types/image/image_normalizer.py +102 -0
- truefoundry/ml/log_types/image/types.py +68 -0
- truefoundry/ml/log_types/plot.py +281 -0
- truefoundry/ml/log_types/pydantic_base.py +10 -0
- truefoundry/ml/log_types/utils.py +12 -0
- truefoundry/ml/logger.py +17 -0
- truefoundry/ml/mlfoundry_api.py +1575 -0
- truefoundry/ml/mlfoundry_run.py +1203 -0
- truefoundry/ml/run_utils.py +93 -0
- truefoundry/ml/session.py +168 -0
- truefoundry/ml/validation_utils.py +346 -0
- truefoundry/pydantic_v1.py +8 -1
- truefoundry/workflow/__init__.py +16 -1
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/METADATA +21 -14
- truefoundry-0.4.0.dist-info/RECORD +344 -0
- truefoundry/deploy/lib/clients/utils.py +0 -41
- truefoundry-0.3.4rc1.dist-info/RECORD +0 -136
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/WHEEL +0 -0
- {truefoundry-0.3.4rc1.dist-info → truefoundry-0.4.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
FastAPI
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import json
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
from typing import TYPE_CHECKING, Any, List, Optional, Union
|
|
20
|
+
|
|
21
|
+
from truefoundry.pydantic_v1 import (
|
|
22
|
+
BaseModel,
|
|
23
|
+
Field,
|
|
24
|
+
StrictInt,
|
|
25
|
+
StrictStr,
|
|
26
|
+
ValidationError,
|
|
27
|
+
validator,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ValidationErrorLocInner(BaseModel):
|
|
34
|
+
"""
|
|
35
|
+
ValidationErrorLocInner
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
# data type: str
|
|
39
|
+
anyof_schema_1_validator: Optional[StrictStr] = None
|
|
40
|
+
# data type: int
|
|
41
|
+
anyof_schema_2_validator: Optional[StrictInt] = None
|
|
42
|
+
if TYPE_CHECKING:
|
|
43
|
+
actual_instance: Union[int, str]
|
|
44
|
+
else:
|
|
45
|
+
actual_instance: Any
|
|
46
|
+
any_of_schemas: List[str] = Field(
|
|
47
|
+
VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS, const=True
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
class Config:
|
|
51
|
+
validate_assignment = True
|
|
52
|
+
|
|
53
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
54
|
+
if args:
|
|
55
|
+
if len(args) > 1:
|
|
56
|
+
raise ValueError(
|
|
57
|
+
"If a position argument is used, only 1 is allowed to set `actual_instance`"
|
|
58
|
+
)
|
|
59
|
+
if kwargs:
|
|
60
|
+
raise ValueError(
|
|
61
|
+
"If a position argument is used, keyword arguments cannot be used."
|
|
62
|
+
)
|
|
63
|
+
super().__init__(actual_instance=args[0])
|
|
64
|
+
else:
|
|
65
|
+
super().__init__(**kwargs)
|
|
66
|
+
|
|
67
|
+
@validator("actual_instance")
|
|
68
|
+
def actual_instance_must_validate_anyof(cls, v):
|
|
69
|
+
instance = ValidationErrorLocInner.construct()
|
|
70
|
+
error_messages = []
|
|
71
|
+
# validate data type: str
|
|
72
|
+
try:
|
|
73
|
+
instance.anyof_schema_1_validator = v
|
|
74
|
+
return v
|
|
75
|
+
except (ValidationError, ValueError) as e:
|
|
76
|
+
error_messages.append(str(e))
|
|
77
|
+
# validate data type: int
|
|
78
|
+
try:
|
|
79
|
+
instance.anyof_schema_2_validator = v
|
|
80
|
+
return v
|
|
81
|
+
except (ValidationError, ValueError) as e:
|
|
82
|
+
error_messages.append(str(e))
|
|
83
|
+
if error_messages:
|
|
84
|
+
# no match
|
|
85
|
+
raise ValueError(
|
|
86
|
+
"No match found when setting the actual_instance in ValidationErrorLocInner with anyOf schemas: int, str. Details: "
|
|
87
|
+
+ ", ".join(error_messages)
|
|
88
|
+
)
|
|
89
|
+
else:
|
|
90
|
+
return v
|
|
91
|
+
|
|
92
|
+
@classmethod
|
|
93
|
+
def from_dict(cls, obj: dict) -> ValidationErrorLocInner:
|
|
94
|
+
return cls.from_json(json.dumps(obj))
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def from_json(cls, json_str: str) -> ValidationErrorLocInner:
|
|
98
|
+
"""Returns the object represented by the json string"""
|
|
99
|
+
instance = ValidationErrorLocInner.construct()
|
|
100
|
+
error_messages = []
|
|
101
|
+
# deserialize data into str
|
|
102
|
+
try:
|
|
103
|
+
# validation
|
|
104
|
+
instance.anyof_schema_1_validator = json.loads(json_str)
|
|
105
|
+
# assign value to actual_instance
|
|
106
|
+
instance.actual_instance = instance.anyof_schema_1_validator
|
|
107
|
+
return instance
|
|
108
|
+
except (ValidationError, ValueError) as e:
|
|
109
|
+
error_messages.append(str(e))
|
|
110
|
+
# deserialize data into int
|
|
111
|
+
try:
|
|
112
|
+
# validation
|
|
113
|
+
instance.anyof_schema_2_validator = json.loads(json_str)
|
|
114
|
+
# assign value to actual_instance
|
|
115
|
+
instance.actual_instance = instance.anyof_schema_2_validator
|
|
116
|
+
return instance
|
|
117
|
+
except (ValidationError, ValueError) as e:
|
|
118
|
+
error_messages.append(str(e))
|
|
119
|
+
|
|
120
|
+
if error_messages:
|
|
121
|
+
# no match
|
|
122
|
+
raise ValueError(
|
|
123
|
+
"No match found when deserializing the JSON string into ValidationErrorLocInner with anyOf schemas: int, str. Details: "
|
|
124
|
+
+ ", ".join(error_messages)
|
|
125
|
+
)
|
|
126
|
+
else:
|
|
127
|
+
return instance
|
|
128
|
+
|
|
129
|
+
def to_json(self) -> str:
|
|
130
|
+
"""Returns the JSON representation of the actual instance"""
|
|
131
|
+
if self.actual_instance is None:
|
|
132
|
+
return "null"
|
|
133
|
+
|
|
134
|
+
to_json = getattr(self.actual_instance, "to_json", None)
|
|
135
|
+
if callable(to_json):
|
|
136
|
+
return self.actual_instance.to_json()
|
|
137
|
+
else:
|
|
138
|
+
return json.dumps(self.actual_instance)
|
|
139
|
+
|
|
140
|
+
def to_dict(self) -> dict:
|
|
141
|
+
"""Returns the dict representation of the actual instance"""
|
|
142
|
+
if self.actual_instance is None:
|
|
143
|
+
return "null"
|
|
144
|
+
|
|
145
|
+
to_json = getattr(self.actual_instance, "to_json", None)
|
|
146
|
+
if callable(to_json):
|
|
147
|
+
return self.actual_instance.to_dict()
|
|
148
|
+
else:
|
|
149
|
+
# primitive type
|
|
150
|
+
return self.actual_instance
|
|
151
|
+
|
|
152
|
+
def to_str(self) -> str:
|
|
153
|
+
"""Returns the string representation of the actual instance"""
|
|
154
|
+
return pprint.pformat(self.dict())
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
FastAPI
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.1.0
|
|
9
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
10
|
+
|
|
11
|
+
Do not edit the class manually.
|
|
12
|
+
""" # noqa: E501
|
|
13
|
+
|
|
14
|
+
import io
|
|
15
|
+
import json
|
|
16
|
+
import logging
|
|
17
|
+
import re
|
|
18
|
+
import ssl
|
|
19
|
+
|
|
20
|
+
import urllib3
|
|
21
|
+
|
|
22
|
+
from truefoundry.ml.autogen.client.exceptions import (
|
|
23
|
+
ApiException,
|
|
24
|
+
ApiValueError,
|
|
25
|
+
BadRequestException,
|
|
26
|
+
ForbiddenException,
|
|
27
|
+
NotFoundException,
|
|
28
|
+
ServiceException,
|
|
29
|
+
UnauthorizedException,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
logger = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def is_socks_proxy_url(url):
|
|
38
|
+
if url is None:
|
|
39
|
+
return False
|
|
40
|
+
split_section = url.split("://")
|
|
41
|
+
if len(split_section) < 2:
|
|
42
|
+
return False
|
|
43
|
+
else:
|
|
44
|
+
return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class RESTResponse(io.IOBase):
|
|
48
|
+
def __init__(self, resp) -> None:
|
|
49
|
+
self.urllib3_response = resp
|
|
50
|
+
self.status = resp.status
|
|
51
|
+
self.reason = resp.reason
|
|
52
|
+
self.data = resp.data
|
|
53
|
+
|
|
54
|
+
def getheaders(self):
|
|
55
|
+
"""Returns a dictionary of the response headers."""
|
|
56
|
+
return self.urllib3_response.headers
|
|
57
|
+
|
|
58
|
+
def getheader(self, name, default=None):
|
|
59
|
+
"""Returns a given response header."""
|
|
60
|
+
return self.urllib3_response.headers.get(name, default)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class RESTClientObject:
|
|
64
|
+
def __init__(self, configuration, pools_size=4, maxsize=None) -> None:
|
|
65
|
+
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
|
66
|
+
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
|
|
67
|
+
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
|
|
68
|
+
# maxsize is the number of requests to host that are allowed in parallel # noqa: E501
|
|
69
|
+
# Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
|
|
70
|
+
|
|
71
|
+
# cert_reqs
|
|
72
|
+
if configuration.verify_ssl:
|
|
73
|
+
cert_reqs = ssl.CERT_REQUIRED
|
|
74
|
+
else:
|
|
75
|
+
cert_reqs = ssl.CERT_NONE
|
|
76
|
+
|
|
77
|
+
addition_pool_args = {}
|
|
78
|
+
if configuration.assert_hostname is not None:
|
|
79
|
+
addition_pool_args["assert_hostname"] = configuration.assert_hostname # noqa: E501
|
|
80
|
+
|
|
81
|
+
if configuration.retries is not None:
|
|
82
|
+
addition_pool_args["retries"] = configuration.retries
|
|
83
|
+
|
|
84
|
+
if configuration.tls_server_name:
|
|
85
|
+
addition_pool_args["server_hostname"] = configuration.tls_server_name
|
|
86
|
+
|
|
87
|
+
if configuration.socket_options is not None:
|
|
88
|
+
addition_pool_args["socket_options"] = configuration.socket_options
|
|
89
|
+
|
|
90
|
+
if maxsize is None:
|
|
91
|
+
if configuration.connection_pool_maxsize is not None:
|
|
92
|
+
maxsize = configuration.connection_pool_maxsize
|
|
93
|
+
else:
|
|
94
|
+
maxsize = 4
|
|
95
|
+
|
|
96
|
+
# https pool manager
|
|
97
|
+
if configuration.proxy:
|
|
98
|
+
if is_socks_proxy_url(configuration.proxy):
|
|
99
|
+
from urllib3.contrib.socks import SOCKSProxyManager
|
|
100
|
+
|
|
101
|
+
self.pool_manager = SOCKSProxyManager(
|
|
102
|
+
cert_reqs=cert_reqs,
|
|
103
|
+
ca_certs=configuration.ssl_ca_cert,
|
|
104
|
+
cert_file=configuration.cert_file,
|
|
105
|
+
key_file=configuration.key_file,
|
|
106
|
+
proxy_url=configuration.proxy,
|
|
107
|
+
headers=configuration.proxy_headers,
|
|
108
|
+
**addition_pool_args,
|
|
109
|
+
)
|
|
110
|
+
else:
|
|
111
|
+
self.pool_manager = urllib3.ProxyManager(
|
|
112
|
+
num_pools=pools_size,
|
|
113
|
+
maxsize=maxsize,
|
|
114
|
+
cert_reqs=cert_reqs,
|
|
115
|
+
ca_certs=configuration.ssl_ca_cert,
|
|
116
|
+
cert_file=configuration.cert_file,
|
|
117
|
+
key_file=configuration.key_file,
|
|
118
|
+
proxy_url=configuration.proxy,
|
|
119
|
+
proxy_headers=configuration.proxy_headers,
|
|
120
|
+
**addition_pool_args,
|
|
121
|
+
)
|
|
122
|
+
else:
|
|
123
|
+
self.pool_manager = urllib3.PoolManager(
|
|
124
|
+
num_pools=pools_size,
|
|
125
|
+
maxsize=maxsize,
|
|
126
|
+
cert_reqs=cert_reqs,
|
|
127
|
+
ca_certs=configuration.ssl_ca_cert,
|
|
128
|
+
cert_file=configuration.cert_file,
|
|
129
|
+
key_file=configuration.key_file,
|
|
130
|
+
**addition_pool_args,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
def request(
|
|
134
|
+
self,
|
|
135
|
+
method,
|
|
136
|
+
url,
|
|
137
|
+
query_params=None,
|
|
138
|
+
headers=None,
|
|
139
|
+
body=None,
|
|
140
|
+
post_params=None,
|
|
141
|
+
_preload_content=True,
|
|
142
|
+
_request_timeout=None,
|
|
143
|
+
):
|
|
144
|
+
"""Perform requests.
|
|
145
|
+
|
|
146
|
+
:param method: http request method
|
|
147
|
+
:param url: http request url
|
|
148
|
+
:param query_params: query parameters in the url
|
|
149
|
+
:param headers: http request headers
|
|
150
|
+
:param body: request json body, for `application/json`
|
|
151
|
+
:param post_params: request post parameters,
|
|
152
|
+
`application/x-www-form-urlencoded`
|
|
153
|
+
and `multipart/form-data`
|
|
154
|
+
:param _preload_content: if False, the urllib3.HTTPResponse object will
|
|
155
|
+
be returned without reading/decoding response
|
|
156
|
+
data. Default is True.
|
|
157
|
+
:param _request_timeout: timeout setting for this request. If one
|
|
158
|
+
number provided, it will be total request
|
|
159
|
+
timeout. It can also be a pair (tuple) of
|
|
160
|
+
(connection, read) timeouts.
|
|
161
|
+
"""
|
|
162
|
+
method = method.upper()
|
|
163
|
+
assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]
|
|
164
|
+
|
|
165
|
+
if post_params and body:
|
|
166
|
+
raise ApiValueError(
|
|
167
|
+
"body parameter cannot be used with post_params parameter."
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
post_params = post_params or {}
|
|
171
|
+
headers = headers or {}
|
|
172
|
+
# url already contains the URL query string
|
|
173
|
+
# so reset query_params to empty dict
|
|
174
|
+
query_params = {}
|
|
175
|
+
|
|
176
|
+
timeout = None
|
|
177
|
+
if _request_timeout:
|
|
178
|
+
if isinstance(_request_timeout, (int, float)): # noqa: E501,F821
|
|
179
|
+
timeout = urllib3.Timeout(total=_request_timeout)
|
|
180
|
+
elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2:
|
|
181
|
+
timeout = urllib3.Timeout(
|
|
182
|
+
connect=_request_timeout[0], read=_request_timeout[1]
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
try:
|
|
186
|
+
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
|
187
|
+
if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
|
|
188
|
+
# no content type provided or payload is json
|
|
189
|
+
if not headers.get("Content-Type") or re.search(
|
|
190
|
+
"json", headers["Content-Type"], re.IGNORECASE
|
|
191
|
+
):
|
|
192
|
+
request_body = None
|
|
193
|
+
if body is not None:
|
|
194
|
+
request_body = json.dumps(body)
|
|
195
|
+
r = self.pool_manager.request(
|
|
196
|
+
method,
|
|
197
|
+
url,
|
|
198
|
+
body=request_body,
|
|
199
|
+
preload_content=_preload_content,
|
|
200
|
+
timeout=timeout,
|
|
201
|
+
headers=headers,
|
|
202
|
+
)
|
|
203
|
+
elif headers["Content-Type"] == "application/x-www-form-urlencoded": # noqa: E501
|
|
204
|
+
r = self.pool_manager.request(
|
|
205
|
+
method,
|
|
206
|
+
url,
|
|
207
|
+
fields=post_params,
|
|
208
|
+
encode_multipart=False,
|
|
209
|
+
preload_content=_preload_content,
|
|
210
|
+
timeout=timeout,
|
|
211
|
+
headers=headers,
|
|
212
|
+
)
|
|
213
|
+
elif headers["Content-Type"] == "multipart/form-data":
|
|
214
|
+
# must del headers['Content-Type'], or the correct
|
|
215
|
+
# Content-Type which generated by urllib3 will be
|
|
216
|
+
# overwritten.
|
|
217
|
+
del headers["Content-Type"]
|
|
218
|
+
# Ensures that dict objects are serialized
|
|
219
|
+
post_params = [
|
|
220
|
+
(a, json.dumps(b)) if isinstance(b, dict) else (a, b)
|
|
221
|
+
for a, b in post_params
|
|
222
|
+
]
|
|
223
|
+
r = self.pool_manager.request(
|
|
224
|
+
method,
|
|
225
|
+
url,
|
|
226
|
+
fields=post_params,
|
|
227
|
+
encode_multipart=True,
|
|
228
|
+
preload_content=_preload_content,
|
|
229
|
+
timeout=timeout,
|
|
230
|
+
headers=headers,
|
|
231
|
+
)
|
|
232
|
+
# Pass a `string` parameter directly in the body to support
|
|
233
|
+
# other content types than Json when `body` argument is
|
|
234
|
+
# provided in serialized form
|
|
235
|
+
elif isinstance(body, str) or isinstance(body, bytes):
|
|
236
|
+
request_body = body
|
|
237
|
+
r = self.pool_manager.request(
|
|
238
|
+
method,
|
|
239
|
+
url,
|
|
240
|
+
body=request_body,
|
|
241
|
+
preload_content=_preload_content,
|
|
242
|
+
timeout=timeout,
|
|
243
|
+
headers=headers,
|
|
244
|
+
)
|
|
245
|
+
else:
|
|
246
|
+
# Cannot generate the request from given parameters
|
|
247
|
+
msg = """Cannot prepare a request message for provided
|
|
248
|
+
arguments. Please check that your arguments match
|
|
249
|
+
declared content type."""
|
|
250
|
+
raise ApiException(status=0, reason=msg)
|
|
251
|
+
# For `GET`, `HEAD`
|
|
252
|
+
else:
|
|
253
|
+
r = self.pool_manager.request(
|
|
254
|
+
method,
|
|
255
|
+
url,
|
|
256
|
+
fields={},
|
|
257
|
+
preload_content=_preload_content,
|
|
258
|
+
timeout=timeout,
|
|
259
|
+
headers=headers,
|
|
260
|
+
)
|
|
261
|
+
except urllib3.exceptions.SSLError as e:
|
|
262
|
+
msg = "{0}\n{1}".format(type(e).__name__, str(e))
|
|
263
|
+
raise ApiException(status=0, reason=msg)
|
|
264
|
+
|
|
265
|
+
if _preload_content:
|
|
266
|
+
r = RESTResponse(r)
|
|
267
|
+
|
|
268
|
+
# log response body
|
|
269
|
+
logger.debug("response body: %s", r.data)
|
|
270
|
+
|
|
271
|
+
if not 200 <= r.status <= 299:
|
|
272
|
+
if r.status == 400:
|
|
273
|
+
raise BadRequestException(http_resp=r)
|
|
274
|
+
|
|
275
|
+
if r.status == 401:
|
|
276
|
+
raise UnauthorizedException(http_resp=r)
|
|
277
|
+
|
|
278
|
+
if r.status == 403:
|
|
279
|
+
raise ForbiddenException(http_resp=r)
|
|
280
|
+
|
|
281
|
+
if r.status == 404:
|
|
282
|
+
raise NotFoundException(http_resp=r)
|
|
283
|
+
|
|
284
|
+
if 500 <= r.status <= 599:
|
|
285
|
+
raise ServiceException(http_resp=r)
|
|
286
|
+
|
|
287
|
+
raise ApiException(http_resp=r)
|
|
288
|
+
|
|
289
|
+
return r
|
|
290
|
+
|
|
291
|
+
def get_request(
|
|
292
|
+
self,
|
|
293
|
+
url,
|
|
294
|
+
headers=None,
|
|
295
|
+
query_params=None,
|
|
296
|
+
_preload_content=True,
|
|
297
|
+
_request_timeout=None,
|
|
298
|
+
):
|
|
299
|
+
return self.request(
|
|
300
|
+
"GET",
|
|
301
|
+
url,
|
|
302
|
+
headers=headers,
|
|
303
|
+
_preload_content=_preload_content,
|
|
304
|
+
_request_timeout=_request_timeout,
|
|
305
|
+
query_params=query_params,
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
def head_request(
|
|
309
|
+
self,
|
|
310
|
+
url,
|
|
311
|
+
headers=None,
|
|
312
|
+
query_params=None,
|
|
313
|
+
_preload_content=True,
|
|
314
|
+
_request_timeout=None,
|
|
315
|
+
):
|
|
316
|
+
return self.request(
|
|
317
|
+
"HEAD",
|
|
318
|
+
url,
|
|
319
|
+
headers=headers,
|
|
320
|
+
_preload_content=_preload_content,
|
|
321
|
+
_request_timeout=_request_timeout,
|
|
322
|
+
query_params=query_params,
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
def options_request(
|
|
326
|
+
self,
|
|
327
|
+
url,
|
|
328
|
+
headers=None,
|
|
329
|
+
query_params=None,
|
|
330
|
+
post_params=None,
|
|
331
|
+
body=None,
|
|
332
|
+
_preload_content=True,
|
|
333
|
+
_request_timeout=None,
|
|
334
|
+
):
|
|
335
|
+
return self.request(
|
|
336
|
+
"OPTIONS",
|
|
337
|
+
url,
|
|
338
|
+
headers=headers,
|
|
339
|
+
query_params=query_params,
|
|
340
|
+
post_params=post_params,
|
|
341
|
+
_preload_content=_preload_content,
|
|
342
|
+
_request_timeout=_request_timeout,
|
|
343
|
+
body=body,
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
def delete_request(
|
|
347
|
+
self,
|
|
348
|
+
url,
|
|
349
|
+
headers=None,
|
|
350
|
+
query_params=None,
|
|
351
|
+
body=None,
|
|
352
|
+
_preload_content=True,
|
|
353
|
+
_request_timeout=None,
|
|
354
|
+
):
|
|
355
|
+
return self.request(
|
|
356
|
+
"DELETE",
|
|
357
|
+
url,
|
|
358
|
+
headers=headers,
|
|
359
|
+
query_params=query_params,
|
|
360
|
+
_preload_content=_preload_content,
|
|
361
|
+
_request_timeout=_request_timeout,
|
|
362
|
+
body=body,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
def post_request(
|
|
366
|
+
self,
|
|
367
|
+
url,
|
|
368
|
+
headers=None,
|
|
369
|
+
query_params=None,
|
|
370
|
+
post_params=None,
|
|
371
|
+
body=None,
|
|
372
|
+
_preload_content=True,
|
|
373
|
+
_request_timeout=None,
|
|
374
|
+
):
|
|
375
|
+
return self.request(
|
|
376
|
+
"POST",
|
|
377
|
+
url,
|
|
378
|
+
headers=headers,
|
|
379
|
+
query_params=query_params,
|
|
380
|
+
post_params=post_params,
|
|
381
|
+
_preload_content=_preload_content,
|
|
382
|
+
_request_timeout=_request_timeout,
|
|
383
|
+
body=body,
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
def put_request(
|
|
387
|
+
self,
|
|
388
|
+
url,
|
|
389
|
+
headers=None,
|
|
390
|
+
query_params=None,
|
|
391
|
+
post_params=None,
|
|
392
|
+
body=None,
|
|
393
|
+
_preload_content=True,
|
|
394
|
+
_request_timeout=None,
|
|
395
|
+
):
|
|
396
|
+
return self.request(
|
|
397
|
+
"PUT",
|
|
398
|
+
url,
|
|
399
|
+
headers=headers,
|
|
400
|
+
query_params=query_params,
|
|
401
|
+
post_params=post_params,
|
|
402
|
+
_preload_content=_preload_content,
|
|
403
|
+
_request_timeout=_request_timeout,
|
|
404
|
+
body=body,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
def patch_request(
|
|
408
|
+
self,
|
|
409
|
+
url,
|
|
410
|
+
headers=None,
|
|
411
|
+
query_params=None,
|
|
412
|
+
post_params=None,
|
|
413
|
+
body=None,
|
|
414
|
+
_preload_content=True,
|
|
415
|
+
_request_timeout=None,
|
|
416
|
+
):
|
|
417
|
+
return self.request(
|
|
418
|
+
"PATCH",
|
|
419
|
+
url,
|
|
420
|
+
headers=headers,
|
|
421
|
+
query_params=query_params,
|
|
422
|
+
post_params=post_params,
|
|
423
|
+
_preload_content=_preload_content,
|
|
424
|
+
_request_timeout=_request_timeout,
|
|
425
|
+
body=body,
|
|
426
|
+
)
|