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
@@ -1,14 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import datetime
4
- import time
5
4
  from enum import Enum
6
5
  from typing import Any, Dict, List, Optional, Union
7
6
 
8
- import jwt
9
-
10
7
  from truefoundry.deploy.lib.util import get_application_fqn_from_deployment_fqn
11
- from truefoundry.pydantic_v1 import BaseModel, Extra, Field, constr, validator
8
+ from truefoundry.pydantic_v1 import BaseModel, Extra, Field
12
9
 
13
10
  # TODO: switch to Enums for str literals
14
11
  # TODO: Need a better approach to keep fields in sync with server
@@ -215,114 +212,6 @@ class Application(Entity):
215
212
  }
216
213
 
217
214
 
218
- class UserType(Enum):
219
- user = "user"
220
- serviceaccount = "serviceaccount"
221
-
222
-
223
- class UserInfo(BaseModel):
224
- user_id: constr(min_length=1)
225
- user_type: UserType = UserType.user
226
- email: Optional[str] = None
227
- tenant_name: constr(min_length=1) = Field(alias="tenantName")
228
-
229
- class Config:
230
- allow_population_by_field_name = True
231
- allow_mutation = False
232
-
233
-
234
- class TenantInfo(BaseModel):
235
- tenant_name: constr(min_length=1) = Field(alias="tenantName")
236
- auth_server_url: str
237
-
238
- class Config:
239
- allow_population_by_field_name = True
240
- allow_mutation = False
241
-
242
-
243
- class Token(BaseModel):
244
- access_token: constr(min_length=1) = Field(alias="accessToken", repr=False)
245
- refresh_token: Optional[constr(min_length=1)] = Field(
246
- alias="refreshToken", repr=False
247
- )
248
- decoded_value: Optional[Dict] = Field(exclude=True, repr=False)
249
-
250
- class Config:
251
- allow_population_by_field_name = True
252
- allow_mutation = False
253
-
254
- @validator("decoded_value", always=True, pre=True)
255
- def _decode_jwt(cls, v, values, **kwargs):
256
- access_token = values["access_token"]
257
- return jwt.decode(
258
- access_token,
259
- options={
260
- "verify_signature": False,
261
- "verify_aud": False,
262
- "verify_exp": False,
263
- },
264
- )
265
-
266
- @property
267
- def tenant_name(self) -> str:
268
- return self.decoded_value["tenantName"]
269
-
270
- def is_going_to_be_expired(self, buffer_in_seconds: int = 120) -> bool:
271
- exp = int(self.decoded_value["exp"])
272
- return (exp - time.time()) < buffer_in_seconds
273
-
274
- def to_user_info(self) -> UserInfo:
275
- return UserInfo(
276
- user_id=self.decoded_value["username"],
277
- email=self.decoded_value["email"]
278
- if "email" in self.decoded_value
279
- else None,
280
- user_type=UserType(self.decoded_value.get("userType", UserType.user.value)),
281
- tenant_name=self.tenant_name,
282
- )
283
-
284
-
285
- class CredentialsFileContent(BaseModel):
286
- access_token: constr(min_length=1) = Field(repr=False)
287
- refresh_token: Optional[constr(min_length=1)] = Field(repr=False)
288
- host: constr(min_length=1)
289
-
290
- class Config:
291
- allow_mutation = False
292
-
293
- def to_token(self) -> Token:
294
- return Token(access_token=self.access_token, refresh_token=self.refresh_token)
295
-
296
-
297
- class DeviceCode(BaseModel):
298
- user_code: str = Field(alias="userCode")
299
- device_code: str = Field(alias="deviceCode")
300
- verification_url: Optional[str] = Field(alias="verificationURI")
301
- complete_verification_url: Optional[str] = Field(alias="verificationURIComplete")
302
- expires_in_seconds: int = Field(alias="expiresInSeconds", default=60)
303
- interval_in_seconds: int = Field(alias="intervalInSeconds", default=1)
304
- message: Optional[str] = Field(alias="message")
305
-
306
- class Config:
307
- allow_population_by_field_name = True
308
- allow_mutation = False
309
-
310
- def get_user_clickable_url(self, auth_host: str) -> str:
311
- return f"{auth_host}/authorize/device?userCode={self.user_code}"
312
-
313
-
314
- class PythonSDKConfig(BaseModel):
315
- min_version: str = Field(alias="minVersion")
316
- truefoundry_cli_min_version: str = Field(alias="truefoundryCliMinVersion")
317
- use_sfy_server_auth_apis: Optional[bool] = Field(
318
- alias="useSFYServerAuthAPIs", default=False
319
- )
320
-
321
- class Config:
322
- allow_population_by_field_name = True
323
- allow_mutation = False
324
-
325
-
326
215
  class JobRun(Base):
