zenml-nightly 0.58.2.dev20240617__py3-none-any.whl → 0.58.2.dev20240619__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.
Files changed (312) hide show
  1. zenml/VERSION +1 -1
  2. zenml/_hub/client.py +8 -5
  3. zenml/actions/base_action.py +8 -10
  4. zenml/artifact_stores/base_artifact_store.py +20 -15
  5. zenml/artifact_stores/local_artifact_store.py +3 -2
  6. zenml/artifacts/artifact_config.py +34 -19
  7. zenml/artifacts/external_artifact.py +18 -8
  8. zenml/artifacts/external_artifact_config.py +14 -6
  9. zenml/artifacts/unmaterialized_artifact.py +2 -11
  10. zenml/cli/__init__.py +6 -0
  11. zenml/cli/artifact.py +20 -2
  12. zenml/cli/served_model.py +0 -1
  13. zenml/cli/server.py +3 -3
  14. zenml/cli/utils.py +36 -40
  15. zenml/cli/web_login.py +2 -2
  16. zenml/client.py +198 -24
  17. zenml/client_lazy_loader.py +20 -14
  18. zenml/config/base_settings.py +5 -6
  19. zenml/config/build_configuration.py +1 -1
  20. zenml/config/compiler.py +3 -3
  21. zenml/config/docker_settings.py +27 -28
  22. zenml/config/global_config.py +33 -37
  23. zenml/config/pipeline_configurations.py +8 -11
  24. zenml/config/pipeline_run_configuration.py +6 -2
  25. zenml/config/pipeline_spec.py +3 -4
  26. zenml/config/resource_settings.py +8 -9
  27. zenml/config/schedule.py +16 -20
  28. zenml/config/secret_reference_mixin.py +6 -3
  29. zenml/config/secrets_store_config.py +16 -23
  30. zenml/config/server_config.py +50 -46
  31. zenml/config/settings_resolver.py +1 -1
  32. zenml/config/source.py +45 -35
  33. zenml/config/step_configurations.py +53 -31
  34. zenml/config/step_run_info.py +3 -0
  35. zenml/config/store_config.py +20 -19
  36. zenml/config/strict_base_model.py +2 -6
  37. zenml/constants.py +26 -2
  38. zenml/container_registries/base_container_registry.py +3 -2
  39. zenml/container_registries/default_container_registry.py +3 -3
  40. zenml/event_hub/base_event_hub.py +1 -1
  41. zenml/event_sources/base_event_source.py +11 -16
  42. zenml/exceptions.py +4 -0
  43. zenml/integrations/airflow/__init__.py +2 -6
  44. zenml/integrations/airflow/flavors/airflow_orchestrator_flavor.py +6 -7
  45. zenml/integrations/airflow/orchestrators/airflow_orchestrator.py +13 -249
  46. zenml/integrations/airflow/orchestrators/dag_generator.py +5 -3
  47. zenml/integrations/argilla/flavors/argilla_annotator_flavor.py +5 -4
  48. zenml/integrations/aws/__init__.py +1 -1
  49. zenml/integrations/aws/flavors/aws_container_registry_flavor.py +3 -2
  50. zenml/integrations/aws/flavors/sagemaker_orchestrator_flavor.py +11 -5
  51. zenml/integrations/aws/flavors/sagemaker_step_operator_flavor.py +6 -2
  52. zenml/integrations/aws/service_connectors/aws_service_connector.py +5 -4
  53. zenml/integrations/aws/step_operators/sagemaker_step_operator.py +1 -1
  54. zenml/integrations/azure/flavors/azureml_step_operator_flavor.py +4 -4
  55. zenml/integrations/azure/service_connectors/azure_service_connector.py +4 -3
  56. zenml/integrations/azure/step_operators/azureml_step_operator.py +2 -1
  57. zenml/integrations/bentoml/steps/bentoml_deployer.py +1 -1
  58. zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +8 -12
  59. zenml/integrations/comet/flavors/comet_experiment_tracker_flavor.py +1 -1
  60. zenml/integrations/constants.py +0 -1
  61. zenml/integrations/deepchecks/__init__.py +1 -0
  62. zenml/integrations/evidently/__init__.py +5 -3
  63. zenml/integrations/evidently/column_mapping.py +11 -3
  64. zenml/integrations/evidently/data_validators/evidently_data_validator.py +21 -3
  65. zenml/integrations/evidently/metrics.py +5 -6
  66. zenml/integrations/evidently/tests.py +5 -6
  67. zenml/integrations/facets/models.py +2 -6
  68. zenml/integrations/feast/__init__.py +3 -1
  69. zenml/integrations/feast/feature_stores/feast_feature_store.py +0 -23
  70. zenml/integrations/gcp/__init__.py +1 -1
  71. zenml/integrations/gcp/flavors/vertex_orchestrator_flavor.py +1 -1
  72. zenml/integrations/gcp/flavors/vertex_step_operator_flavor.py +1 -1
  73. zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +234 -103
  74. zenml/integrations/gcp/service_connectors/gcp_service_connector.py +57 -42
  75. zenml/integrations/gcp/step_operators/vertex_step_operator.py +1 -0
  76. zenml/integrations/github/code_repositories/github_code_repository.py +1 -1
  77. zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py +9 -13
  78. zenml/integrations/great_expectations/__init__.py +1 -1
  79. zenml/integrations/great_expectations/data_validators/ge_data_validator.py +44 -44
  80. zenml/integrations/great_expectations/flavors/great_expectations_data_validator_flavor.py +35 -2
  81. zenml/integrations/great_expectations/ge_store_backend.py +24 -11
  82. zenml/integrations/great_expectations/materializers/ge_materializer.py +3 -3
  83. zenml/integrations/great_expectations/utils.py +5 -5
  84. zenml/integrations/huggingface/__init__.py +3 -0
  85. zenml/integrations/huggingface/flavors/huggingface_model_deployer_flavor.py +1 -1
  86. zenml/integrations/huggingface/steps/__init__.py +3 -0
  87. zenml/integrations/huggingface/steps/accelerate_runner.py +149 -0
  88. zenml/integrations/huggingface/steps/huggingface_deployer.py +2 -2
  89. zenml/integrations/hyperai/flavors/hyperai_orchestrator_flavor.py +1 -1
  90. zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py +4 -3
  91. zenml/integrations/kubeflow/__init__.py +1 -1
  92. zenml/integrations/kubeflow/flavors/kubeflow_orchestrator_flavor.py +48 -81
  93. zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py +295 -245
  94. zenml/integrations/kubernetes/flavors/kubernetes_orchestrator_flavor.py +1 -1
  95. zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py +11 -2
  96. zenml/integrations/kubernetes/pod_settings.py +17 -31
  97. zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py +8 -7
  98. zenml/integrations/label_studio/__init__.py +1 -3
  99. zenml/integrations/label_studio/annotators/label_studio_annotator.py +3 -4
  100. zenml/integrations/label_studio/flavors/label_studio_annotator_flavor.py +2 -2
  101. zenml/integrations/langchain/__init__.py +5 -1
  102. zenml/integrations/langchain/materializers/document_materializer.py +44 -8
  103. zenml/integrations/mlflow/__init__.py +9 -3
  104. zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py +1 -1
  105. zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py +29 -37
  106. zenml/integrations/mlflow/model_registries/mlflow_model_registry.py +4 -4
  107. zenml/integrations/mlflow/steps/mlflow_deployer.py +1 -1
  108. zenml/integrations/neptune/flavors/neptune_experiment_tracker_flavor.py +1 -1
  109. zenml/integrations/neural_prophet/__init__.py +5 -1
  110. zenml/integrations/pigeon/flavors/pigeon_annotator_flavor.py +1 -1
  111. zenml/integrations/s3/flavors/s3_artifact_store_flavor.py +9 -8
  112. zenml/integrations/seldon/seldon_client.py +52 -67
  113. zenml/integrations/seldon/services/seldon_deployment.py +3 -3
  114. zenml/integrations/seldon/steps/seldon_deployer.py +4 -4
  115. zenml/integrations/skypilot/flavors/skypilot_orchestrator_base_vm_config.py +15 -5
  116. zenml/integrations/skypilot_aws/__init__.py +1 -1
  117. zenml/integrations/skypilot_aws/flavors/skypilot_orchestrator_aws_vm_flavor.py +1 -1
  118. zenml/integrations/skypilot_azure/__init__.py +1 -1
  119. zenml/integrations/skypilot_azure/flavors/skypilot_orchestrator_azure_vm_flavor.py +1 -1
  120. zenml/integrations/skypilot_gcp/__init__.py +2 -1
  121. zenml/integrations/skypilot_gcp/flavors/skypilot_orchestrator_gcp_vm_flavor.py +1 -1
  122. zenml/integrations/skypilot_lambda/flavors/skypilot_orchestrator_lambda_vm_flavor.py +2 -2
  123. zenml/integrations/spark/flavors/spark_step_operator_flavor.py +1 -1
  124. zenml/integrations/spark/step_operators/spark_step_operator.py +2 -0
  125. zenml/integrations/tekton/__init__.py +1 -1
  126. zenml/integrations/tekton/flavors/tekton_orchestrator_flavor.py +66 -23
  127. zenml/integrations/tekton/orchestrators/tekton_orchestrator.py +547 -233
  128. zenml/integrations/tensorboard/__init__.py +1 -12
  129. zenml/integrations/tensorboard/services/tensorboard_service.py +3 -5
  130. zenml/integrations/tensorboard/visualizers/tensorboard_visualizer.py +6 -6
  131. zenml/integrations/tensorflow/__init__.py +2 -10
  132. zenml/integrations/tensorflow/materializers/keras_materializer.py +17 -9
  133. zenml/integrations/wandb/flavors/wandb_experiment_tracker_flavor.py +9 -14
  134. zenml/integrations/whylogs/flavors/whylogs_data_validator_flavor.py +1 -1
  135. zenml/lineage_graph/lineage_graph.py +1 -1
  136. zenml/logging/step_logging.py +15 -7
  137. zenml/materializers/built_in_materializer.py +3 -3
  138. zenml/materializers/pydantic_materializer.py +2 -2
  139. zenml/metadata/lazy_load.py +4 -4
  140. zenml/metadata/metadata_types.py +64 -4
  141. zenml/model/model.py +79 -54
  142. zenml/model_deployers/base_model_deployer.py +14 -12
  143. zenml/model_registries/base_model_registry.py +17 -15
  144. zenml/models/__init__.py +79 -206
  145. zenml/models/v2/base/base.py +54 -41
  146. zenml/models/v2/base/base_plugin_flavor.py +2 -6
  147. zenml/models/v2/base/filter.py +91 -76
  148. zenml/models/v2/base/page.py +2 -12
  149. zenml/models/v2/base/scoped.py +4 -7
  150. zenml/models/v2/core/api_key.py +22 -8
  151. zenml/models/v2/core/artifact.py +2 -2
  152. zenml/models/v2/core/artifact_version.py +74 -40
  153. zenml/models/v2/core/code_repository.py +37 -10
  154. zenml/models/v2/core/component.py +65 -16
  155. zenml/models/v2/core/device.py +14 -4
  156. zenml/models/v2/core/event_source.py +1 -2
  157. zenml/models/v2/core/flavor.py +74 -8
  158. zenml/models/v2/core/logs.py +68 -8
  159. zenml/models/v2/core/model.py +8 -4
  160. zenml/models/v2/core/model_version.py +25 -6
  161. zenml/models/v2/core/model_version_artifact.py +51 -21
  162. zenml/models/v2/core/model_version_pipeline_run.py +45 -13
  163. zenml/models/v2/core/pipeline.py +37 -72
  164. zenml/models/v2/core/pipeline_build.py +29 -17
  165. zenml/models/v2/core/pipeline_deployment.py +18 -6
  166. zenml/models/v2/core/pipeline_namespace.py +113 -0
  167. zenml/models/v2/core/pipeline_run.py +50 -22
  168. zenml/models/v2/core/run_metadata.py +59 -36
  169. zenml/models/v2/core/schedule.py +37 -24
  170. zenml/models/v2/core/secret.py +31 -12
  171. zenml/models/v2/core/service.py +64 -36
  172. zenml/models/v2/core/service_account.py +24 -11
  173. zenml/models/v2/core/service_connector.py +219 -44
  174. zenml/models/v2/core/stack.py +45 -17
  175. zenml/models/v2/core/step_run.py +28 -8
  176. zenml/models/v2/core/tag.py +8 -4
  177. zenml/models/v2/core/trigger.py +2 -2
  178. zenml/models/v2/core/trigger_execution.py +1 -0
  179. zenml/models/v2/core/user.py +18 -21
  180. zenml/models/v2/core/workspace.py +13 -3
  181. zenml/models/v2/misc/build_item.py +3 -3
  182. zenml/models/v2/misc/external_user.py +2 -6
  183. zenml/models/v2/misc/hub_plugin_models.py +9 -9
  184. zenml/models/v2/misc/loaded_visualization.py +2 -2
  185. zenml/models/v2/misc/service_connector_type.py +8 -17
  186. zenml/models/v2/misc/user_auth.py +7 -2
  187. zenml/new/pipelines/build_utils.py +3 -3
  188. zenml/new/pipelines/pipeline.py +17 -13
  189. zenml/new/pipelines/run_utils.py +103 -1
  190. zenml/orchestrators/base_orchestrator.py +10 -7
  191. zenml/orchestrators/local_docker/local_docker_orchestrator.py +1 -1
  192. zenml/orchestrators/step_launcher.py +28 -4
  193. zenml/orchestrators/step_runner.py +3 -6
  194. zenml/orchestrators/utils.py +1 -1
  195. zenml/plugins/base_plugin_flavor.py +6 -10
  196. zenml/plugins/plugin_flavor_registry.py +3 -7
  197. zenml/secret/base_secret.py +7 -8
  198. zenml/service_connectors/docker_service_connector.py +4 -3
  199. zenml/service_connectors/service_connector.py +5 -12
  200. zenml/service_connectors/service_connector_registry.py +2 -4
  201. zenml/services/container/container_service.py +1 -1
  202. zenml/services/container/container_service_endpoint.py +1 -1
  203. zenml/services/local/local_service.py +1 -1
  204. zenml/services/local/local_service_endpoint.py +1 -1
  205. zenml/services/service.py +16 -10
  206. zenml/services/service_type.py +4 -5
  207. zenml/services/terraform/terraform_service.py +1 -1
  208. zenml/stack/flavor.py +1 -5
  209. zenml/stack/flavor_registry.py +4 -4
  210. zenml/stack/stack.py +4 -1
  211. zenml/stack/stack_component.py +55 -31
  212. zenml/step_operators/step_operator_entrypoint_configuration.py +1 -0
  213. zenml/steps/base_step.py +34 -28
  214. zenml/steps/entrypoint_function_utils.py +3 -5
  215. zenml/steps/utils.py +12 -14
  216. zenml/utils/cuda_utils.py +50 -0
  217. zenml/utils/deprecation_utils.py +18 -20
  218. zenml/utils/dict_utils.py +1 -1
  219. zenml/utils/filesync_model.py +65 -28
  220. zenml/utils/function_utils.py +260 -0
  221. zenml/utils/json_utils.py +131 -0
  222. zenml/utils/mlstacks_utils.py +2 -2
  223. zenml/utils/pipeline_docker_image_builder.py +9 -0
  224. zenml/utils/pydantic_utils.py +270 -62
  225. zenml/utils/secret_utils.py +65 -12
  226. zenml/utils/source_utils.py +2 -2
  227. zenml/utils/typed_model.py +5 -3
  228. zenml/utils/typing_utils.py +243 -0
  229. zenml/utils/yaml_utils.py +1 -1
  230. zenml/zen_server/auth.py +2 -2
  231. zenml/zen_server/cloud_utils.py +6 -6
  232. zenml/zen_server/deploy/base_provider.py +1 -1
  233. zenml/zen_server/deploy/deployment.py +6 -8
  234. zenml/zen_server/deploy/docker/docker_zen_server.py +3 -4
  235. zenml/zen_server/deploy/local/local_provider.py +0 -1
  236. zenml/zen_server/deploy/local/local_zen_server.py +6 -6
  237. zenml/zen_server/deploy/terraform/terraform_zen_server.py +4 -6
  238. zenml/zen_server/exceptions.py +4 -1
  239. zenml/zen_server/feature_gate/zenml_cloud_feature_gate.py +1 -1
  240. zenml/zen_server/pipeline_deployment/utils.py +48 -68
  241. zenml/zen_server/rbac/models.py +2 -5
  242. zenml/zen_server/rbac/utils.py +11 -14
  243. zenml/zen_server/routers/auth_endpoints.py +2 -2
  244. zenml/zen_server/routers/pipeline_builds_endpoints.py +1 -1
  245. zenml/zen_server/routers/runs_endpoints.py +1 -1
  246. zenml/zen_server/routers/secrets_endpoints.py +3 -2
  247. zenml/zen_server/routers/server_endpoints.py +1 -1
  248. zenml/zen_server/routers/steps_endpoints.py +1 -1
  249. zenml/zen_server/routers/workspaces_endpoints.py +1 -1
  250. zenml/zen_stores/base_zen_store.py +46 -9
  251. zenml/zen_stores/migrations/utils.py +42 -46
  252. zenml/zen_stores/migrations/versions/0701da9951a0_added_service_table.py +1 -1
  253. zenml/zen_stores/migrations/versions/1041bc644e0d_remove_secrets_manager.py +5 -3
  254. zenml/zen_stores/migrations/versions/10a907dad202_delete_mlmd_tables.py +1 -1
  255. zenml/zen_stores/migrations/versions/26b776ad583e_redesign_artifacts.py +8 -10
  256. zenml/zen_stores/migrations/versions/37835ce041d2_optimizing_database.py +3 -3
  257. zenml/zen_stores/migrations/versions/46506f72f0ed_add_server_settings.py +10 -12
  258. zenml/zen_stores/migrations/versions/5994f9ad0489_introduce_role_permissions.py +3 -2
  259. zenml/zen_stores/migrations/versions/6917bce75069_add_pipeline_run_unique_constraint.py +4 -4
  260. zenml/zen_stores/migrations/versions/728c6369cfaa_add_name_column_to_input_artifact_pk.py +3 -2
  261. zenml/zen_stores/migrations/versions/743ec82b1b3c_update_size_of_build_images.py +2 -2
  262. zenml/zen_stores/migrations/versions/7500f434b71c_remove_shared_columns.py +3 -2
  263. zenml/zen_stores/migrations/versions/7834208cc3f6_artifact_project_scoping.py +8 -7
  264. zenml/zen_stores/migrations/versions/7b651bf6822e_track_secrets_in_db.py +6 -4
  265. zenml/zen_stores/migrations/versions/7e4a481d17f7_add_identity_table.py +2 -2
  266. zenml/zen_stores/migrations/versions/7f603e583dd7_fixed_migration.py +1 -1
  267. zenml/zen_stores/migrations/versions/a39c4184c8ce_remove_secrets_manager_flavors.py +2 -2
  268. zenml/zen_stores/migrations/versions/a91762e6be36_artifact_version_table.py +4 -4
  269. zenml/zen_stores/migrations/versions/alembic_start.py +1 -1
  270. zenml/zen_stores/migrations/versions/fbd7f18ced1e_increase_step_run_field_lengths.py +4 -4
  271. zenml/zen_stores/rest_zen_store.py +109 -49
  272. zenml/zen_stores/schemas/api_key_schemas.py +1 -1
  273. zenml/zen_stores/schemas/artifact_schemas.py +8 -8
  274. zenml/zen_stores/schemas/artifact_visualization_schemas.py +3 -3
  275. zenml/zen_stores/schemas/code_repository_schemas.py +1 -1
  276. zenml/zen_stores/schemas/component_schemas.py +8 -3
  277. zenml/zen_stores/schemas/device_schemas.py +8 -6
  278. zenml/zen_stores/schemas/event_source_schemas.py +3 -4
  279. zenml/zen_stores/schemas/flavor_schemas.py +5 -3
  280. zenml/zen_stores/schemas/model_schemas.py +26 -1
  281. zenml/zen_stores/schemas/pipeline_build_schemas.py +1 -1
  282. zenml/zen_stores/schemas/pipeline_deployment_schemas.py +4 -4
  283. zenml/zen_stores/schemas/pipeline_run_schemas.py +6 -6
  284. zenml/zen_stores/schemas/pipeline_schemas.py +5 -2
  285. zenml/zen_stores/schemas/run_metadata_schemas.py +2 -2
  286. zenml/zen_stores/schemas/secret_schemas.py +8 -5
  287. zenml/zen_stores/schemas/server_settings_schemas.py +3 -1
  288. zenml/zen_stores/schemas/service_connector_schemas.py +1 -1
  289. zenml/zen_stores/schemas/service_schemas.py +11 -2
  290. zenml/zen_stores/schemas/stack_schemas.py +1 -1
  291. zenml/zen_stores/schemas/step_run_schemas.py +11 -11
  292. zenml/zen_stores/schemas/tag_schemas.py +6 -2
  293. zenml/zen_stores/schemas/trigger_schemas.py +2 -2
  294. zenml/zen_stores/schemas/user_schemas.py +2 -2
  295. zenml/zen_stores/schemas/workspace_schemas.py +3 -1
  296. zenml/zen_stores/secrets_stores/aws_secrets_store.py +19 -20
  297. zenml/zen_stores/secrets_stores/azure_secrets_store.py +17 -20
  298. zenml/zen_stores/secrets_stores/base_secrets_store.py +79 -12
  299. zenml/zen_stores/secrets_stores/gcp_secrets_store.py +17 -20
  300. zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py +4 -8
  301. zenml/zen_stores/secrets_stores/service_connector_secrets_store.py +10 -7
  302. zenml/zen_stores/secrets_stores/sql_secrets_store.py +5 -6
  303. zenml/zen_stores/sql_zen_store.py +196 -120
  304. zenml/zen_stores/zen_store_interface.py +33 -0
  305. {zenml_nightly-0.58.2.dev20240617.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/METADATA +9 -7
  306. {zenml_nightly-0.58.2.dev20240617.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/RECORD +309 -306
  307. zenml/integrations/kubeflow/utils.py +0 -95
  308. zenml/models/v2/base/internal.py +0 -37
  309. zenml/models/v2/base/update.py +0 -44
  310. {zenml_nightly-0.58.2.dev20240617.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/LICENSE +0 -0
  311. {zenml_nightly-0.58.2.dev20240617.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/WHEEL +0 -0
  312. {zenml_nightly-0.58.2.dev20240617.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/entry_points.txt +0 -0
@@ -16,7 +16,7 @@
16
16
  from typing import Optional
17
17
  from uuid import UUID
18
18
 
19
- from pydantic import BaseModel
19
+ from pydantic import BaseModel, ConfigDict
20
20
 
21
21
  from zenml.utils.enum_utils import StrEnum
22
22
 
@@ -89,7 +89,4 @@ class Resource(BaseModel):
89
89
 
90
90
  return representation
91
91
 
92
- class Config:
93
- """Pydantic configuration class."""
94
-
95
- frozen = True
92
+ model_config = ConfigDict(frozen=True)
@@ -72,7 +72,7 @@ def dehydrate_page(page: Page[AnyResponse]) -> Page[AnyResponse]:
72
72
  for item in page.items
73
73
  ]
74
74
 
75
- return page.copy(update={"items": new_items})
75
+ return page.model_copy(update={"items": new_items})
76
76
 
77
77
 
78
78
  def dehydrate_response_model(
@@ -103,15 +103,12 @@ def dehydrate_response_model(
103
103
  )
104
104
 
105
105
  dehydrated_values = {}
106
- for key, value in model.__dict__.items():
107
- if key in model.__private_attributes__:
108
- dehydrated_values[key] = value
109
- else:
110
- dehydrated_values[key] = _dehydrate_value(
111
- value, permissions=permissions
112
- )
106
+ for key, value in dict(model).items():
107
+ dehydrated_values[key] = _dehydrate_value(
108
+ value, permissions=permissions
109
+ )
113
110
 
114
- return type(model).parse_obj(dehydrated_values)
111
+ return type(model).model_validate(dehydrated_values)
115
112
 
116
113
 
117
114
  def _dehydrate_value(
@@ -144,6 +141,8 @@ def _dehydrate_value(
144
141
  return dehydrate_response_model(value, permissions=permissions)
145
142
  else:
146
143
  return get_permission_denied_model(value)
144
+ elif isinstance(value, Page):
145
+ return dehydrate_page(page=value)
147
146
  elif isinstance(value, BaseModel):
148
147
  return dehydrate_response_model(value, permissions=permissions)
149
148
  elif isinstance(value, Dict):
@@ -189,8 +188,8 @@ def get_permission_denied_model(model: AnyResponse) -> AnyResponse:
189
188
  Returns:
190
189
  The permission denied model.
191
190
  """
192
- return model.copy(
193
- exclude={"body", "metadata"}, update={"permission_denied": True}
191
+ return model.model_copy(
192
+ update={"body": None, "metadata": None, "permission_denied": True}
194
193
  )
195
194
 
196
195
 
@@ -472,9 +471,7 @@ def get_subresources_for_model(
472
471
  """
473
472
  resources = set()
474
473
 
475
- for key, value in model.__dict__.items():
476
- if key in model.__private_attributes__:
477
- continue
474
+ for value in dict(model).values():
478
475
  resources.update(_get_subresources_for_value(value))
479
476
 
480
477
  return resources
@@ -436,7 +436,7 @@ def device_authorization(
436
436
  city=city,
437
437
  region=region,
438
438
  country=country,
439
- **device_details.dict(exclude_none=True),
439
+ **device_details.model_dump(exclude_none=True),
440
440
  )
441
441
  )
442
442
  else:
@@ -455,7 +455,7 @@ def device_authorization(
455
455
  city=city,
456
456
  region=region,
457
457
  country=country,
458
- **device_details.dict(exclude_none=True),
458
+ **device_details.model_dump(exclude_none=True),
459
459
  ),
460
460
  )
461
461
 
@@ -177,7 +177,7 @@ if server_config().workload_manager_enabled:
177
177
  deployment = zen_store().get_deployment(
178
178
  deployment_id=build.template_deployment_id, hydrate=True
179
179
  )
180
- deployment.metadata.build = build # type: ignore[union-attr]
180
+ deployment.get_metadata().build = build
181
181
 
182
182
  return run_pipeline(
183
183
  deployment=deployment,
@@ -242,7 +242,7 @@ def get_pipeline_configuration(
242
242
  run = verify_permissions_and_get_entity(
243
243
  id=run_id, get_method=zen_store().get_run, hydrate=True
244
244
  )
245
- return run.config.dict()
245
+ return run.config.model_dump()
246
246
 
247
247
 
248
248
  @router.get(
@@ -175,8 +175,9 @@ def update_secret(
175
175
  # the update to None, so that they are deleted.
176
176
  secret = zen_store().get_secret(secret_id=secret_id)
177
177
  for key in secret.values.keys():
178
- if key not in secret_update.values:
179
- secret_update.values[key] = None
178
+ if secret_update.values is not None:
179
+ if key not in secret_update.values:
180
+ secret_update.values[key] = None
180
181
 
181
182
  return verify_permissions_and_update_entity(
182
183
  id=secret_id,
@@ -122,7 +122,7 @@ if server_config().external_server_id is None:
122
122
  """
123
123
  if not server_config().rbac_enabled:
124
124
  will_update_admin_properties = bool(
125
- settings_update.dict(
125
+ settings_update.model_dump(
126
126
  exclude_none=True, exclude={"onboarding_state"}
127
127
  )
128
128
  )
@@ -200,7 +200,7 @@ def get_step_configuration(
200
200
  pipeline_run = zen_store().get_run(step.pipeline_run_id)
201
201
  verify_permission_for_model(pipeline_run, action=Action.READ)
202
202
 
203
- return step.config.dict()
203
+ return step.config.model_dump()
204
204
 
205
205
 
206
206
  @router.get(
@@ -1067,7 +1067,7 @@ def create_code_repository(
1067
1067
 
1068
1068
  @router.get(
1069
1069
  WORKSPACES + "/{workspace_name_or_id}" + STATISTICS,
1070
- response_model=Dict[str, str],
1070
+ response_model=Dict[str, int],
1071
1071
  responses={401: error_response, 404: error_response, 422: error_response},
1072
1072
  )
1073
1073
  @handle_exceptions
@@ -18,6 +18,7 @@ from abc import ABC
18
18
  from typing import (
19
19
  Any,
20
20
  ClassVar,
21
+ Dict,
21
22
  Optional,
22
23
  Tuple,
23
24
  Type,
@@ -26,7 +27,7 @@ from typing import (
26
27
  from urllib.parse import urlparse
27
28
  from uuid import UUID
28
29
 
29
- from pydantic import BaseModel
30
+ from pydantic import BaseModel, ConfigDict, model_validator
30
31
  from requests import ConnectionError
31
32
 
32
33
  import zenml
@@ -54,6 +55,7 @@ from zenml.models import (
54
55
  UserResponse,
55
56
  WorkspaceResponse,
56
57
  )
58
+ from zenml.utils.pydantic_utils import before_validator_handler
57
59
  from zenml.zen_stores.secrets_stores.sql_secrets_store import (
58
60
  SqlSecretsStoreConfiguration,
59
61
  )
@@ -78,6 +80,45 @@ class BaseZenStore(
78
80
  TYPE: ClassVar[StoreType]
79
81
  CONFIG_TYPE: ClassVar[Type[StoreConfiguration]]
80
82
 
83
+ @model_validator(mode="before")
84
+ @classmethod
85
+ @before_validator_handler
86
+ def convert_config(cls, data: Dict[str, Any]) -> Dict[str, Any]:
87
+ """Method to infer the correct type of the config and convert.
88
+
89
+ Args:
90
+ data: The provided configuration object, can potentially be a
91
+ generic object
92
+
93
+ Raises:
94
+ ValueError: If the provided config object's type does not match
95
+ any of the current implementations.
96
+
97
+ Returns:
98
+ The converted configuration object.
99
+ """
100
+ if data["config"].type == StoreType.SQL:
101
+ from zenml.zen_stores.sql_zen_store import SqlZenStoreConfiguration
102
+
103
+ data["config"] = SqlZenStoreConfiguration(
104
+ **data["config"].model_dump()
105
+ )
106
+
107
+ elif data["config"].type == StoreType.REST:
108
+ from zenml.zen_stores.rest_zen_store import (
109
+ RestZenStoreConfiguration,
110
+ )
111
+
112
+ data["config"] = RestZenStoreConfiguration(
113
+ **data["config"].model_dump()
114
+ )
115
+ else:
116
+ raise ValueError(
117
+ f"Unknown type '{data['config'].type}' for the configuration."
118
+ )
119
+
120
+ return data
121
+
81
122
  # ---------------------------------
82
123
  # Initialization and configuration
83
124
  # ---------------------------------
@@ -477,14 +518,10 @@ class BaseZenStore(
477
518
  raise KeyError(f"User with external ID '{user_id}' not found.")
478
519
  return users.items[0]
479
520
 
480
- class Config:
481
- """Pydantic configuration class."""
482
-
521
+ model_config = ConfigDict(
483
522
  # Validate attributes when assigning them. We need to set this in order
484
523
  # to have a mix of mutable and immutable attributes
485
- validate_assignment = True
524
+ validate_assignment=True,
486
525
  # Ignore extra attributes from configs of previous ZenML versions
487
- extra = "ignore"
488
- # all attributes with leading underscore are private and therefore
489
- # are mutable and not included in serialization
490
- underscore_attrs_are_private = True
526
+ extra="ignore",
527
+ )
@@ -28,8 +28,7 @@ from typing import (
28
28
  )
29
29
 
30
30
  import pymysql
31
- from pydantic import BaseModel
32
- from pydantic.json import pydantic_encoder
31
+ from pydantic import BaseModel, ConfigDict
33
32
  from sqlalchemy import MetaData, func, text
34
33
  from sqlalchemy.engine import URL, Engine
35
34
  from sqlalchemy.exc import (
@@ -42,6 +41,7 @@ from sqlmodel import (
42
41
  )
43
42
 
44
43
  from zenml.logger import get_logger
44
+ from zenml.utils.json_utils import pydantic_encoder
45
45
 
46
46
  logger = get_logger(__name__)
47
47
 
@@ -300,25 +300,26 @@ class MigrationUtils(BaseModel):
300
300
 
301
301
  # Fetch the number of rows in the table
302
302
  row_count = conn.scalar(
303
- select([func.count("*")]).select_from(table)
303
+ select(func.count()).select_from(table)
304
304
  )
305
305
 
306
306
  # Fetch the data from the table in batches
307
- batch_size = 50
308
- for i in range(0, row_count, batch_size):
309
- rows = conn.execute(
310
- table.select()
311
- .order_by(*order_by)
312
- .limit(batch_size)
313
- .offset(i)
314
- ).fetchall()
315
-
316
- store_db_info(
317
- dict(
318
- table=table.name,
319
- data=[row._asdict() for row in rows],
320
- ),
321
- )
307
+ if row_count is not None:
308
+ batch_size = 50
309
+ for i in range(0, row_count, batch_size):
310
+ rows = conn.execute(
311
+ table.select()
312
+ .order_by(*order_by)
313
+ .limit(batch_size)
314
+ .offset(i)
315
+ ).fetchall()
316
+
317
+ store_db_info(
318
+ dict(
319
+ table=table.name,
320
+ data=[row._asdict() for row in rows],
321
+ ),
322
+ )
322
323
 
323
324
  def restore_database_from_storage(
324
325
  self, load_db_info: Callable[[], Generator[Dict[str, Any], None, None]]
@@ -342,11 +343,9 @@ class MigrationUtils(BaseModel):
342
343
  information.
343
344
  """
344
345
  # Drop and re-create the primary database
345
- self.create_database(
346
- drop=True,
347
- )
346
+ self.create_database(drop=True)
348
347
 
349
- metadata = MetaData(bind=self.engine)
348
+ metadata = MetaData()
350
349
 
351
350
  with self.engine.begin() as connection:
352
351
  # read the DB information one JSON object at a time
@@ -356,7 +355,7 @@ class MigrationUtils(BaseModel):
356
355
  # execute the table creation statement
357
356
  connection.execute(text(table_dump["create_stmt"]))
358
357
  # Reload the database metadata after creating the table
359
- metadata.reflect()
358
+ metadata.reflect(bind=self.engine)
360
359
 
361
360
  if "data" in table_dump:
362
361
  # insert the data into the database
@@ -604,11 +603,11 @@ class MigrationUtils(BaseModel):
604
603
  src_engine: The source SQLAlchemy engine.
605
604
  dst_engine: The destination SQLAlchemy engine.
606
605
  """
607
- src_metadata = MetaData(bind=src_engine)
608
- src_metadata.reflect()
606
+ src_metadata = MetaData()
607
+ src_metadata.reflect(bind=src_engine)
609
608
 
610
- dst_metadata = MetaData(bind=dst_engine)
611
- dst_metadata.reflect()
609
+ dst_metadata = MetaData()
610
+ dst_metadata.reflect(bind=dst_engine)
612
611
 
613
612
  # @event.listens_for(src_metadata, "column_reflect")
614
613
  # def generalize_datatypes(inspector, tablename, column_dict):
@@ -620,7 +619,7 @@ class MigrationUtils(BaseModel):
620
619
 
621
620
  # Refresh target metadata after creating the tables
622
621
  dst_metadata.clear()
623
- dst_metadata.reflect()
622
+ dst_metadata.reflect(bind=dst_engine)
624
623
 
625
624
  # Copy all data from the source database to the destination database
626
625
  with src_engine.begin() as src_conn:
@@ -648,22 +647,23 @@ class MigrationUtils(BaseModel):
648
647
  order_by.append(src_table.columns["id"])
649
648
 
650
649
  row_count = src_conn.scalar(
651
- select([func.count("*")]).select_from(src_table)
650
+ select(func.count()).select_from(src_table)
652
651
  )
653
652
 
654
653
  # Copy rows in batches
655
- batch_size = 50
656
- for i in range(0, row_count, batch_size):
657
- rows = src_conn.execute(
658
- src_table.select()
659
- .order_by(*order_by)
660
- .limit(batch_size)
661
- .offset(i)
662
- ).fetchall()
663
-
664
- dst_conn.execute(
665
- insert, [row._asdict() for row in rows]
666
- )
654
+ if row_count is not None:
655
+ batch_size = 50
656
+ for i in range(0, row_count, batch_size):
657
+ rows = src_conn.execute(
658
+ src_table.select()
659
+ .order_by(*order_by)
660
+ .limit(batch_size)
661
+ .offset(i)
662
+ ).fetchall()
663
+
664
+ dst_conn.execute(
665
+ insert, [row._asdict() for row in rows]
666
+ )
667
667
 
668
668
  def backup_database_to_db(self, backup_db_name: str) -> None:
669
669
  """Backup the database to a backup database.
@@ -713,8 +713,4 @@ class MigrationUtils(BaseModel):
713
713
  "backup database."
714
714
  )
715
715
 
716
- class Config:
717
- """Pydantic configuration class."""
718
-
719
- # all attributes with leading underscore are private
720
- underscore_attrs_are_private = True
716
+ model_config = ConfigDict(arbitrary_types_allowed=True)
@@ -22,7 +22,7 @@ def upgrade() -> None:
22
22
  """Upgrade database schema and/or data, creating a new revision."""
23
23
  # If the tables already exist, skip this migration.
24
24
  conn = op.get_bind()
25
- inspector = Inspector.from_engine(conn)
25
+ inspector = Inspector.from_engine(conn.engine)
26
26
  tables = inspector.get_table_names()
27
27
  if "service" in tables:
28
28
  return
@@ -19,14 +19,16 @@ depends_on = None
19
19
  def upgrade() -> None:
20
20
  """Upgrade database schema and/or data, creating a new revision."""
21
21
  conn = op.get_bind()
22
- meta = sa.MetaData(bind=op.get_bind())
23
- meta.reflect(only=("stack_component", "stack_composition"))
22
+ meta = sa.MetaData()
23
+ meta.reflect(
24
+ only=("stack_component", "stack_composition"), bind=op.get_bind()
25
+ )
24
26
  components = sa.Table("stack_component", meta)
25
27
  compositions = sa.Table("stack_composition", meta)
26
28
 
27
29
  # Find all secrets manager components
28
30
  secrets_manager_components = conn.execute(
29
- sa.select([components.c.id]).where(
31
+ sa.select(components.c.id).where(
30
32
  components.c.type == "secrets_manager"
31
33
  )
32
34
  ).all()
@@ -20,7 +20,7 @@ def upgrade() -> None:
20
20
  """Upgrade database schema and/or data, creating a new revision."""
21
21
  # Bye bye MLMD :wave: :wave: :wave:
22
22
  conn = op.get_bind()
23
- inspector = Inspector.from_engine(conn)
23
+ inspector = Inspector.from_engine(conn.engine)
24
24
  tables = inspector.get_table_names()
25
25
  for table in (
26
26
  "Artifact",
@@ -6,7 +6,7 @@ Create Date: 2022-11-17 08:00:24.936750
6
6
 
7
7
  """
8
8
 
9
- from typing import TYPE_CHECKING, Dict
9
+ from typing import Any, Dict
10
10
 
11
11
  import sqlalchemy as sa
12
12
  import sqlmodel
@@ -14,9 +14,6 @@ from alembic import op
14
14
  from sqlalchemy import select
15
15
  from sqlalchemy.sql.expression import false, true
16
16
 
17
- if TYPE_CHECKING:
18
- from sqlalchemy.engine.row import Row
19
-
20
17
  # revision identifiers, used by Alembic.
21
18
  revision = "26b776ad583e"
22
19
  down_revision = "0.23.0"
@@ -53,13 +50,14 @@ def upgrade() -> None:
53
50
  # Migrate data
54
51
  # ------------
55
52
  conn = op.get_bind()
56
- meta = sa.MetaData(bind=op.get_bind())
53
+ meta = sa.MetaData()
57
54
  meta.reflect(
55
+ bind=op.get_bind(),
58
56
  only=(
59
57
  "artifacts",
60
58
  "step_run_output_artifact",
61
59
  "step_run_input_artifact",
62
- )
60
+ ),
63
61
  )
64
62
  artifacts = sa.Table("artifacts", meta)
65
63
  step_run_output_artifact = sa.Table("step_run_output_artifact", meta)
@@ -85,7 +83,7 @@ def upgrade() -> None:
85
83
  ).where(artifacts.c.is_cached == true())
86
84
  ).fetchall()
87
85
 
88
- def _find_produced_artifact(cached_artifact: "Row") -> "Row":
86
+ def _find_produced_artifact(cached_artifact: Any) -> Any:
89
87
  """For a given cached artifact, find the original produced artifact.
90
88
 
91
89
  Args:
@@ -115,9 +113,9 @@ def upgrade() -> None:
115
113
  produced_artifact = _find_produced_artifact(cached_artifact)
116
114
  cached_to_produced_mapping[cached_artifact.id] = produced_artifact.id
117
115
  conn.execute(
118
- step_run_input_artifact.update(
119
- step_run_input_artifact.c.artifact_id == cached_artifact.id
120
- ).values({"artifact_id": produced_artifact.id})
116
+ step_run_input_artifact.update()
117
+ .where(step_run_input_artifact.c.artifact_id == cached_artifact.id)
118
+ .values({"artifact_id": produced_artifact.id})
121
119
  )
122
120
 
123
121
  # Delete all cached artifacts from the artifacts table
@@ -62,7 +62,7 @@ def upgrade() -> None:
62
62
  "pipeline_configuration",
63
63
  existing_type=sa.TEXT(),
64
64
  type_=sa.String(length=16777215).with_variant(
65
- mysql.MEDIUMTEXT(), "mysql"
65
+ mysql.MEDIUMTEXT, "mysql"
66
66
  ),
67
67
  existing_nullable=False,
68
68
  )
@@ -121,7 +121,7 @@ def upgrade() -> None:
121
121
  batch_op.alter_column(
122
122
  "step_configuration",
123
123
  existing_type=sa.String(length=16777215).with_variant(
124
- mysql.MEDIUMTEXT(), "mysql"
124
+ mysql.MEDIUMTEXT, "mysql"
125
125
  ),
126
126
  nullable=True,
127
127
  )
@@ -272,7 +272,7 @@ def downgrade() -> None:
272
272
  batch_op.alter_column(
273
273
  "pipeline_configuration",
274
274
  existing_type=sa.String(length=16777215).with_variant(
275
- mysql.MEDIUMTEXT(), "mysql"
275
+ mysql.MEDIUMTEXT, "mysql"
276
276
  ),
277
277
  type_=sa.TEXT(),
278
278
  existing_nullable=False,
@@ -43,18 +43,17 @@ def upgrade() -> None:
43
43
  )
44
44
 
45
45
  # Get metadata from current connection
46
- meta = sa.MetaData(bind=op.get_bind())
46
+ meta = sa.MetaData()
47
47
 
48
48
  # Pass in tuple with tables we want to reflect, otherwise whole database
49
49
  # will get reflected
50
- meta.reflect(only=("identity", "server_settings"))
50
+ meta.reflect(only=("identity", "server_settings"), bind=op.get_bind())
51
51
 
52
52
  # Fetch the deployment id from the identity table
53
53
  deployment_id = (
54
- sa.select([meta.tables["identity"].c.id])
55
- .limit(1)
56
- .execute()
57
- .fetchone()[0]
54
+ op.get_bind()
55
+ .execute(sa.select(meta.tables["identity"].c.id).limit(1))
56
+ .scalar_one()
58
57
  )
59
58
 
60
59
  # Prefill the settings table with a single row that contains the deployment
@@ -94,18 +93,17 @@ def downgrade() -> None:
94
93
  )
95
94
 
96
95
  # Get metadata from current connection
97
- meta = sa.MetaData(bind=op.get_bind())
96
+ meta = sa.MetaData()
98
97
 
99
98
  # Pass in tuple with tables we want to reflect, otherwise whole database
100
99
  # will get reflected
101
- meta.reflect(only=("identity", "server_settings"))
100
+ meta.reflect(only=("identity", "server_settings"), bind=op.get_bind())
102
101
 
103
102
  # Fetch the deployment id from the settings table
104
103
  deployment_id = (
105
- sa.select([meta.tables["server_settings"].c.id])
106
- .limit(1)
107
- .execute()
108
- .fetchone()[0]
104
+ op.get_bind()
105
+ .execute(sa.select(meta.tables["server_settings"].c.id).limit(1))
106
+ .scalar_one()
109
107
  )
110
108
 
111
109
  # Prefill the identity table with a single row that contains the deployment
@@ -36,18 +36,19 @@ def upgrade() -> None:
36
36
  sa.PrimaryKeyConstraint("name", "role_id"),
37
37
  )
38
38
  # get metadata from current connection
39
- meta = sa.MetaData(bind=op.get_bind())
39
+ meta = sa.MetaData()
40
40
 
41
41
  # pass in tuple with tables we want to reflect, otherwise whole database
42
42
  # will get reflected
43
43
  meta.reflect(
44
+ bind=op.get_bind(),
44
45
  only=(
45
46
  "rolepermissionschema",
46
47
  "roleschema",
47
48
  "userroleassignmentschema",
48
49
  "teamroleassignmentschema",
49
50
  "userschema",
50
- )
51
+ ),
51
52
  )
52
53
 
53
54
  # In order to ensure unique names on roles delete potential admin/guest role
@@ -24,8 +24,8 @@ def add_orchestrator_run_id_for_old_runs() -> None:
24
24
  this constraint. This is not the case for old pipeline runs which existed
25
25
  before we had deployments, so we add a dummy value for those runs.
26
26
  """
27
- meta = sa.MetaData(bind=op.get_bind())
28
- meta.reflect(only=("pipeline_run",))
27
+ meta = sa.MetaData()
28
+ meta.reflect(bind=op.get_bind(), only=("pipeline_run",))
29
29
  run_table = sa.Table("pipeline_run", meta)
30
30
  connection = op.get_bind()
31
31
 
@@ -48,8 +48,8 @@ def verify_unique_constraint_satisfied() -> None:
48
48
  RuntimeError: If there are rows which have identical values for the
49
49
  `deployment_id` and `orchestrator_run_id` columns.
50
50
  """
51
- meta = sa.MetaData(bind=op.get_bind())
52
- meta.reflect(only=("pipeline_run",))
51
+ meta = sa.MetaData()
52
+ meta.reflect(bind=op.get_bind(), only=("pipeline_run",))
53
53
  run_table = sa.Table("pipeline_run", meta)
54
54
  connection = op.get_bind()
55
55
 
@@ -131,7 +131,8 @@ def _disable_primary_key_requirement_if_necessary() -> None:
131
131
  Raises:
132
132
  NotImplementedError: If the database engine is not MySQL or mariadb.
133
133
  """
134
- engine = op.get_bind().engine
134
+ conn = op.get_bind()
135
+ engine = conn.engine
135
136
  engine_name = engine.name.lower()
136
137
 
137
138
  if engine_name == "mysql":
@@ -141,7 +142,7 @@ def _disable_primary_key_requirement_if_necessary() -> None:
141
142
  0,
142
143
  13,
143
144
  ):
144
- potential_session_var = engine.execute(
145
+ potential_session_var = conn.execute(
145
146
  text('SHOW SESSION VARIABLES LIKE "sql_require_primary_key";')
146
147
  ).fetchone()
147
148
  if potential_session_var and potential_session_var[1] == "ON":
@@ -25,7 +25,7 @@ def upgrade() -> None:
25
25
  "images",
26
26
  existing_type=sa.TEXT(),
27
27
  type_=sa.String(length=16777215).with_variant(
28
- mysql.MEDIUMTEXT(), "mysql"
28
+ mysql.MEDIUMTEXT, "mysql"
29
29
  ),
30
30
  existing_nullable=False,
31
31
  )
@@ -40,7 +40,7 @@ def downgrade() -> None:
40
40
  batch_op.alter_column(
41
41
  "images",
42
42
  existing_type=sa.String(length=16777215).with_variant(
43
- mysql.MEDIUMTEXT(), "mysql"
43
+ mysql.MEDIUMTEXT, "mysql"
44
44
  ),
45
45
  type_=sa.TEXT(),
46
46
  existing_nullable=False,