truefoundry 0.3.4__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.

Files changed (253) hide show
  1. truefoundry/__init__.py +2 -0
  2. truefoundry/autodeploy/agents/developer.py +1 -1
  3. truefoundry/autodeploy/agents/project_identifier.py +2 -2
  4. truefoundry/autodeploy/agents/tester.py +1 -1
  5. truefoundry/autodeploy/cli.py +1 -1
  6. truefoundry/autodeploy/tools/list_files.py +1 -1
  7. truefoundry/cli/__main__.py +3 -17
  8. truefoundry/common/__init__.py +0 -0
  9. truefoundry/{deploy/lib/auth → common}/auth_service_client.py +50 -40
  10. truefoundry/common/constants.py +12 -0
  11. truefoundry/{deploy/lib/auth → common}/credential_file_manager.py +7 -7
  12. truefoundry/{deploy/lib/auth → common}/credential_provider.py +10 -23
  13. truefoundry/common/entities.py +124 -0
  14. truefoundry/common/exceptions.py +12 -0
  15. truefoundry/common/request_utils.py +84 -0
  16. truefoundry/common/servicefoundry_client.py +91 -0
  17. truefoundry/common/utils.py +56 -0
  18. truefoundry/deploy/auto_gen/models.py +4 -6
  19. truefoundry/deploy/cli/cli.py +3 -1
  20. truefoundry/deploy/cli/commands/apply_command.py +1 -1
  21. truefoundry/deploy/cli/commands/build_command.py +1 -1
  22. truefoundry/deploy/cli/commands/deploy_command.py +1 -1
  23. truefoundry/deploy/cli/commands/login_command.py +2 -2
  24. truefoundry/deploy/cli/commands/patch_application_command.py +1 -1
  25. truefoundry/deploy/cli/commands/patch_command.py +1 -1
  26. truefoundry/deploy/cli/commands/terminate_comand.py +1 -1
  27. truefoundry/deploy/cli/util.py +1 -1
  28. truefoundry/deploy/function_service/remote/remote.py +1 -1
  29. truefoundry/deploy/lib/auth/servicefoundry_session.py +2 -2
  30. truefoundry/deploy/lib/clients/servicefoundry_client.py +120 -159
  31. truefoundry/deploy/lib/const.py +1 -35
  32. truefoundry/deploy/lib/exceptions.py +0 -16
  33. truefoundry/deploy/lib/model/entity.py +1 -112
  34. truefoundry/deploy/lib/session.py +14 -42
  35. truefoundry/deploy/lib/util.py +0 -37
  36. truefoundry/{python_deploy_codegen.py → deploy/python_deploy_codegen.py} +2 -2
  37. truefoundry/deploy/v2/lib/deploy.py +3 -3
  38. truefoundry/deploy/v2/lib/deployable_patched_models.py +1 -1
  39. truefoundry/langchain/truefoundry_chat.py +1 -1
  40. truefoundry/langchain/truefoundry_embeddings.py +1 -1
  41. truefoundry/langchain/truefoundry_llm.py +1 -1
  42. truefoundry/langchain/utils.py +0 -41
  43. truefoundry/ml/__init__.py +37 -6
  44. truefoundry/ml/artifact/__init__.py +0 -0
  45. truefoundry/ml/artifact/truefoundry_artifact_repo.py +1161 -0
  46. truefoundry/ml/autogen/__init__.py +0 -0
  47. truefoundry/ml/autogen/client/__init__.py +370 -0
  48. truefoundry/ml/autogen/client/api/__init__.py +16 -0
  49. truefoundry/ml/autogen/client/api/auth_api.py +184 -0
  50. truefoundry/ml/autogen/client/api/deprecated_api.py +605 -0
  51. truefoundry/ml/autogen/client/api/experiments_api.py +1944 -0
  52. truefoundry/ml/autogen/client/api/health_api.py +299 -0
  53. truefoundry/ml/autogen/client/api/metrics_api.py +371 -0
  54. truefoundry/ml/autogen/client/api/mlfoundry_artifacts_api.py +7213 -0
  55. truefoundry/ml/autogen/client/api/python_deployment_config_api.py +201 -0
  56. truefoundry/ml/autogen/client/api/run_artifacts_api.py +231 -0
  57. truefoundry/ml/autogen/client/api/runs_api.py +2919 -0
  58. truefoundry/ml/autogen/client/api_client.py +822 -0
  59. truefoundry/ml/autogen/client/api_response.py +30 -0
  60. truefoundry/ml/autogen/client/configuration.py +489 -0
  61. truefoundry/ml/autogen/client/exceptions.py +161 -0
  62. truefoundry/ml/autogen/client/models/__init__.py +341 -0
  63. truefoundry/ml/autogen/client/models/add_custom_metrics_to_model_version_request_dto.py +69 -0
  64. truefoundry/ml/autogen/client/models/add_features_to_model_version_request_dto.py +83 -0
  65. truefoundry/ml/autogen/client/models/agent.py +125 -0
  66. truefoundry/ml/autogen/client/models/agent_app.py +118 -0
  67. truefoundry/ml/autogen/client/models/agent_open_api_tool.py +143 -0
  68. truefoundry/ml/autogen/client/models/agent_open_api_tool_with_fqn.py +144 -0
  69. truefoundry/ml/autogen/client/models/agent_with_fqn.py +127 -0
  70. truefoundry/ml/autogen/client/models/artifact_dto.py +115 -0
  71. truefoundry/ml/autogen/client/models/artifact_response_dto.py +75 -0
  72. truefoundry/ml/autogen/client/models/artifact_type.py +39 -0
  73. truefoundry/ml/autogen/client/models/artifact_version_dto.py +141 -0
  74. truefoundry/ml/autogen/client/models/artifact_version_response_dto.py +77 -0
  75. truefoundry/ml/autogen/client/models/artifact_version_status.py +35 -0
  76. truefoundry/ml/autogen/client/models/assistant_message.py +89 -0
  77. truefoundry/ml/autogen/client/models/authorize_user_for_model_request_dto.py +69 -0
  78. truefoundry/ml/autogen/client/models/authorize_user_for_model_version_request_dto.py +69 -0
  79. truefoundry/ml/autogen/client/models/blob_storage_reference.py +93 -0
  80. truefoundry/ml/autogen/client/models/body_get_search_runs_get.py +72 -0
  81. truefoundry/ml/autogen/client/models/chat_prompt.py +156 -0
  82. truefoundry/ml/autogen/client/models/chat_prompt_messages_inner.py +171 -0
  83. truefoundry/ml/autogen/client/models/columns_dto.py +73 -0
  84. truefoundry/ml/autogen/client/models/content.py +153 -0
  85. truefoundry/ml/autogen/client/models/content1.py +153 -0
  86. truefoundry/ml/autogen/client/models/content2.py +174 -0
  87. truefoundry/ml/autogen/client/models/content2_any_of_inner.py +150 -0
  88. truefoundry/ml/autogen/client/models/create_artifact_request_dto.py +74 -0
  89. truefoundry/ml/autogen/client/models/create_artifact_response_dto.py +65 -0
  90. truefoundry/ml/autogen/client/models/create_artifact_version_request_dto.py +74 -0
  91. truefoundry/ml/autogen/client/models/create_artifact_version_response_dto.py +65 -0
  92. truefoundry/ml/autogen/client/models/create_dataset_request_dto.py +76 -0
  93. truefoundry/ml/autogen/client/models/create_experiment_request_dto.py +94 -0
  94. truefoundry/ml/autogen/client/models/create_experiment_response_dto.py +67 -0
  95. truefoundry/ml/autogen/client/models/create_model_version_request_dto.py +95 -0
  96. truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_request_dto.py +73 -0
  97. truefoundry/ml/autogen/client/models/create_multi_part_upload_for_dataset_response_dto.py +79 -0
  98. truefoundry/ml/autogen/client/models/create_multi_part_upload_request_dto.py +73 -0
  99. truefoundry/ml/autogen/client/models/create_python_deployment_config_request_dto.py +72 -0
  100. truefoundry/ml/autogen/client/models/create_python_deployment_config_response_dto.py +67 -0
  101. truefoundry/ml/autogen/client/models/create_run_request_dto.py +97 -0
  102. truefoundry/ml/autogen/client/models/create_run_response_dto.py +75 -0
  103. truefoundry/ml/autogen/client/models/dataset_dto.py +112 -0
  104. truefoundry/ml/autogen/client/models/dataset_response_dto.py +75 -0
  105. truefoundry/ml/autogen/client/models/delete_artifact_versions_request_dto.py +65 -0
  106. truefoundry/ml/autogen/client/models/delete_dataset_request_dto.py +74 -0
  107. truefoundry/ml/autogen/client/models/delete_model_version_request_dto.py +65 -0
  108. truefoundry/ml/autogen/client/models/delete_run_request.py +65 -0
  109. truefoundry/ml/autogen/client/models/delete_tag_request_dto.py +68 -0
  110. truefoundry/ml/autogen/client/models/experiment_dto.py +127 -0
  111. truefoundry/ml/autogen/client/models/experiment_id_request_dto.py +67 -0
  112. truefoundry/ml/autogen/client/models/experiment_response_dto.py +75 -0
  113. truefoundry/ml/autogen/client/models/experiment_tag_dto.py +69 -0
  114. truefoundry/ml/autogen/client/models/feature_dto.py +68 -0
  115. truefoundry/ml/autogen/client/models/feature_value_type.py +35 -0
  116. truefoundry/ml/autogen/client/models/file_info_dto.py +76 -0
  117. truefoundry/ml/autogen/client/models/finalize_artifact_version_request_dto.py +101 -0
  118. truefoundry/ml/autogen/client/models/get_experiment_response_dto.py +88 -0
  119. truefoundry/ml/autogen/client/models/get_latest_run_log_response_dto.py +75 -0
  120. truefoundry/ml/autogen/client/models/get_metric_history_response.py +79 -0
  121. truefoundry/ml/autogen/client/models/get_signed_url_for_dataset_write_request_dto.py +68 -0
  122. truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_request_dto.py +68 -0
  123. truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_read_response_dto.py +81 -0
  124. truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_request_dto.py +69 -0
  125. truefoundry/ml/autogen/client/models/get_signed_urls_for_artifact_version_write_response_dto.py +83 -0
  126. truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_request_dto.py +68 -0
  127. truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_read_response_dto.py +81 -0
  128. truefoundry/ml/autogen/client/models/get_signed_urls_for_dataset_write_response_dto.py +81 -0
  129. truefoundry/ml/autogen/client/models/get_tenant_id_response_dto.py +73 -0
  130. truefoundry/ml/autogen/client/models/http_validation_error.py +82 -0
  131. truefoundry/ml/autogen/client/models/image_content_part.py +87 -0
  132. truefoundry/ml/autogen/client/models/image_url.py +75 -0
  133. truefoundry/ml/autogen/client/models/internal_metadata.py +180 -0
  134. truefoundry/ml/autogen/client/models/latest_run_log_dto.py +78 -0
  135. truefoundry/ml/autogen/client/models/list_artifact_versions_request_dto.py +107 -0
  136. truefoundry/ml/autogen/client/models/list_artifact_versions_response_dto.py +87 -0
  137. truefoundry/ml/autogen/client/models/list_artifacts_request_dto.py +96 -0
  138. truefoundry/ml/autogen/client/models/list_artifacts_response_dto.py +86 -0
  139. truefoundry/ml/autogen/client/models/list_colums_response_dto.py +75 -0
  140. truefoundry/ml/autogen/client/models/list_datasets_request_dto.py +78 -0
  141. truefoundry/ml/autogen/client/models/list_datasets_response_dto.py +86 -0
  142. truefoundry/ml/autogen/client/models/list_experiments_response_dto.py +86 -0
  143. truefoundry/ml/autogen/client/models/list_files_for_artifact_version_request_dto.py +76 -0
  144. truefoundry/ml/autogen/client/models/list_files_for_artifact_versions_response_dto.py +82 -0
  145. truefoundry/ml/autogen/client/models/list_files_for_dataset_request_dto.py +76 -0
  146. truefoundry/ml/autogen/client/models/list_files_for_dataset_response_dto.py +82 -0
  147. truefoundry/ml/autogen/client/models/list_latest_run_logs_response_dto.py +82 -0
  148. truefoundry/ml/autogen/client/models/list_metric_history_request_dto.py +69 -0
  149. truefoundry/ml/autogen/client/models/list_metric_history_response_dto.py +84 -0
  150. truefoundry/ml/autogen/client/models/list_model_version_response_dto.py +87 -0
  151. truefoundry/ml/autogen/client/models/list_model_versions_request_dto.py +93 -0
  152. truefoundry/ml/autogen/client/models/list_models_request_dto.py +89 -0
  153. truefoundry/ml/autogen/client/models/list_models_response_dto.py +84 -0
  154. truefoundry/ml/autogen/client/models/list_run_artifacts_response_dto.py +84 -0
  155. truefoundry/ml/autogen/client/models/list_run_logs_response_dto.py +82 -0
  156. truefoundry/ml/autogen/client/models/list_seed_experiments_response_dto.py +81 -0
  157. truefoundry/ml/autogen/client/models/log_batch_request_dto.py +106 -0
  158. truefoundry/ml/autogen/client/models/log_metric_request_dto.py +80 -0
  159. truefoundry/ml/autogen/client/models/log_param_request_dto.py +76 -0
  160. truefoundry/ml/autogen/client/models/method.py +37 -0
  161. truefoundry/ml/autogen/client/models/metric_collection_dto.py +82 -0
  162. truefoundry/ml/autogen/client/models/metric_dto.py +76 -0
  163. truefoundry/ml/autogen/client/models/mime_type.py +37 -0
  164. truefoundry/ml/autogen/client/models/model_configuration.py +103 -0
  165. truefoundry/ml/autogen/client/models/model_dto.py +122 -0
  166. truefoundry/ml/autogen/client/models/model_response_dto.py +75 -0
  167. truefoundry/ml/autogen/client/models/model_schema_dto.py +85 -0
  168. truefoundry/ml/autogen/client/models/model_version_dto.py +170 -0
  169. truefoundry/ml/autogen/client/models/model_version_response_dto.py +75 -0
  170. truefoundry/ml/autogen/client/models/multi_part_upload_dto.py +107 -0
  171. truefoundry/ml/autogen/client/models/multi_part_upload_response_dto.py +79 -0
  172. truefoundry/ml/autogen/client/models/multi_part_upload_storage_provider.py +34 -0
  173. truefoundry/ml/autogen/client/models/notify_artifact_version_failure_dto.py +65 -0
  174. truefoundry/ml/autogen/client/models/openapi_spec.py +152 -0
  175. truefoundry/ml/autogen/client/models/param_dto.py +66 -0
  176. truefoundry/ml/autogen/client/models/parameters.py +84 -0
  177. truefoundry/ml/autogen/client/models/prediction_type.py +34 -0
  178. truefoundry/ml/autogen/client/models/resolve_agent_app_response_dto.py +75 -0
  179. truefoundry/ml/autogen/client/models/restore_run_request_dto.py +65 -0
  180. truefoundry/ml/autogen/client/models/run_data_dto.py +104 -0
  181. truefoundry/ml/autogen/client/models/run_dto.py +84 -0
  182. truefoundry/ml/autogen/client/models/run_info_dto.py +105 -0
  183. truefoundry/ml/autogen/client/models/run_log_dto.py +90 -0
  184. truefoundry/ml/autogen/client/models/run_log_input_dto.py +80 -0
  185. truefoundry/ml/autogen/client/models/run_response_dto.py +75 -0
  186. truefoundry/ml/autogen/client/models/run_tag_dto.py +66 -0
  187. truefoundry/ml/autogen/client/models/search_runs_request_dto.py +94 -0
  188. truefoundry/ml/autogen/client/models/search_runs_response_dto.py +84 -0
  189. truefoundry/ml/autogen/client/models/set_experiment_tag_request_dto.py +73 -0
  190. truefoundry/ml/autogen/client/models/set_tag_request_dto.py +76 -0
  191. truefoundry/ml/autogen/client/models/signed_url_dto.py +69 -0
  192. truefoundry/ml/autogen/client/models/stop.py +152 -0
  193. truefoundry/ml/autogen/client/models/store_run_logs_request_dto.py +83 -0
  194. truefoundry/ml/autogen/client/models/system_message.py +89 -0
  195. truefoundry/ml/autogen/client/models/text.py +153 -0
  196. truefoundry/ml/autogen/client/models/text_content_part.py +84 -0
  197. truefoundry/ml/autogen/client/models/update_artifact_version_request_dto.py +74 -0
  198. truefoundry/ml/autogen/client/models/update_dataset_request_dto.py +74 -0
  199. truefoundry/ml/autogen/client/models/update_experiment_request_dto.py +74 -0
  200. truefoundry/ml/autogen/client/models/update_model_version_request_dto.py +93 -0
  201. truefoundry/ml/autogen/client/models/update_run_request_dto.py +78 -0
  202. truefoundry/ml/autogen/client/models/update_run_response_dto.py +75 -0
  203. truefoundry/ml/autogen/client/models/url.py +153 -0
  204. truefoundry/ml/autogen/client/models/user_message.py +89 -0
  205. truefoundry/ml/autogen/client/models/validation_error.py +87 -0
  206. truefoundry/ml/autogen/client/models/validation_error_loc_inner.py +154 -0
  207. truefoundry/ml/autogen/client/rest.py +426 -0
  208. truefoundry/ml/autogen/client_README.md +320 -0
  209. truefoundry/ml/cli/__init__.py +0 -0
  210. truefoundry/ml/cli/cli.py +18 -0
  211. truefoundry/ml/cli/commands/__init__.py +3 -0
  212. truefoundry/ml/cli/commands/download.py +87 -0
  213. truefoundry/ml/clients/__init__.py +0 -0
  214. truefoundry/ml/clients/entities.py +8 -0
  215. truefoundry/ml/clients/servicefoundry_client.py +45 -0
  216. truefoundry/ml/clients/utils.py +122 -0
  217. truefoundry/ml/constants.py +84 -0
  218. truefoundry/ml/entities.py +62 -0
  219. truefoundry/ml/enums.py +70 -0
  220. truefoundry/ml/env_vars.py +9 -0
  221. truefoundry/ml/exceptions.py +8 -0
  222. truefoundry/ml/git_info.py +60 -0
  223. truefoundry/ml/internal_namespace.py +52 -0
  224. truefoundry/ml/log_types/__init__.py +4 -0
  225. truefoundry/ml/log_types/artifacts/artifact.py +431 -0
  226. truefoundry/ml/log_types/artifacts/constants.py +33 -0
  227. truefoundry/ml/log_types/artifacts/dataset.py +384 -0
  228. truefoundry/ml/log_types/artifacts/general_artifact.py +110 -0
  229. truefoundry/ml/log_types/artifacts/model.py +611 -0
  230. truefoundry/ml/log_types/artifacts/model_extras.py +48 -0
  231. truefoundry/ml/log_types/artifacts/utils.py +161 -0
  232. truefoundry/ml/log_types/image/__init__.py +3 -0
  233. truefoundry/ml/log_types/image/constants.py +8 -0
  234. truefoundry/ml/log_types/image/image.py +357 -0
  235. truefoundry/ml/log_types/image/image_normalizer.py +102 -0
  236. truefoundry/ml/log_types/image/types.py +68 -0
  237. truefoundry/ml/log_types/plot.py +281 -0
  238. truefoundry/ml/log_types/pydantic_base.py +10 -0
  239. truefoundry/ml/log_types/utils.py +12 -0
  240. truefoundry/ml/logger.py +17 -0
  241. truefoundry/ml/mlfoundry_api.py +1575 -0
  242. truefoundry/ml/mlfoundry_run.py +1203 -0
  243. truefoundry/ml/run_utils.py +93 -0
  244. truefoundry/ml/session.py +168 -0
  245. truefoundry/ml/validation_utils.py +346 -0
  246. truefoundry/pydantic_v1.py +6 -2
  247. truefoundry/workflow/__init__.py +16 -1
  248. {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/METADATA +21 -14
  249. truefoundry-0.4.0.dist-info/RECORD +344 -0
  250. truefoundry/deploy/lib/clients/utils.py +0 -41
  251. truefoundry-0.3.4.dist-info/RECORD +0 -136
  252. {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/WHEEL +0 -0
  253. {truefoundry-0.3.4.dist-info → truefoundry-0.4.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,30 @@
1
+ """API response object."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, Optional
6
+
7
+ from truefoundry.pydantic_v1 import Field, StrictInt, StrictStr
8
+
9
+
10
+ class ApiResponse:
11
+ """
12
+ API response object
13
+ """
14
+
15
+ status_code: Optional[StrictInt] = Field(None, description="HTTP status code")
16
+ headers: Optional[Dict[StrictStr, StrictStr]] = Field(
17
+ None, description="HTTP headers"
18
+ )
19
+ data: Optional[Any] = Field(
20
+ None, description="Deserialized data given the data type"
21
+ )
22
+ raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)")
23
+
24
+ def __init__(
25
+ self, status_code=None, headers=None, data=None, raw_data=None
26
+ ) -> None:
27
+ self.status_code = status_code
28
+ self.headers = headers
29
+ self.data = data
30
+ self.raw_data = raw_data
@@ -0,0 +1,489 @@
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 copy
15
+ import http.client as httplib
16
+ import logging
17
+ import multiprocessing
18
+ import sys
19
+
20
+ import urllib3
21
+
22
+ JSON_SCHEMA_VALIDATION_KEYWORDS = {
23
+ "multipleOf",
24
+ "maximum",
25
+ "exclusiveMaximum",
26
+ "minimum",
27
+ "exclusiveMinimum",
28
+ "maxLength",
29
+ "minLength",
30
+ "pattern",
31
+ "maxItems",
32
+ "minItems",
33
+ }
34
+
35
+
36
+ class Configuration:
37
+ """This class contains various settings of the API client.
38
+
39
+ :param host: Base url.
40
+ :param api_key: Dict to store API key(s).
41
+ Each entry in the dict specifies an API key.
42
+ The dict key is the name of the security scheme in the OAS specification.
43
+ The dict value is the API key secret.
44
+ :param api_key_prefix: Dict to store API prefix (e.g. Bearer).
45
+ The dict key is the name of the security scheme in the OAS specification.
46
+ The dict value is an API key prefix when generating the auth data.
47
+ :param username: Username for HTTP basic authentication.
48
+ :param password: Password for HTTP basic authentication.
49
+ :param access_token: Access token.
50
+ :param server_index: Index to servers configuration.
51
+ :param server_variables: Mapping with string values to replace variables in
52
+ templated server configuration. The validation of enums is performed for
53
+ variables with defined enum values before.
54
+ :param server_operation_index: Mapping from operation ID to an index to server
55
+ configuration.
56
+ :param server_operation_variables: Mapping from operation ID to a mapping with
57
+ string values to replace variables in templated server configuration.
58
+ The validation of enums is performed for variables with defined enum
59
+ values before.
60
+ :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
61
+ in PEM format.
62
+
63
+ :Example:
64
+
65
+ API Key Authentication Example.
66
+ Given the following security scheme in the OpenAPI specification:
67
+ components:
68
+ securitySchemes:
69
+ cookieAuth: # name for the security scheme
70
+ type: apiKey
71
+ in: cookie
72
+ name: JSESSIONID # cookie name
73
+
74
+ You can programmatically set the cookie:
75
+
76
+ conf = truefoundry.ml.autogen.client.Configuration(
77
+ api_key={'cookieAuth': 'abc123'}
78
+ api_key_prefix={'cookieAuth': 'JSESSIONID'}
79
+ )
80
+
81
+ The following cookie will be added to the HTTP request:
82
+ Cookie: JSESSIONID abc123
83
+ """
84
+
85
+ _default = None
86
+
87
+ def __init__(
88
+ self,
89
+ host=None,
90
+ api_key=None,
91
+ api_key_prefix=None,
92
+ username=None,
93
+ password=None,
94
+ access_token=None,
95
+ server_index=None,
96
+ server_variables=None,
97
+ server_operation_index=None,
98
+ server_operation_variables=None,
99
+ ssl_ca_cert=None,
100
+ ) -> None:
101
+ """Constructor"""
102
+ self._base_path = "http://localhost" if host is None else host
103
+ """Default Base url
104
+ """
105
+ self.server_index = 0 if server_index is None and host is None else server_index
106
+ self.server_operation_index = server_operation_index or {}
107
+ """Default server index
108
+ """
109
+ self.server_variables = server_variables or {}
110
+ self.server_operation_variables = server_operation_variables or {}
111
+ """Default server variables
112
+ """
113
+ self.temp_folder_path = None
114
+ """Temp file folder for downloading files
115
+ """
116
+ # Authentication Settings
117
+ self.api_key = {}
118
+ if api_key:
119
+ self.api_key = api_key
120
+ """dict to store API key(s)
121
+ """
122
+ self.api_key_prefix = {}
123
+ if api_key_prefix:
124
+ self.api_key_prefix = api_key_prefix
125
+ """dict to store API prefix (e.g. Bearer)
126
+ """
127
+ self.refresh_api_key_hook = None
128
+ """function hook to refresh API key if expired
129
+ """
130
+ self.username = username
131
+ """Username for HTTP basic authentication
132
+ """
133
+ self.password = password
134
+ """Password for HTTP basic authentication
135
+ """
136
+ self.access_token = access_token
137
+ """Access token
138
+ """
139
+ self.logger = {}
140
+ """Logging Settings
141
+ """
142
+ self.logger["package_logger"] = logging.getLogger(
143
+ "truefoundry.ml.autogen.client"
144
+ )
145
+ self.logger["urllib3_logger"] = logging.getLogger("urllib3")
146
+ self.logger_format = "%(asctime)s %(levelname)s %(message)s"
147
+ """Log format
148
+ """
149
+ self.logger_stream_handler = None
150
+ """Log stream handler
151
+ """
152
+ self.logger_file_handler = None
153
+ """Log file handler
154
+ """
155
+ self.logger_file = None
156
+ """Debug file location
157
+ """
158
+ self.debug = False
159
+ """Debug switch
160
+ """
161
+
162
+ self.verify_ssl = True
163
+ """SSL/TLS verification
164
+ Set this to false to skip verifying SSL certificate when calling API
165
+ from https server.
166
+ """
167
+ self.ssl_ca_cert = ssl_ca_cert
168
+ """Set this to customize the certificate file to verify the peer.
169
+ """
170
+ self.cert_file = None
171
+ """client certificate file
172
+ """
173
+ self.key_file = None
174
+ """client key file
175
+ """
176
+ self.assert_hostname = None
177
+ """Set this to True/False to enable/disable SSL hostname verification.
178
+ """
179
+ self.tls_server_name = None
180
+ """SSL/TLS Server Name Indication (SNI)
181
+ Set this to the SNI value expected by the server.
182
+ """
183
+
184
+ self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
185
+ """urllib3 connection pool's maximum number of connections saved
186
+ per pool. urllib3 uses 1 connection as default value, but this is
187
+ not the best value when you are making a lot of possibly parallel
188
+ requests to the same host, which is often the case here.
189
+ cpu_count * 5 is used as default value to increase performance.
190
+ """
191
+
192
+ self.proxy = None
193
+ """Proxy URL
194
+ """
195
+ self.proxy_headers = None
196
+ """Proxy headers
197
+ """
198
+ self.safe_chars_for_path_param = ""
199
+ """Safe chars for path_param
200
+ """
201
+ self.retries = None
202
+ """Adding retries to override urllib3 default value 3
203
+ """
204
+ # Enable client side validation
205
+ self.client_side_validation = True
206
+
207
+ self.socket_options = None
208
+ """Options to pass down to the underlying urllib3 socket
209
+ """
210
+
211
+ self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z"
212
+ """datetime format
213
+ """
214
+
215
+ self.date_format = "%Y-%m-%d"
216
+ """date format
217
+ """
218
+
219
+ def __deepcopy__(self, memo):
220
+ cls = self.__class__
221
+ result = cls.__new__(cls)
222
+ memo[id(self)] = result
223
+ for k, v in self.__dict__.items():
224
+ if k not in ("logger", "logger_file_handler"):
225
+ setattr(result, k, copy.deepcopy(v, memo))
226
+ # shallow copy of loggers
227
+ result.logger = copy.copy(self.logger)
228
+ # use setters to configure loggers
229
+ result.logger_file = self.logger_file
230
+ result.debug = self.debug
231
+ return result
232
+
233
+ def __setattr__(self, name, value):
234
+ object.__setattr__(self, name, value)
235
+
236
+ @classmethod
237
+ def set_default(cls, default):
238
+ """Set default instance of configuration.
239
+
240
+ It stores default configuration, which can be
241
+ returned by get_default_copy method.
242
+
243
+ :param default: object of Configuration
244
+ """
245
+ cls._default = default
246
+
247
+ @classmethod
248
+ def get_default_copy(cls):
249
+ """Deprecated. Please use `get_default` instead.
250
+
251
+ Deprecated. Please use `get_default` instead.
252
+
253
+ :return: The configuration object.
254
+ """
255
+ return cls.get_default()
256
+
257
+ @classmethod
258
+ def get_default(cls):
259
+ """Return the default configuration.
260
+
261
+ This method returns newly created, based on default constructor,
262
+ object of Configuration class or returns a copy of default
263
+ configuration.
264
+
265
+ :return: The configuration object.
266
+ """
267
+ if cls._default is None:
268
+ cls._default = Configuration()
269
+ return cls._default
270
+
271
+ @property
272
+ def logger_file(self):
273
+ """The logger file.
274
+
275
+ If the logger_file is None, then add stream handler and remove file
276
+ handler. Otherwise, add file handler and remove stream handler.
277
+
278
+ :param value: The logger_file path.
279
+ :type: str
280
+ """
281
+ return self.__logger_file
282
+
283
+ @logger_file.setter
284
+ def logger_file(self, value):
285
+ """The logger file.
286
+
287
+ If the logger_file is None, then add stream handler and remove file
288
+ handler. Otherwise, add file handler and remove stream handler.
289
+
290
+ :param value: The logger_file path.
291
+ :type: str
292
+ """
293
+ self.__logger_file = value
294
+ if self.__logger_file:
295
+ # If set logging file,
296
+ # then add file handler and remove stream handler.
297
+ self.logger_file_handler = logging.FileHandler(self.__logger_file)
298
+ self.logger_file_handler.setFormatter(self.logger_formatter)
299
+ for _, logger in self.logger.items():
300
+ logger.addHandler(self.logger_file_handler)
301
+
302
+ @property
303
+ def debug(self):
304
+ """Debug status
305
+
306
+ :param value: The debug status, True or False.
307
+ :type: bool
308
+ """
309
+ return self.__debug
310
+
311
+ @debug.setter
312
+ def debug(self, value):
313
+ """Debug status
314
+
315
+ :param value: The debug status, True or False.
316
+ :type: bool
317
+ """
318
+ self.__debug = value
319
+ if self.__debug:
320
+ # if debug status is True, turn on debug logging
321
+ for _, logger in self.logger.items():
322
+ logger.setLevel(logging.DEBUG)
323
+ # turn on httplib debug
324
+ httplib.HTTPConnection.debuglevel = 1
325
+ else:
326
+ # if debug status is False, turn off debug logging,
327
+ # setting log level to default `logging.WARNING`
328
+ for _, logger in self.logger.items():
329
+ logger.setLevel(logging.WARNING)
330
+ # turn off httplib debug
331
+ httplib.HTTPConnection.debuglevel = 0
332
+
333
+ @property
334
+ def logger_format(self):
335
+ """The logger format.
336
+
337
+ The logger_formatter will be updated when sets logger_format.
338
+
339
+ :param value: The format string.
340
+ :type: str
341
+ """
342
+ return self.__logger_format
343
+
344
+ @logger_format.setter
345
+ def logger_format(self, value):
346
+ """The logger format.
347
+
348
+ The logger_formatter will be updated when sets logger_format.
349
+
350
+ :param value: The format string.
351
+ :type: str
352
+ """
353
+ self.__logger_format = value
354
+ self.logger_formatter = logging.Formatter(self.__logger_format)
355
+
356
+ def get_api_key_with_prefix(self, identifier, alias=None):
357
+ """Gets API key (with prefix if set).
358
+
359
+ :param identifier: The identifier of apiKey.
360
+ :param alias: The alternative identifier of apiKey.
361
+ :return: The token for api key authentication.
362
+ """
363
+ if self.refresh_api_key_hook is not None:
364
+ self.refresh_api_key_hook(self)
365
+ key = self.api_key.get(
366
+ identifier, self.api_key.get(alias) if alias is not None else None
367
+ )
368
+ if key:
369
+ prefix = self.api_key_prefix.get(identifier)
370
+ if prefix:
371
+ return "%s %s" % (prefix, key)
372
+ else:
373
+ return key
374
+
375
+ def get_basic_auth_token(self):
376
+ """Gets HTTP basic authentication header (string).
377
+
378
+ :return: The token for basic HTTP authentication.
379
+ """
380
+ username = ""
381
+ if self.username is not None:
382
+ username = self.username
383
+ password = ""
384
+ if self.password is not None:
385
+ password = self.password
386
+ return urllib3.util.make_headers(basic_auth=username + ":" + password).get(
387
+ "authorization"
388
+ )
389
+
390
+ def auth_settings(self):
391
+ """Gets Auth Settings dict for api client.
392
+
393
+ :return: The Auth Settings information dict.
394
+ """
395
+ auth = {}
396
+ if self.access_token is not None:
397
+ auth["HTTPBearer"] = {
398
+ "type": "bearer",
399
+ "in": "header",
400
+ "key": "Authorization",
401
+ "value": "Bearer " + self.access_token,
402
+ }
403
+ if "APIKeyCookie" in self.api_key:
404
+ auth["APIKeyCookie"] = {
405
+ "type": "api_key",
406
+ "in": "cookie",
407
+ "key": "accessToken",
408
+ "value": self.get_api_key_with_prefix(
409
+ "APIKeyCookie",
410
+ ),
411
+ }
412
+ return auth
413
+
414
+ def to_debug_report(self):
415
+ """Gets the essential information for debugging.
416
+
417
+ :return: The report for debugging.
418
+ """
419
+ return (
420
+ "Python SDK Debug Report:\n"
421
+ "OS: {env}\n"
422
+ "Python Version: {pyversion}\n"
423
+ "Version of the API: 0.1.0\n"
424
+ "SDK Package Version: 0.1.0".format(env=sys.platform, pyversion=sys.version)
425
+ )
426
+
427
+ def get_host_settings(self):
428
+ """Gets an array of host settings
429
+
430
+ :return: An array of host settings
431
+ """
432
+ return [
433
+ {
434
+ "url": "",
435
+ "description": "No description provided",
436
+ }
437
+ ]
438
+
439
+ def get_host_from_settings(self, index, variables=None, servers=None):
440
+ """Gets host URL based on the index and variables
441
+ :param index: array index of the host settings
442
+ :param variables: hash of variable and the corresponding value
443
+ :param servers: an array of host settings or None
444
+ :return: URL based on host settings
445
+ """
446
+ if index is None:
447
+ return self._base_path
448
+
449
+ variables = {} if variables is None else variables
450
+ servers = self.get_host_settings() if servers is None else servers
451
+
452
+ try:
453
+ server = servers[index]
454
+ except IndexError:
455
+ raise ValueError(
456
+ "Invalid index {0} when selecting the host settings. "
457
+ "Must be less than {1}".format(index, len(servers))
458
+ )
459
+
460
+ url = server["url"]
461
+
462
+ # go through variables and replace placeholders
463
+ for variable_name, variable in server.get("variables", {}).items():
464
+ used_value = variables.get(variable_name, variable["default_value"])
465
+
466
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
467
+ raise ValueError(
468
+ "The variable `{0}` in the host URL has invalid value "
469
+ "{1}. Must be {2}.".format(
470
+ variable_name, variables[variable_name], variable["enum_values"]
471
+ )
472
+ )
473
+
474
+ url = url.replace("{" + variable_name + "}", used_value)
475
+
476
+ return url
477
+
478
+ @property
479
+ def host(self):
480
+ """Return generated host."""
481
+ return self.get_host_from_settings(
482
+ self.server_index, variables=self.server_variables
483
+ )
484
+
485
+ @host.setter
486
+ def host(self, value):
487
+ """Fix base path."""
488
+ self._base_path = value
489
+ self.server_index = None
@@ -0,0 +1,161 @@
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
+
15
+ class OpenApiException(Exception):
16
+ """The base exception class for all OpenAPIExceptions"""
17
+
18
+
19
+ class ApiTypeError(OpenApiException, TypeError):
20
+ def __init__(
21
+ self, msg, path_to_item=None, valid_classes=None, key_type=None
22
+ ) -> None:
23
+ """Raises an exception for TypeErrors
24
+
25
+ Args:
26
+ msg (str): the exception message
27
+
28
+ Keyword Args:
29
+ path_to_item (list): a list of keys an indices to get to the
30
+ current_item
31
+ None if unset
32
+ valid_classes (tuple): the primitive classes that current item
33
+ should be an instance of
34
+ None if unset
35
+ key_type (bool): False if our value is a value in a dict
36
+ True if it is a key in a dict
37
+ False if our item is an item in a list
38
+ None if unset
39
+ """
40
+ self.path_to_item = path_to_item
41
+ self.valid_classes = valid_classes
42
+ self.key_type = key_type
43
+ full_msg = msg
44
+ if path_to_item:
45
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
46
+ super(ApiTypeError, self).__init__(full_msg)
47
+
48
+
49
+ class ApiValueError(OpenApiException, ValueError):
50
+ def __init__(self, msg, path_to_item=None) -> None:
51
+ """
52
+ Args:
53
+ msg (str): the exception message
54
+
55
+ Keyword Args:
56
+ path_to_item (list) the path to the exception in the
57
+ received_data dict. None if unset
58
+ """
59
+
60
+ self.path_to_item = path_to_item
61
+ full_msg = msg
62
+ if path_to_item:
63
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
64
+ super(ApiValueError, self).__init__(full_msg)
65
+
66
+
67
+ class ApiAttributeError(OpenApiException, AttributeError):
68
+ def __init__(self, msg, path_to_item=None) -> None:
69
+ """
70
+ Raised when an attribute reference or assignment fails.
71
+
72
+ Args:
73
+ msg (str): the exception message
74
+
75
+ Keyword Args:
76
+ path_to_item (None/list) the path to the exception in the
77
+ received_data dict
78
+ """
79
+ self.path_to_item = path_to_item
80
+ full_msg = msg
81
+ if path_to_item:
82
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
83
+ super(ApiAttributeError, self).__init__(full_msg)
84
+
85
+
86
+ class ApiKeyError(OpenApiException, KeyError):
87
+ def __init__(self, msg, path_to_item=None) -> None:
88
+ """
89
+ Args:
90
+ msg (str): the exception message
91
+
92
+ Keyword Args:
93
+ path_to_item (None/list) the path to the exception in the
94
+ received_data dict
95
+ """
96
+ self.path_to_item = path_to_item
97
+ full_msg = msg
98
+ if path_to_item:
99
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
100
+ super(ApiKeyError, self).__init__(full_msg)
101
+
102
+
103
+ class ApiException(OpenApiException):
104
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
105
+ if http_resp:
106
+ self.status = http_resp.status
107
+ self.reason = http_resp.reason
108
+ self.body = http_resp.data
109
+ self.headers = http_resp.getheaders()
110
+ else:
111
+ self.status = status
112
+ self.reason = reason
113
+ self.body = None
114
+ self.headers = None
115
+
116
+ def __str__(self):
117
+ """Custom error messages for exception"""
118
+ error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
119
+ if self.headers:
120
+ error_message += "HTTP response headers: {0}\n".format(self.headers)
121
+
122
+ if self.body:
123
+ error_message += "HTTP response body: {0}\n".format(self.body)
124
+
125
+ return error_message
126
+
127
+
128
+ class BadRequestException(ApiException):
129
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
130
+ super(BadRequestException, self).__init__(status, reason, http_resp)
131
+
132
+
133
+ class NotFoundException(ApiException):
134
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
135
+ super(NotFoundException, self).__init__(status, reason, http_resp)
136
+
137
+
138
+ class UnauthorizedException(ApiException):
139
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
140
+ super(UnauthorizedException, self).__init__(status, reason, http_resp)
141
+
142
+
143
+ class ForbiddenException(ApiException):
144
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
145
+ super(ForbiddenException, self).__init__(status, reason, http_resp)
146
+
147
+
148
+ class ServiceException(ApiException):
149
+ def __init__(self, status=None, reason=None, http_resp=None) -> None:
150
+ super(ServiceException, self).__init__(status, reason, http_resp)
151
+
152
+
153
+ def render_path(path_to_item):
154
+ """Returns a string representation of a path"""
155
+ result = ""
156
+ for pth in path_to_item:
157
+ if isinstance(pth, int):
158
+ result += "[{0}]".format(pth)
159
+ else:
160
+ result += "['{0}']".format(pth)
161
+ return result