327
216
  name: str
328
217
  applicationName: str
@@ -3,41 +3,22 @@ from typing import Optional
3
3
 
4
4
  import rich_click as click
5
5
 
6
+ from truefoundry.common.auth_service_client import AuthServiceClient
7
+ from truefoundry.common.constants import TFY_API_KEY_ENV_KEY, TFY_HOST_ENV_KEY
8
+ from truefoundry.common.credential_file_manager import CredentialsFileManager
9
+ from truefoundry.common.credential_provider import EnvCredentialProvider
10
+ from truefoundry.common.entities import CredentialsFileContent, Token
11
+ from truefoundry.common.utils import resolve_base_url
6
12
  from truefoundry.deploy.io.output_callback import OutputCallBack
7
- from truefoundry.deploy.lib.auth.auth_service_client import AuthServiceClient
8
- from truefoundry.deploy.lib.auth.credential_file_manager import CredentialsFileManager
9
- from truefoundry.deploy.lib.auth.credential_provider import EnvCredentialProvider
10
- from truefoundry.deploy.lib.clients.servicefoundry_client import (
11
- ServiceFoundryServiceClient,
12
- )
13
- from truefoundry.deploy.lib.clients.utils import resolve_base_url
14
13
  from truefoundry.deploy.lib.const import (
15
- API_KEY_ENV_NAME,
16
- HOST_ENV_NAME,
17
- OLD_SFY_PROFILES_FILEPATH,
18
- OLD_SFY_SESSIONS_FILEPATH,
19
14
  RICH_OUTPUT_CALLBACK,
20
15
  )
21
16
  from truefoundry.deploy.lib.messages import (
22
17
  PROMPT_ALREADY_LOGGED_OUT,
23
18
  PROMPT_LOGOUT_SUCCESSFUL,
24
19
  )
25
- from truefoundry.deploy.lib.model.entity import CredentialsFileContent, Token
26
20
  from truefoundry.logger import logger
27
21
 
28
- if OLD_SFY_PROFILES_FILEPATH.exists():
29
- logger.warning(
30
- "%s file is deprecated. You can delete this file now.",
31
- OLD_SFY_PROFILES_FILEPATH,
32
- )
33
-
34
-
35
- if OLD_SFY_SESSIONS_FILEPATH.exists():
36
- logger.warning(
37
- "%s file is deprecated. You can delete this file now.",
38
- OLD_SFY_SESSIONS_FILEPATH,
39
- )
40
-
41
22
 
