zenml-nightly 0.58.2.dev20240618__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 (300) 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/store_config.py +20 -19
  35. zenml/config/strict_base_model.py +2 -6
  36. zenml/constants.py +26 -2
  37. zenml/container_registries/base_container_registry.py +3 -2
  38. zenml/container_registries/default_container_registry.py +3 -3
  39. zenml/event_hub/base_event_hub.py +1 -1
  40. zenml/event_sources/base_event_source.py +11 -16
  41. zenml/exceptions.py +4 -0
  42. zenml/integrations/airflow/__init__.py +2 -10
  43. zenml/integrations/airflow/flavors/airflow_orchestrator_flavor.py +6 -7
  44. zenml/integrations/airflow/orchestrators/airflow_orchestrator.py +13 -249
  45. zenml/integrations/airflow/orchestrators/dag_generator.py +5 -3
  46. zenml/integrations/argilla/flavors/argilla_annotator_flavor.py +5 -4
  47. zenml/integrations/aws/__init__.py +1 -1
  48. zenml/integrations/aws/flavors/aws_container_registry_flavor.py +3 -2
  49. zenml/integrations/aws/flavors/sagemaker_orchestrator_flavor.py +11 -5
  50. zenml/integrations/aws/flavors/sagemaker_step_operator_flavor.py +6 -2
  51. zenml/integrations/aws/service_connectors/aws_service_connector.py +5 -4
  52. zenml/integrations/azure/flavors/azureml_step_operator_flavor.py +4 -4
  53. zenml/integrations/azure/service_connectors/azure_service_connector.py +4 -3
  54. zenml/integrations/azure/step_operators/azureml_step_operator.py +1 -1
  55. zenml/integrations/bentoml/steps/bentoml_deployer.py +1 -1
  56. zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +8 -12
  57. zenml/integrations/comet/flavors/comet_experiment_tracker_flavor.py +1 -1
  58. zenml/integrations/evidently/__init__.py +3 -4
  59. zenml/integrations/evidently/column_mapping.py +11 -3
  60. zenml/integrations/evidently/data_validators/evidently_data_validator.py +21 -3
  61. zenml/integrations/evidently/metrics.py +5 -6
  62. zenml/integrations/evidently/tests.py +5 -6
  63. zenml/integrations/facets/models.py +2 -6
  64. zenml/integrations/feast/__init__.py +3 -1
  65. zenml/integrations/feast/feature_stores/feast_feature_store.py +0 -23
  66. zenml/integrations/gcp/__init__.py +1 -1
  67. zenml/integrations/gcp/flavors/vertex_orchestrator_flavor.py +1 -1
  68. zenml/integrations/gcp/flavors/vertex_step_operator_flavor.py +1 -1
  69. zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +234 -103
  70. zenml/integrations/gcp/service_connectors/gcp_service_connector.py +57 -42
  71. zenml/integrations/github/code_repositories/github_code_repository.py +1 -1
  72. zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py +9 -13
  73. zenml/integrations/great_expectations/__init__.py +1 -1
  74. zenml/integrations/great_expectations/data_validators/ge_data_validator.py +44 -44
  75. zenml/integrations/great_expectations/flavors/great_expectations_data_validator_flavor.py +35 -2
  76. zenml/integrations/great_expectations/ge_store_backend.py +24 -11
  77. zenml/integrations/great_expectations/materializers/ge_materializer.py +3 -3
  78. zenml/integrations/great_expectations/utils.py +5 -5
  79. zenml/integrations/huggingface/__init__.py +3 -0
  80. zenml/integrations/huggingface/flavors/huggingface_model_deployer_flavor.py +1 -1
  81. zenml/integrations/huggingface/steps/__init__.py +3 -0
  82. zenml/integrations/huggingface/steps/accelerate_runner.py +149 -0
  83. zenml/integrations/huggingface/steps/huggingface_deployer.py +2 -2
  84. zenml/integrations/hyperai/flavors/hyperai_orchestrator_flavor.py +1 -1
  85. zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py +4 -3
  86. zenml/integrations/kubeflow/__init__.py +1 -1
  87. zenml/integrations/kubeflow/flavors/kubeflow_orchestrator_flavor.py +48 -81
  88. zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py +295 -245
  89. zenml/integrations/kubernetes/flavors/kubernetes_orchestrator_flavor.py +1 -1
  90. zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py +11 -2
  91. zenml/integrations/kubernetes/pod_settings.py +17 -31
  92. zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py +8 -7
  93. zenml/integrations/label_studio/__init__.py +1 -3
  94. zenml/integrations/label_studio/annotators/label_studio_annotator.py +3 -4
  95. zenml/integrations/label_studio/flavors/label_studio_annotator_flavor.py +2 -2
  96. zenml/integrations/langchain/materializers/document_materializer.py +44 -8
  97. zenml/integrations/mlflow/__init__.py +9 -3
  98. zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py +1 -1
  99. zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py +29 -37
  100. zenml/integrations/mlflow/model_registries/mlflow_model_registry.py +4 -4
  101. zenml/integrations/mlflow/steps/mlflow_deployer.py +1 -1
  102. zenml/integrations/neptune/flavors/neptune_experiment_tracker_flavor.py +1 -1
  103. zenml/integrations/pigeon/flavors/pigeon_annotator_flavor.py +1 -1
  104. zenml/integrations/s3/flavors/s3_artifact_store_flavor.py +9 -8
  105. zenml/integrations/seldon/seldon_client.py +52 -67
  106. zenml/integrations/seldon/services/seldon_deployment.py +3 -3
  107. zenml/integrations/seldon/steps/seldon_deployer.py +4 -4
  108. zenml/integrations/skypilot/flavors/skypilot_orchestrator_base_vm_config.py +15 -5
  109. zenml/integrations/skypilot_aws/__init__.py +1 -1
  110. zenml/integrations/skypilot_aws/flavors/skypilot_orchestrator_aws_vm_flavor.py +1 -1
  111. zenml/integrations/skypilot_azure/__init__.py +1 -1
  112. zenml/integrations/skypilot_azure/flavors/skypilot_orchestrator_azure_vm_flavor.py +1 -1
  113. zenml/integrations/skypilot_gcp/__init__.py +2 -1
  114. zenml/integrations/skypilot_gcp/flavors/skypilot_orchestrator_gcp_vm_flavor.py +1 -1
  115. zenml/integrations/skypilot_lambda/flavors/skypilot_orchestrator_lambda_vm_flavor.py +2 -2
  116. zenml/integrations/spark/flavors/spark_step_operator_flavor.py +1 -1
  117. zenml/integrations/tekton/__init__.py +1 -1
  118. zenml/integrations/tekton/flavors/tekton_orchestrator_flavor.py +66 -23
  119. zenml/integrations/tekton/orchestrators/tekton_orchestrator.py +547 -233
  120. zenml/integrations/tensorboard/__init__.py +1 -12
  121. zenml/integrations/tensorboard/services/tensorboard_service.py +3 -5
  122. zenml/integrations/tensorboard/visualizers/tensorboard_visualizer.py +6 -6
  123. zenml/integrations/tensorflow/__init__.py +2 -10
  124. zenml/integrations/tensorflow/materializers/keras_materializer.py +17 -9
  125. zenml/integrations/wandb/flavors/wandb_experiment_tracker_flavor.py +9 -14
  126. zenml/integrations/whylogs/flavors/whylogs_data_validator_flavor.py +1 -1
  127. zenml/lineage_graph/lineage_graph.py +1 -1
  128. zenml/materializers/built_in_materializer.py +3 -3
  129. zenml/materializers/pydantic_materializer.py +2 -2
  130. zenml/metadata/lazy_load.py +4 -4
  131. zenml/metadata/metadata_types.py +64 -4
  132. zenml/model/model.py +79 -54
  133. zenml/model_deployers/base_model_deployer.py +14 -12
  134. zenml/model_registries/base_model_registry.py +17 -15
  135. zenml/models/__init__.py +79 -206
  136. zenml/models/v2/base/base.py +54 -41
  137. zenml/models/v2/base/base_plugin_flavor.py +2 -6
  138. zenml/models/v2/base/filter.py +91 -76
  139. zenml/models/v2/base/page.py +2 -12
  140. zenml/models/v2/base/scoped.py +4 -7
  141. zenml/models/v2/core/api_key.py +22 -8
  142. zenml/models/v2/core/artifact.py +2 -2
  143. zenml/models/v2/core/artifact_version.py +74 -40
  144. zenml/models/v2/core/code_repository.py +37 -10
  145. zenml/models/v2/core/component.py +65 -16
  146. zenml/models/v2/core/device.py +14 -4
  147. zenml/models/v2/core/event_source.py +1 -2
  148. zenml/models/v2/core/flavor.py +74 -8
  149. zenml/models/v2/core/logs.py +68 -8
  150. zenml/models/v2/core/model.py +8 -4
  151. zenml/models/v2/core/model_version.py +25 -6
  152. zenml/models/v2/core/model_version_artifact.py +51 -21
  153. zenml/models/v2/core/model_version_pipeline_run.py +45 -13
  154. zenml/models/v2/core/pipeline.py +37 -72
  155. zenml/models/v2/core/pipeline_build.py +29 -17
  156. zenml/models/v2/core/pipeline_deployment.py +18 -6
  157. zenml/models/v2/core/pipeline_namespace.py +113 -0
  158. zenml/models/v2/core/pipeline_run.py +50 -22
  159. zenml/models/v2/core/run_metadata.py +59 -36
  160. zenml/models/v2/core/schedule.py +37 -24
  161. zenml/models/v2/core/secret.py +31 -12
  162. zenml/models/v2/core/service.py +64 -36
  163. zenml/models/v2/core/service_account.py +24 -11
  164. zenml/models/v2/core/service_connector.py +219 -44
  165. zenml/models/v2/core/stack.py +45 -17
  166. zenml/models/v2/core/step_run.py +28 -8
  167. zenml/models/v2/core/tag.py +8 -4
  168. zenml/models/v2/core/trigger.py +2 -2
  169. zenml/models/v2/core/trigger_execution.py +1 -0
  170. zenml/models/v2/core/user.py +18 -21
  171. zenml/models/v2/core/workspace.py +13 -3
  172. zenml/models/v2/misc/build_item.py +3 -3
  173. zenml/models/v2/misc/external_user.py +2 -6
  174. zenml/models/v2/misc/hub_plugin_models.py +9 -9
  175. zenml/models/v2/misc/loaded_visualization.py +2 -2
  176. zenml/models/v2/misc/service_connector_type.py +8 -17
  177. zenml/models/v2/misc/user_auth.py +7 -2
  178. zenml/new/pipelines/build_utils.py +3 -3
  179. zenml/new/pipelines/pipeline.py +17 -13
  180. zenml/new/pipelines/run_utils.py +103 -1
  181. zenml/orchestrators/base_orchestrator.py +10 -7
  182. zenml/orchestrators/local_docker/local_docker_orchestrator.py +1 -1
  183. zenml/orchestrators/step_runner.py +3 -6
  184. zenml/orchestrators/utils.py +1 -1
  185. zenml/plugins/base_plugin_flavor.py +6 -10
  186. zenml/plugins/plugin_flavor_registry.py +3 -7
  187. zenml/secret/base_secret.py +7 -8
  188. zenml/service_connectors/docker_service_connector.py +4 -3
  189. zenml/service_connectors/service_connector.py +5 -12
  190. zenml/service_connectors/service_connector_registry.py +2 -4
  191. zenml/services/container/container_service.py +1 -1
  192. zenml/services/container/container_service_endpoint.py +1 -1
  193. zenml/services/local/local_service.py +1 -1
  194. zenml/services/local/local_service_endpoint.py +1 -1
  195. zenml/services/service.py +16 -10
  196. zenml/services/service_type.py +4 -5
  197. zenml/services/terraform/terraform_service.py +1 -1
  198. zenml/stack/flavor.py +1 -5
  199. zenml/stack/flavor_registry.py +4 -4
  200. zenml/stack/stack.py +4 -1
  201. zenml/stack/stack_component.py +55 -31
  202. zenml/steps/base_step.py +34 -28
  203. zenml/steps/entrypoint_function_utils.py +3 -5
  204. zenml/steps/utils.py +12 -14
  205. zenml/utils/cuda_utils.py +50 -0
  206. zenml/utils/deprecation_utils.py +18 -20
  207. zenml/utils/dict_utils.py +1 -1
  208. zenml/utils/filesync_model.py +65 -28
  209. zenml/utils/function_utils.py +260 -0
  210. zenml/utils/json_utils.py +131 -0
  211. zenml/utils/mlstacks_utils.py +2 -2
  212. zenml/utils/pydantic_utils.py +270 -62
  213. zenml/utils/secret_utils.py +65 -12
  214. zenml/utils/source_utils.py +2 -2
  215. zenml/utils/typed_model.py +5 -3
  216. zenml/utils/typing_utils.py +243 -0
  217. zenml/utils/yaml_utils.py +1 -1
  218. zenml/zen_server/auth.py +2 -2
  219. zenml/zen_server/cloud_utils.py +6 -6
  220. zenml/zen_server/deploy/base_provider.py +1 -1
  221. zenml/zen_server/deploy/deployment.py +6 -8
  222. zenml/zen_server/deploy/docker/docker_zen_server.py +3 -4
  223. zenml/zen_server/deploy/local/local_provider.py +0 -1
  224. zenml/zen_server/deploy/local/local_zen_server.py +6 -6
  225. zenml/zen_server/deploy/terraform/terraform_zen_server.py +4 -6
  226. zenml/zen_server/exceptions.py +4 -1
  227. zenml/zen_server/feature_gate/zenml_cloud_feature_gate.py +1 -1
  228. zenml/zen_server/pipeline_deployment/utils.py +48 -68
  229. zenml/zen_server/rbac/models.py +2 -5
  230. zenml/zen_server/rbac/utils.py +11 -14
  231. zenml/zen_server/routers/auth_endpoints.py +2 -2
  232. zenml/zen_server/routers/pipeline_builds_endpoints.py +1 -1
  233. zenml/zen_server/routers/runs_endpoints.py +1 -1
  234. zenml/zen_server/routers/secrets_endpoints.py +3 -2
  235. zenml/zen_server/routers/server_endpoints.py +1 -1
  236. zenml/zen_server/routers/steps_endpoints.py +1 -1
  237. zenml/zen_server/routers/workspaces_endpoints.py +1 -1
  238. zenml/zen_stores/base_zen_store.py +46 -9
  239. zenml/zen_stores/migrations/utils.py +42 -46
  240. zenml/zen_stores/migrations/versions/0701da9951a0_added_service_table.py +1 -1
  241. zenml/zen_stores/migrations/versions/1041bc644e0d_remove_secrets_manager.py +5 -3
  242. zenml/zen_stores/migrations/versions/10a907dad202_delete_mlmd_tables.py +1 -1
  243. zenml/zen_stores/migrations/versions/26b776ad583e_redesign_artifacts.py +8 -10
  244. zenml/zen_stores/migrations/versions/37835ce041d2_optimizing_database.py +3 -3
  245. zenml/zen_stores/migrations/versions/46506f72f0ed_add_server_settings.py +10 -12
  246. zenml/zen_stores/migrations/versions/5994f9ad0489_introduce_role_permissions.py +3 -2
  247. zenml/zen_stores/migrations/versions/6917bce75069_add_pipeline_run_unique_constraint.py +4 -4
  248. zenml/zen_stores/migrations/versions/728c6369cfaa_add_name_column_to_input_artifact_pk.py +3 -2
  249. zenml/zen_stores/migrations/versions/743ec82b1b3c_update_size_of_build_images.py +2 -2
  250. zenml/zen_stores/migrations/versions/7500f434b71c_remove_shared_columns.py +3 -2
  251. zenml/zen_stores/migrations/versions/7834208cc3f6_artifact_project_scoping.py +8 -7
  252. zenml/zen_stores/migrations/versions/7b651bf6822e_track_secrets_in_db.py +6 -4
  253. zenml/zen_stores/migrations/versions/7e4a481d17f7_add_identity_table.py +2 -2
  254. zenml/zen_stores/migrations/versions/7f603e583dd7_fixed_migration.py +1 -1
  255. zenml/zen_stores/migrations/versions/a39c4184c8ce_remove_secrets_manager_flavors.py +2 -2
  256. zenml/zen_stores/migrations/versions/a91762e6be36_artifact_version_table.py +4 -4
  257. zenml/zen_stores/migrations/versions/alembic_start.py +1 -1
  258. zenml/zen_stores/migrations/versions/fbd7f18ced1e_increase_step_run_field_lengths.py +4 -4
  259. zenml/zen_stores/rest_zen_store.py +109 -49
  260. zenml/zen_stores/schemas/api_key_schemas.py +1 -1
  261. zenml/zen_stores/schemas/artifact_schemas.py +8 -8
  262. zenml/zen_stores/schemas/artifact_visualization_schemas.py +3 -3
  263. zenml/zen_stores/schemas/code_repository_schemas.py +1 -1
  264. zenml/zen_stores/schemas/component_schemas.py +8 -3
  265. zenml/zen_stores/schemas/device_schemas.py +8 -6
  266. zenml/zen_stores/schemas/event_source_schemas.py +3 -4
  267. zenml/zen_stores/schemas/flavor_schemas.py +5 -3
  268. zenml/zen_stores/schemas/model_schemas.py +26 -1
  269. zenml/zen_stores/schemas/pipeline_build_schemas.py +1 -1
  270. zenml/zen_stores/schemas/pipeline_deployment_schemas.py +4 -4
  271. zenml/zen_stores/schemas/pipeline_run_schemas.py +6 -6
  272. zenml/zen_stores/schemas/pipeline_schemas.py +5 -2
  273. zenml/zen_stores/schemas/run_metadata_schemas.py +2 -2
  274. zenml/zen_stores/schemas/secret_schemas.py +8 -5
  275. zenml/zen_stores/schemas/server_settings_schemas.py +3 -1
  276. zenml/zen_stores/schemas/service_connector_schemas.py +1 -1
  277. zenml/zen_stores/schemas/service_schemas.py +11 -2
  278. zenml/zen_stores/schemas/stack_schemas.py +1 -1
  279. zenml/zen_stores/schemas/step_run_schemas.py +11 -11
  280. zenml/zen_stores/schemas/tag_schemas.py +6 -2
  281. zenml/zen_stores/schemas/trigger_schemas.py +2 -2
  282. zenml/zen_stores/schemas/user_schemas.py +2 -2
  283. zenml/zen_stores/schemas/workspace_schemas.py +3 -1
  284. zenml/zen_stores/secrets_stores/aws_secrets_store.py +19 -20
  285. zenml/zen_stores/secrets_stores/azure_secrets_store.py +17 -20
  286. zenml/zen_stores/secrets_stores/base_secrets_store.py +79 -12
  287. zenml/zen_stores/secrets_stores/gcp_secrets_store.py +17 -20
  288. zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py +4 -8
  289. zenml/zen_stores/secrets_stores/service_connector_secrets_store.py +10 -7
  290. zenml/zen_stores/secrets_stores/sql_secrets_store.py +5 -6
  291. zenml/zen_stores/sql_zen_store.py +196 -120
  292. zenml/zen_stores/zen_store_interface.py +33 -0
  293. {zenml_nightly-0.58.2.dev20240618.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/METADATA +8 -7
  294. {zenml_nightly-0.58.2.dev20240618.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/RECORD +297 -294
  295. zenml/integrations/kubeflow/utils.py +0 -95
  296. zenml/models/v2/base/internal.py +0 -37
  297. zenml/models/v2/base/update.py +0 -44
  298. {zenml_nightly-0.58.2.dev20240618.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/LICENSE +0 -0
  299. {zenml_nightly-0.58.2.dev20240618.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/WHEEL +0 -0
  300. {zenml_nightly-0.58.2.dev20240618.dist-info → zenml_nightly-0.58.2.dev20240619.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,243 @@
1
+ # Copyright (c) ZenML GmbH 2021. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at:
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
+ # or implied. See the License for the specific language governing
13
+ # permissions and limitations under the License.
14
+ """Carried over version of some functions from the pydantic v1 typing module.
15
+
16
+ Check out the latest version here:
17
+ https://github.com/pydantic/pydantic/blob/v1.10.14/pydantic/typing.py
18
+ """
19
+
20
+ import sys
21
+ import typing
22
+ from typing import Any, Optional, Set, Tuple, Type, Union, cast
23
+ from typing import get_args as _typing_get_args
24
+ from typing import get_origin as _typing_get_origin
25
+
26
+ from typing_extensions import Annotated, Literal
27
+
28
+ # Annotated[...] is implemented by returning an instance of one of these
29
+ # classes, depending on python/typing_extensions version.
30
+ AnnotatedTypeNames = {"AnnotatedMeta", "_AnnotatedAlias"}
31
+
32
+ # None types
33
+ NONE_TYPES: Tuple[Any, Any, Any] = (None, None.__class__, Literal[None])
34
+
35
+ # Literal types
36
+ LITERAL_TYPES: Set[Any] = {Literal}
37
+ if hasattr(typing, "Literal"):
38
+ LITERAL_TYPES.add(typing.Literal)
39
+
40
+ # ----- is_none_type -----
41
+
42
+ if sys.version_info[:2] == (3, 8):
43
+
44
+ def is_none_type(type_: Any) -> bool:
45
+ """Checks if the provided type is none type.
46
+
47
+ Args:
48
+ type_: type to check.
49
+
50
+ Returns:
51
+ boolean indicating whether the type is none type.
52
+ """
53
+ for none_type in NONE_TYPES:
54
+ if type_ is none_type:
55
+ return True
56
+ # With python 3.8, specifically 3.8.10, Literal "is" checks are very
57
+ # flakey can change on very subtle changes like use of types in other
58
+ # modules, hopefully this check avoids that issue.
59
+ if is_literal_type(type_): # pragma: no cover
60
+ return all_literal_values(type_) == (None,)
61
+ return False
62
+ else:
63
+
64
+ def is_none_type(type_: Any) -> bool:
65
+ """Checks if the provided type is a none type.
66
+
67
+ Args:
68
+ type_: type to check.
69
+
70
+ Returns:
71
+ boolean indicating whether the type is a none type.
72
+ """
73
+ return type_ in NONE_TYPES
74
+
75
+ # ----- is_union -----
76
+
77
+ if sys.version_info < (3, 10):
78
+
79
+ def is_union(type_: Optional[Type[Any]]) -> bool:
80
+ """Checks if the provided type is a union type.
81
+
82
+ Args:
83
+ type_: type to check.
84
+
85
+ Returns:
86
+ boolean indicating whether the type is union type.
87
+ """
88
+ return type_ is Union # type: ignore[comparison-overlap]
89
+
90
+
91
+ else:
92
+
93
+ def is_union(type_: Optional[Type[Any]]) -> bool:
94
+ """Checks if the provided type is a union type.
95
+
96
+ Args:
97
+ type_: type to check.
98
+
99
+ Returns:
100
+ boolean indicating whether the type is union type.
101
+ """
102
+ import types
103
+
104
+ return type_ is Union or type_ is types.UnionType # type: ignore[comparison-overlap]
105
+
106
+
107
+ # ----- literal -----
108
+
109
+
110
+ def is_literal_type(type_: Type[Any]) -> bool:
111
+ """Checks if the provided type is a literal type.
112
+
113
+ Args:
114
+ type_: type to check.
115
+
116
+ Returns:
117
+ boolean indicating whether the type is union type.
118
+ """
119
+ return Literal is not None and get_origin(type_) in LITERAL_TYPES
120
+
121
+
122
+ def literal_values(type_: Type[Any]) -> Tuple[Any, ...]:
123
+ """Fetches the literal values defined in a type.
124
+
125
+ Args:
126
+ type_: type to check.
127
+
128
+ Returns:
129
+ tuple of the literal values.
130
+ """
131
+ return get_args(type_)
132
+
133
+
134
+ def all_literal_values(type_: Type[Any]) -> Tuple[Any, ...]:
135
+ """Fetches the literal values defined in a type in a recursive manner.
136
+
137
+ This method is used to retrieve all Literal values as Literal can be
138
+ used recursively (see https://www.python.org/dev/peps/pep-0586)
139
+ e.g. `Literal[Literal[Literal[1, 2, 3], "foo"], 5, None]`
140
+
141
+ Args:
142
+ type_: type to check.
143
+
144
+ Returns:
145
+ tuple of all the literal values defined in the type.
146
+ """
147
+ if not is_literal_type(type_):
148
+ return (type_,)
149
+
150
+ values = literal_values(type_)
151
+ return tuple(x for value in values for x in all_literal_values(value))
152
+
153
+
154
+ # ----- get_origin -----
155
+
156
+
157
+ def get_origin(tp: Type[Any]) -> Optional[Type[Any]]:
158
+ """Fetches the origin of a given type.
159
+
160
+ We can't directly use `typing.get_origin` since we need a fallback to
161
+ support custom generic classes like `ConstrainedList`
162
+ It should be useless once https://github.com/cython/cython/issues/3537 is
163
+ solved and https://github.com/pydantic/pydantic/pull/1753 is merged.
164
+
165
+ Args:
166
+ tp: type to check
167
+
168
+ Returns:
169
+ the origin type of the provided type.
170
+ """
171
+ if type(tp).__name__ in AnnotatedTypeNames:
172
+ return cast(Type[Any], Annotated) # mypy complains about _SpecialForm
173
+ return _typing_get_origin(tp) or getattr(tp, "__origin__", None)
174
+
175
+
176
+ # ----- get_args -----
177
+
178
+
179
+ def _generic_get_args(tp: Type[Any]) -> Tuple[Any, ...]:
180
+ """Generic get args function.
181
+
182
+ In python 3.9, `typing.Dict`, `typing.List`, ...
183
+ do have an empty `__args__` by default (instead of the generic ~T
184
+ for example). In order to still support `Dict` for example and consider
185
+ it as `Dict[Any, Any]`, we retrieve the `_nparams` value that tells us
186
+ how many parameters it needs.
187
+
188
+ Args:
189
+ tp: type to check.
190
+
191
+ Returns:
192
+ Tuple of all the args.
193
+ """
194
+ if hasattr(tp, "_nparams"):
195
+ return (Any,) * tp._nparams # type: ignore[no-any-return]
196
+ # Special case for `tuple[()]`, which used to return ((),) with
197
+ # `typing.Tuple in python 3.10- but now returns () for `tuple` and `Tuple`.
198
+ try:
199
+ if tp == Tuple[()] or sys.version_info >= (3, 9) and tp == tuple[()]:
200
+ return ((),)
201
+ # there is a TypeError when compiled with cython
202
+ except TypeError: # pragma: no cover
203
+ pass
204
+ return ()
205
+
206
+
207
+ def get_args(tp: Type[Any]) -> Tuple[Any, ...]:
208
+ """Get type arguments with all substitutions performed.
209
+
210
+ For unions, basic simplifications used by Union constructor are performed.
211
+ Examples::
212
+ get_args(Dict[str, int]) == (str, int)
213
+ get_args(int) == ()
214
+ get_args(Union[int, Union[T, int], str][int]) == (int, str)
215
+ get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
216
+ get_args(Callable[[], T][int]) == ([], int)
217
+
218
+ Args:
219
+ tp: the type to check.
220
+
221
+ Returns:
222
+ Tuple of all the args.
223
+ """
224
+ if type(tp).__name__ in AnnotatedTypeNames:
225
+ return tp.__args__ + tp.__metadata__ # type: ignore[no-any-return]
226
+ # the fallback is needed for the same reasons as `get_origin` (see above)
227
+ return (
228
+ _typing_get_args(tp)
229
+ or getattr(tp, "__args__", ())
230
+ or _generic_get_args(tp)
231
+ )
232
+
233
+
234
+ def is_optional(tp: Type[Any]) -> bool:
235
+ """Checks whether a given annotation is typing.Optional.
236
+
237
+ Args:
238
+ tp: the type to check.
239
+
240
+ Returns:
241
+ boolean indicating if the type is typing.Optional.
242
+ """
243
+ return is_union(get_origin(tp)) and type(None) in get_args(tp)
zenml/utils/yaml_utils.py CHANGED
@@ -193,7 +193,7 @@ def is_json_serializable(obj: Any) -> bool:
193
193
  Returns:
194
194
  Whether the object is JSON serializable using pydantics encoder class.
195
195
  """
196
- from pydantic.json import pydantic_encoder
196
+ from zenml.utils.json_utils import pydantic_encoder
197
197
 
198
198
  try:
199
199
  json.dumps(obj, default=pydantic_encoder)
zenml/zen_server/auth.py CHANGED
@@ -154,7 +154,7 @@ def _fetch_and_verify_api_key(
154
154
  # Update the "last used" timestamp of the API key
155
155
  store.update_internal_api_key(
156
156
  api_key.id,
157
- APIKeyInternalUpdate(update_last_login=True), # type: ignore[call-arg]
157
+ APIKeyInternalUpdate(update_last_login=True),
158
158
  )
159
159
 
160
160
  return api_key
@@ -544,7 +544,7 @@ def authenticate_external_user(external_access_token: str) -> AuthContext:
544
544
 
545
545
  if isinstance(payload, dict):
546
546
  try:
547
- external_user = ExternalUserModel.parse_obj(payload)
547
+ external_user = ExternalUserModel.model_validate(payload)
548
548
  except Exception as e:
549
549
  logger.exception(
550
550
  f"Error parsing user information from external "
@@ -4,7 +4,7 @@ import os
4
4
  from typing import Any, Dict, Optional
5
5
 
6
6
  import requests
7
- from pydantic import BaseModel, validator
7
+ from pydantic import BaseModel, ConfigDict, field_validator
8
8
  from requests.adapters import HTTPAdapter, Retry
9
9
 
10
10
  from zenml.exceptions import SubscriptionUpgradeRequiredError
@@ -23,7 +23,8 @@ class ZenMLCloudConfiguration(BaseModel):
23
23
  oauth2_audience: str
24
24
  auth0_domain: str
25
25
 
26
- @validator("api_url")
26
+ @field_validator("api_url")
27
+ @classmethod
27
28
  def _strip_trailing_slashes_url(cls, url: str) -> str:
28
29
  """Strip any trailing slashes on the API URL.
29
30
 
@@ -51,12 +52,11 @@ class ZenMLCloudConfiguration(BaseModel):
51
52
 
52
53
  return ZenMLCloudConfiguration(**env_config)
53
54
 
54
- class Config:
55
- """Pydantic configuration class."""
56
-
55
+ model_config = ConfigDict(
57
56
  # Allow extra attributes from configs of previous ZenML versions to
58
57
  # permit downgrading
59
- extra = "allow"
58
+ extra="allow"
59
+ )
60
60
 
61
61
 
62
62
  class ZenMLCloudSession:
@@ -78,7 +78,7 @@ class BaseServerProvider(ABC):
78
78
  if isinstance(config, cls.CONFIG_TYPE):
79
79
  return config
80
80
  try:
81
- return cls.CONFIG_TYPE(**config.dict())
81
+ return cls.CONFIG_TYPE(**config.model_dump())
82
82
  except ValidationError as e:
83
83
  raise ServerDeploymentConfigurationError(
84
84
  f"Invalid configuration for provider {cls.TYPE.value}: {e}"
@@ -15,7 +15,7 @@
15
15
 
16
16
  from typing import Optional
17
17
 
18
- from pydantic import BaseModel
18
+ from pydantic import BaseModel, ConfigDict
19
19
 
20
20
  from zenml.enums import ServerProviderType
21
21
  from zenml.services.service_status import ServiceState
@@ -34,16 +34,14 @@ class ServerDeploymentConfig(BaseModel):
34
34
 
35
35
  name: str
36
36
  provider: ServerProviderType
37
-
38
- class Config:
39
- """Pydantic configuration class."""
40
-
37
+ model_config = ConfigDict(
41
38
  # Validate attributes when assigning them. We need to set this in order
42
39
  # to have a mix of mutable and immutable attributes
43
- validate_assignment = True
40
+ validate_assignment=True,
44
41
  # Allow extra attributes to be set in the base class. The concrete
45
42
  # classes are responsible for validating the attributes.
46
- extra = "allow"
43
+ extra="allow",
44
+ )
47
45
 
48
46
 
49
47
  class ServerDeploymentStatus(BaseModel):
@@ -83,7 +81,7 @@ class ServerDeployment(BaseModel):
83
81
  """
84
82
 
85
83
  config: ServerDeploymentConfig
86
- status: Optional[ServerDeploymentStatus]
84
+ status: Optional[ServerDeploymentStatus] = None
87
85
 
88
86
  @property
89
87
  def is_running(self) -> bool:
@@ -16,6 +16,8 @@
16
16
  import os
17
17
  from typing import Dict, List, Optional, Tuple, cast
18
18
 
19
+ from pydantic import ConfigDict
20
+
19
21
  import zenml
20
22
  from zenml.config.global_config import GlobalConfiguration
21
23
  from zenml.config.store_config import StoreConfiguration
@@ -70,10 +72,7 @@ class DockerServerDeploymentConfig(ServerDeploymentConfig):
70
72
  store: Optional[StoreConfiguration] = None
71
73
  use_legacy_dashboard: bool = DEFAULT_ZENML_SERVER_USE_LEGACY_DASHBOARD
72
74
 
73
- class Config:
74
- """Pydantic configuration."""
75
-
76
- extra = "forbid"
75
+ model_config = ConfigDict(extra="forbid")
77
76
 
78
77
 
79
78
  class DockerZenServerConfig(ContainerServiceConfig):
@@ -62,7 +62,6 @@ class LocalServerProvider(BaseServerProvider):
62
62
  try:
63
63
  # Make sure the ZenML Server dependencies are installed
64
64
  import fastapi # noqa
65
- import fastapi_utils # noqa
66
65
  import jwt # noqa
67
66
  import multipart # noqa
68
67
  import uvicorn # noqa
@@ -17,6 +17,8 @@ import ipaddress
17
17
  import os
18
18
  from typing import Dict, List, Optional, Tuple, Union, cast
19
19
 
20
+ from pydantic import ConfigDict, Field
21
+
20
22
  from zenml.client import Client
21
23
  from zenml.config.global_config import GlobalConfiguration
22
24
  from zenml.config.store_config import StoreConfiguration
@@ -60,17 +62,15 @@ class LocalServerDeploymentConfig(ServerDeploymentConfig):
60
62
  """
61
63
 
62
64
  port: int = 8237
63
- ip_address: Union[ipaddress.IPv4Address, ipaddress.IPv6Address] = (
64
- ipaddress.IPv4Address(DEFAULT_LOCAL_SERVICE_IP_ADDRESS)
65
+ ip_address: Union[ipaddress.IPv4Address, ipaddress.IPv6Address] = Field(
66
+ default=ipaddress.IPv4Address(DEFAULT_LOCAL_SERVICE_IP_ADDRESS),
67
+ union_mode="left_to_right",
65
68
  )
66
69
  blocking: bool = False
67
70
  store: Optional[StoreConfiguration] = None
68
71
  use_legacy_dashboard: bool = DEFAULT_ZENML_SERVER_USE_LEGACY_DASHBOARD
69
72
 
70
- class Config:
71
- """Pydantic configuration."""
72
-
73
- extra = "forbid"
73
+ model_config = ConfigDict(extra="forbid")
74
74
 
75
75
 
76
76
  class LocalZenServerConfig(LocalDaemonServiceConfig):
@@ -19,6 +19,8 @@ from pathlib import Path
19
19
  from typing import Any, Dict, Optional, cast
20
20
  from uuid import UUID
21
21
 
22
+ from pydantic import ConfigDict
23
+
22
24
  from zenml.logger import get_logger
23
25
  from zenml.services import ServiceType
24
26
  from zenml.services.terraform.terraform_service import (
@@ -137,11 +139,7 @@ class TerraformServerDeploymentConfig(ServerDeploymentConfig):
137
139
  database_ssl_key: str = ""
138
140
  database_ssl_verify_server_cert: bool = True
139
141
  analytics_opt_in: bool = True
140
-
141
- class Config:
142
- """Pydantic configuration."""
143
-
144
- extra = "allow"
142
+ model_config = ConfigDict(extra="allow")
145
143
 
146
144
 
147
145
  class TerraformZenServerConfig(TerraformServiceConfig):
@@ -199,7 +197,7 @@ class TerraformZenServer(TerraformService):
199
197
  # filter keys that are not modeled as terraform deployment vars
200
198
  vars = {
201
199
  k: str(v) if isinstance(v, UUID) else v
202
- for k, v in self.config.server.dict().items()
200
+ for k, v in self.config.server.model_dump().items()
203
201
  if k not in filter_vars
204
202
  }
205
203
  assert self.status.runtime_path
@@ -24,6 +24,7 @@ from zenml.exceptions import (
24
24
  DuplicateRunNameError,
25
25
  EntityExistsError,
26
26
  IllegalOperationError,
27
+ MethodNotAllowedError,
27
28
  SecretExistsError,
28
29
  StackComponentExistsError,
29
30
  StackExistsError,
@@ -39,7 +40,7 @@ if TYPE_CHECKING:
39
40
  class ErrorModel(BaseModel):
40
41
  """Base class for error responses."""
41
42
 
42
- detail: Any
43
+ detail: Optional[Any] = None
43
44
 
44
45
 
45
46
  error_response = dict(model=ErrorModel)
@@ -93,6 +94,8 @@ REST_API_EXCEPTIONS: List[Tuple[Type[Exception], int]] = [
93
94
  (RuntimeError, 500),
94
95
  # 501 Not Implemented,
95
96
  (NotImplementedError, 501),
97
+ # 405 Method Not Allowed
98
+ (MethodNotAllowedError, 405),
96
99
  ]
97
100
 
98
101
 
@@ -109,7 +109,7 @@ class ZenMLCloudFeatureGateInterface(FeatureGateInterface, ZenMLCloudSession):
109
109
  "tenant_id": str(server_config.external_server_id),
110
110
  "resource_id": str(resource_id),
111
111
  },
112
- ).dict()
112
+ ).model_dump()
113
113
  response = self._post(endpoint=USAGE_EVENT_ENDPOINT, data=data)
114
114
  if response.status_code != 200:
115
115
  logger.error(
@@ -9,6 +9,7 @@ from uuid import UUID
9
9
  from fastapi import BackgroundTasks
10
10
  from packaging import version
11
11
 
12
+ from zenml.config.base_settings import BaseSettings
12
13
  from zenml.config.pipeline_configurations import PipelineConfiguration
13
14
  from zenml.config.pipeline_run_configuration import PipelineRunConfiguration
14
15
  from zenml.config.step_configurations import Step, StepConfiguration
@@ -29,10 +30,11 @@ from zenml.models import (
29
30
  )
30
31
  from zenml.new.pipelines.run_utils import (
31
32
  create_placeholder_run,
33
+ validate_run_config_is_runnable_from_server,
34
+ validate_stack_is_runnable_from_server,
32
35
  )
33
- from zenml.orchestrators import BaseOrchestratorConfig
34
36
  from zenml.stack.flavor import Flavor
35
- from zenml.utils import dict_utils, pydantic_utils
37
+ from zenml.utils import dict_utils, pydantic_utils, settings_utils
36
38
  from zenml.zen_server.auth import AuthContext
37
39
  from zenml.zen_server.pipeline_deployment.runner_entrypoint_configuration import (
38
40
  RunnerEntrypointConfiguration,
@@ -73,21 +75,32 @@ def run_pipeline(
73
75
  if not stack:
74
76
  raise ValueError("Unable to run deployment without associated stack.")
75
77
 
76
- validate_stack(stack)
78
+ validate_stack_is_runnable_from_server(zen_store=zen_store(), stack=stack)
79
+ if run_config:
80
+ validate_run_config_is_runnable_from_server(run_config)
77
81
 
78
82
  deployment_request = apply_run_config(
79
83
  deployment=deployment,
80
84
  run_config=run_config or PipelineRunConfiguration(),
81
85
  user_id=auth_context.user.id,
82
86
  )
87
+
88
+ ensure_async_orchestrator(deployment=deployment_request, stack=stack)
89
+
83
90
  new_deployment = zen_store().create_deployment(deployment_request)
84
91
  placeholder_run = create_placeholder_run(deployment=new_deployment)
85
92
  assert placeholder_run
86
93
 
87
- api_token = auth_context.encoded_access_token
88
- if not api_token:
89
- assert auth_context.access_token
90
- api_token = auth_context.access_token.encode()
94
+ if auth_context.access_token:
95
+ token = auth_context.access_token
96
+ token.pipeline_id = deployment_request.pipeline
97
+
98
+ # We create a non-expiring token to make sure its active for the entire
99
+ # duration of the pipeline run
100
+ api_token = token.encode(expires=None)
101
+ else:
102
+ assert auth_context.encoded_access_token
103
+ api_token = auth_context.encoded_access_token
91
104
 
92
105
  server_url = server_config().server_url
93
106
  if not server_url:
@@ -170,39 +183,35 @@ def run_pipeline(
170
183
  return placeholder_run
171
184
 
172
185
 
173
- def validate_stack(stack: StackResponse) -> None:
174
- """Validate a stack model.
186
+ def ensure_async_orchestrator(
187
+ deployment: PipelineDeploymentRequest, stack: StackResponse
188
+ ) -> None:
189
+ """Ensures the orchestrator is configured to run async.
175
190
 
176
191
  Args:
177
- stack: The stack to validate.
178
-
179
- Raises:
180
- ValueError: If the stack has components of a custom flavor, local
181
- components or a synchronous orchestrator.
192
+ deployment: Deployment request in which the orchestrator
193
+ configuration should be updated to ensure the orchestrator is
194
+ running async.
195
+ stack: The stack on which the deployment will run.
182
196
  """
183
- for component_list in stack.components.values():
184
- assert len(component_list) == 1
185
- component = component_list[0]
186
- flavors = zen_store().list_flavors(
187
- FlavorFilter(name=component.flavor, type=component.type)
188
- )
189
- assert len(flavors) == 1
190
- flavor_model = flavors[0]
191
-
192
- if flavor_model.workspace is not None:
193
- raise ValueError("No custom stack component flavors allowed.")
194
-
195
- flavor = Flavor.from_model(flavor_model)
196
- component_config = flavor.config_class(**component.configuration)
197
+ orchestrator = stack.components[StackComponentType.ORCHESTRATOR][0]
198
+ flavors = zen_store().list_flavors(
199
+ FlavorFilter(name=orchestrator.flavor, type=orchestrator.type)
200
+ )
201
+ flavor = Flavor.from_model(flavors[0])
197
202
 
198
- if component_config.is_local:
199
- raise ValueError("No local stack components allowed.")
203
+ if "synchronous" in flavor.config_class.model_fields:
204
+ key = settings_utils.get_flavor_setting_key(flavor)
200
205
 
201
- if flavor.type == StackComponentType.ORCHESTRATOR:
202
- assert isinstance(component_config, BaseOrchestratorConfig)
206
+ if settings := deployment.pipeline_configuration.settings.get(key):
207
+ settings_dict = settings.model_dump()
208
+ else:
209
+ settings_dict = {}
203
210
 
204
- if component_config.is_synchronous:
205
- raise ValueError("No synchronous orchestrator allowed.")
211
+ settings_dict["synchronous"] = False
212
+ deployment.pipeline_configuration.settings[key] = (
213
+ BaseSettings.model_validate(settings_dict)
214
+ )
206
215
 
207
216
 
208
217
  def get_requirements_for_stack(
@@ -326,57 +335,28 @@ def apply_run_config(
326
335
  run_config: The run configuration to apply.
327
336
  user_id: The ID of the user that wants to run the deployment.
328
337
 
329
- Raises:
330
- ValueError: If the run configuration contains values that can't be
331
- updated when running a pipeline deployment.
332
-
333
338
  Returns:
334
339
  The updated deployment.
335
340
  """
336
- pipeline_updates = {}
337
-
338
- if run_config.parameters:
339
- raise ValueError(
340
- "Can't set parameters when running pipeline via Rest API."
341
- )
342
-
343
- if run_config.build:
344
- raise ValueError("Can't set build when running pipeline via Rest API.")
345
-
346
- if run_config.schedule:
347
- raise ValueError(
348
- "Can't set schedule when running pipeline via Rest API."
349
- )
350
-
351
- if run_config.settings.get("docker"):
352
- raise ValueError(
353
- "Can't set DockerSettings when running pipeline via Rest API."
354
- )
355
-
356
- pipeline_updates = run_config.dict(
357
- exclude_none=True, include=set(PipelineConfiguration.__fields__)
341
+ pipeline_updates = run_config.model_dump(
342
+ exclude_none=True, include=set(PipelineConfiguration.model_fields)
358
343
  )
359
344
 
360
345
  pipeline_configuration = pydantic_utils.update_model(
361
346
  deployment.pipeline_configuration, update=pipeline_updates
362
347
  )
363
- pipeline_configuration_dict = pipeline_configuration.dict(
348
+ pipeline_configuration_dict = pipeline_configuration.model_dump(
364
349
  exclude_none=True
365
350
  )
366
351
  steps = {}
367
352
  for invocation_id, step in deployment.step_configurations.items():
368
353
  step_config_dict = dict_utils.recursive_update(
369
354
  copy.deepcopy(pipeline_configuration_dict),
370
- update=step.config.dict(exclude_none=True),
355
+ update=step.config.model_dump(exclude_none=True),
371
356
  )
372
- step_config = StepConfiguration.parse_obj(step_config_dict)
357
+ step_config = StepConfiguration.model_validate(step_config_dict)
373
358
 
374
359
  if update := run_config.steps.get(invocation_id):
375
- if update.settings.get("docker"):
376
- raise ValueError(
377
- "Can't set DockerSettings when running pipeline via Rest API."
378
- )
379
-
380
360
  step_config = pydantic_utils.update_model(
381
361
  step_config, update=update
382
362
  )