42
23
  def login(
43
24
  api_key: Optional[str] = None,
@@ -45,13 +26,13 @@ def login(
45
26
  relogin: bool = False,
46
27
  output_hook: OutputCallBack = RICH_OUTPUT_CALLBACK,
47
28
  ) -> bool:
48
- if API_KEY_ENV_NAME in os.environ and HOST_ENV_NAME in os.environ:
29
+ if TFY_API_KEY_ENV_KEY in os.environ and TFY_HOST_ENV_KEY in os.environ:
49
30
  logger.warning(
50
31
  "Skipping login because environment variables %s and "
51
32
  "%s are set and will be used when running truefoundry. "
52
33
  "If you want to relogin then unset these environment keys.",
53
- HOST_ENV_NAME,
54
- API_KEY_ENV_NAME,
34
+ TFY_HOST_ENV_KEY,
35
+ TFY_API_KEY_ENV_KEY,
55
36
  )
56
37
  return False
57
38
 
@@ -85,12 +66,7 @@ def login(
85
66
  return False
86
67
 
87
68
  if api_key:
88
- servicefoundry_client = ServiceFoundryServiceClient(
89
- init_session=False, base_url=host
90
- )
91
- token = _login_with_api_key(
92
- api_key=api_key, servicefoundry_client=servicefoundry_client
93
- )
69
+ token = Token(access_token=api_key, refresh_token=None)
94
70
  else:
95
71
  auth_service = AuthServiceClient.from_base_url(base_url=host)
96
72
  # interactive login
@@ -122,13 +98,6 @@ def logout(
122
98
  output_hook.print_line(PROMPT_ALREADY_LOGGED_OUT)
123
99
 
124
100
 
125
- def _login_with_api_key(
126
- api_key: str, servicefoundry_client: ServiceFoundryServiceClient
127
- ) -> Token:
128
- logger.debug("Logging in with api key")
129
- return servicefoundry_client.get_token_from_api_key(api_key=api_key)
130
-
131
-
132
101
  def _login_with_device_code(
133
102
  base_url: str,
134
103
  auth_service: AuthServiceClient,
@@ -144,7 +113,10 @@ def _login_with_device_code(
144
113
  if device_code.message:
145
114
  message = device_code.message
146
115
  else:
147
- message = f"Please open the following URL in a browser and enter the code {device_code.user_code} when prompted: {device_code.verification_url}"
116
+ message = (
117
+ f"Please open the following URL in a browser and enter the code {device_code.user_code} "
118
+ f"when prompted: {device_code.verification_url}"
119
+ )
148
120
  else:
149
121
  auto_open_url = device_code.get_user_clickable_url(auth_host=base_url)
150
122
  if auto_open_url:
@@ -1,7 +1,5 @@
1
1
  import os
2
2
  import re
3
- from functools import lru_cache, wraps
4
- from time import monotonic_ns
5
3
  from typing import Union
6
4
 
7
5
  from truefoundry.deploy.lib.const import (
@@ -41,23 +39,6 @@ def get_deployment_fqn_from_application_fqn(
41
39
  return f"{application_fqn}:{version}"
42
40
 
43
41
 
44
- def is_notebook():
45
- # https://stackoverflow.com/questions/15411967/how-can-i-check-if-code-is-executed-in-the-ipython-notebook
46
- try:
47
- # noinspection PyUnresolvedReferences
48
- shell = get_ipython().__class__
49
- if shell.__name__ == "ZMQInteractiveShell":
50
- return True # Jupyter notebook or qtconsole
51
- elif shell.__name__ == "TerminalInteractiveShell":
52
- return False # Terminal running IPython
53
- elif "google.colab" in str(shell):
54
- return True # google colab notebook
55
- else:
56
- return False # Other type (?)
57
- except NameError:
58
- return False # Probably standard Python interpreter
59
-
60
-
61
42
  def find_list_paths(data, parent_key="", sep="."):
62
43
  list_paths = []
63
44
  if isinstance(data, dict):
@@ -70,21 +51,3 @@ def find_list_paths(data, parent_key="", sep="."):
70
51
  new_key = f"{parent_key}[{i}]"
71
52
  list_paths.extend(find_list_paths(value, new_key, sep))
72
53
  return list_paths
73
-
74
-
75
- def timed_lru_cache(seconds: int = 300, maxsize: int = None):
76
- def wrapper_cache(func):
77
- func = lru_cache(maxsize=maxsize)(func)
78
- func.delta = seconds * 10**9
79
- func.expiration = monotonic_ns() + func.delta
80
-
81
- @wraps(func)
82
- def wrapped_func(*args, **kwargs):
83
- if monotonic_ns() >= func.expiration:
84
- func.cache_clear()
85
- func.expiration = monotonic_ns() + func.delta
86
- return func(*args, **kwargs)
87
-
88
- return wrapped_func
89
-
90
- return wrapper_cache
@@ -101,11 +101,11 @@ def add_local_source_comment(code):
101
101
  return "\n".join(new_lines)
102
102
 
103
103
 
104
- def convert_deployment_config_to_python(workspace_fqn: str, deployment_config: dict):
104
+ def convert_deployment_config_to_python(workspace_fqn: str, application_spec: dict):
105
105
  """
106
106
  Convert a deployment config to a python file that can be used to deploy to a workspace
107
107
  """
108
- application = Application.parse_obj(deployment_config)
108
+ application = Application.parse_obj(application_spec)
109
109
  application_type = application.__root__.type
110
110
 
111
111
  spec_repr = get_python_repr(application.__root__)
@@ -4,12 +4,12 @@ from typing import List, Optional, TypeVar
4
4
 
5
5
  from rich.status import Status
6
6
 
7
+ from truefoundry.common.utils import poll_for_function
7
8
  from truefoundry.deploy.auto_gen import models as auto_gen_models
8
9
  from truefoundry.deploy.builder.docker_service import env_has_docker
9
10
  from truefoundry.deploy.lib.clients.servicefoundry_client import (
10
11
  ServiceFoundryServiceClient,
11
12
  )
12
- from truefoundry.deploy.lib.clients.utils import poll_for_function
13
13
  from truefoundry.deploy.lib.dao.workspace import get_workspace_by_fqn
14
14
  from truefoundry.deploy.lib.model.entity import Deployment, DeploymentTransitionStatus
15
15
  from truefoundry.deploy.lib.util import get_application_fqn_from_deployment_fqn
@@ -45,7 +45,7 @@ def _handle_if_local_source(component: Component, workspace_fqn: str) -> Compone
45
45
  local_build = False
46
46
  else:
47
47
  logger.info(
48
- "Found locally installed docker, image will be built locally and then pushed. "
48
+ "Found locally installed docker, image will be built locally and then pushed.\n"
49
49
  "If you want to always build remotely instead of locally, "
50
50
  "please set `image.build_source.local_build` to `false` in your YAML spec or equivalently set "
51
51
  "`image=Build(build_source=LocalSource(local_build=False, ...))` in your "
@@ -72,7 +72,7 @@ def _handle_if_local_source(component: Component, workspace_fqn: str) -> Compone
72
72
  component_name=component.name,
73
73
  )
74
74
  else:
75
- # We'll build image on Truefoundry servers, upload the source and update image.build_source
75
+ # We'll build image on TrueFoundry servers, upload the source and update image.build_source
76
76
  logger.info("Uploading code for %s '%s'", component.type, component.name)
77
77
  new_component.image.build_source = local_source_to_remote_source(
78
78
  local_source=component.image.build_source,
@@ -81,7 +81,7 @@ class Application(models.Application, DeployablePatchedModelBase):
81
81
  class Workflow(models.Workflow, DeployablePatchedModelBase):
82
82
  type: Literal["workflow"] = "workflow"
83
83
  source: Union[models.RemoteSource, models.LocalSource] = Field(
84
- default_factory=LocalSource
84
+ default_factory=lambda: LocalSource(local_build=False)
85
85
  )
86
86
 
87
87
  def deploy(self, workspace_fqn: str, wait: bool = True) -> Deployment:
@@ -10,8 +10,8 @@ from langchain.schema.messages import (
10
10
  SystemMessage,
11
11
  )
12
12
 
13
+ from truefoundry.common.request_utils import requests_retry_session
13
14
  from truefoundry.langchain.utils import (
14
- requests_retry_session,
15
15
  validate_tfy_environment,
16
16
  )
17
17
  from truefoundry.logger import logger
@@ -6,8 +6,8 @@ import tqdm
6
6
  from langchain.embeddings.base import Embeddings
7
7
  from langchain.pydantic_v1 import BaseModel, Extra, Field, root_validator
8
8
 
9
+ from truefoundry.common.request_utils import requests_retry_session
9
10
  from truefoundry.langchain.utils import (
10
- requests_retry_session,
11
11
  validate_tfy_environment,
12
12
  )
13
13
  from truefoundry.logger import logger
@@ -3,8 +3,8 @@ from typing import Any, Dict, List, Optional
3
3
  from langchain.llms.base import LLM
4
4
  from langchain.pydantic_v1 import Extra, Field, root_validator
5
5
 
6
+ from truefoundry.common.request_utils import requests_retry_session
6
7
  from truefoundry.langchain.utils import (
7
- requests_retry_session,
8
8
  validate_tfy_environment,
9
9
  )
10
10
  from truefoundry.logger import logger
@@ -2,10 +2,7 @@ import os
2
2
  from typing import Dict, List, Optional
3
3
  from urllib.parse import urljoin
4
4
 
5
- import requests
6
5
  from langchain.pydantic_v1 import BaseModel
7
- from requests.adapters import HTTPAdapter
8
- from urllib3.util.retry import Retry
9
6
 
10
7
  from truefoundry.deploy.lib.auth.servicefoundry_session import ServiceFoundrySession
11
8
 
@@ -45,41 +42,3 @@ def validate_tfy_environment(values: Dict):
45
42
  values["tfy_llm_gateway_url"] = gateway_url
46
43
  values["tfy_api_key"] = api_key
47
44
  return values
48
-
49
-
50
- def requests_retry_session(
51
- retries=5,
52
- backoff_factor=0.3,
53
- status_forcelist=(500, 502, 503, 504),
54
- method_whitelist=frozenset({"GET", "POST"}),
55
- session=None,
56
- ):
57
- """
58
- Returns a `requests` session with retry capabilities for certain HTTP status codes.
59
-
60
- Args:
61
- retries (int): The number of retries for HTTP requests.
62
- backoff_factor (float): The backoff factor for exponential backoff during retries.
63
- status_forcelist (tuple): A tuple of HTTP status codes that should trigger a retry.
64
- method_whitelist (frozenset): The set of HTTP methods that should be retried.
65
- session (requests.Session, optional): An optional existing requests session to use.
66
-
67
- Returns:
68
- requests.Session: A session with retry capabilities.
69
- """
70
- # Implementation taken from https://www.peterbe.com/plog/best-practice-with-retries-with-requests
71
- session = session or requests.Session()
72
- retry = Retry(
73
- total=retries,
74
- read=retries,
75
- connect=retries,
76
- status=retries,
77
- backoff_factor=backoff_factor,
78
- allowed_methods=method_whitelist,
79
- status_forcelist=status_forcelist,
80
- respect_retry_after_header=True,
81
- )
82
- adapter = HTTPAdapter(max_retries=retry)
83
- session.mount("http://", adapter)
84
- session.mount("https://", adapter)
85
- return session
@@ -1,6 +1,37 @@
1
- try:
2
- from mlfoundry import * # noqa: F403
3
- except ImportError:
4
- print(
5
- "To use metadata/artifact logging features, please run 'pip install truefoundry[ml]'."
6
- )
1
+ from truefoundry.ml.enums import (
2
+ DataSlice,
3
+ FileFormat,
4
+ ModelFramework,
5
+ ModelType,
6
+ ViewType,
7
+ )
8
+ from truefoundry.ml.exceptions import MlFoundryException
9
+ from truefoundry.ml.log_types import Image, Plot
10
+ from truefoundry.ml.log_types.artifacts.artifact import ArtifactPath, ArtifactVersion
11
+ from truefoundry.ml.log_types.artifacts.dataset import DataDirectory, DataDirectoryPath
12
+ from truefoundry.ml.log_types.artifacts.model import (
13
+ ModelVersion,
14
+ )
15
+ from truefoundry.ml.logger import init_logger
16
+ from truefoundry.ml.mlfoundry_api import get_client
17
+ from truefoundry.ml.mlfoundry_run import MlFoundryRun
18
+
19
+ __all__ = [
20
+ "ArtifactPath",
21
+ "ArtifactVersion",
22
+ "DataDirectory",
23
+ "DataDirectoryPath",
24
+ "DataSlice",
25
+ "FileFormat",
26
+ "Image",
27
+ "MlFoundryRun",
28
+ "MlFoundryException",
29
+ "ModelFramework",
30
+ "ModelType",
31
+ "ModelVersion",
32
+ "Plot",
33
+ "ViewType",
34
+ "get_client",
35
+ ]
36
+
37
+ init_logger()
File without changes