zenml-nightly 0.58.2.dev20240614__py3-none-any.whl → 0.58.2.dev20240622__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.
- zenml/VERSION +1 -1
- zenml/_hub/client.py +8 -5
- zenml/actions/base_action.py +8 -10
- zenml/artifact_stores/base_artifact_store.py +20 -15
- zenml/artifact_stores/local_artifact_store.py +3 -2
- zenml/artifacts/artifact_config.py +34 -19
- zenml/artifacts/external_artifact.py +18 -8
- zenml/artifacts/external_artifact_config.py +14 -6
- zenml/artifacts/unmaterialized_artifact.py +2 -11
- zenml/cli/__init__.py +6 -0
- zenml/cli/artifact.py +20 -2
- zenml/cli/base.py +2 -2
- zenml/cli/served_model.py +0 -1
- zenml/cli/server.py +3 -3
- zenml/cli/utils.py +36 -40
- zenml/cli/web_login.py +2 -2
- zenml/client.py +198 -24
- zenml/client_lazy_loader.py +20 -14
- zenml/config/base_settings.py +5 -6
- zenml/config/build_configuration.py +1 -1
- zenml/config/compiler.py +3 -3
- zenml/config/docker_settings.py +27 -28
- zenml/config/global_config.py +33 -37
- zenml/config/pipeline_configurations.py +8 -11
- zenml/config/pipeline_run_configuration.py +6 -2
- zenml/config/pipeline_spec.py +3 -4
- zenml/config/resource_settings.py +8 -9
- zenml/config/schedule.py +16 -20
- zenml/config/secret_reference_mixin.py +6 -3
- zenml/config/secrets_store_config.py +16 -23
- zenml/config/server_config.py +50 -46
- zenml/config/settings_resolver.py +1 -1
- zenml/config/source.py +45 -35
- zenml/config/step_configurations.py +53 -31
- zenml/config/step_run_info.py +3 -0
- zenml/config/store_config.py +20 -19
- zenml/config/strict_base_model.py +2 -6
- zenml/constants.py +26 -2
- zenml/container_registries/base_container_registry.py +3 -2
- zenml/container_registries/default_container_registry.py +3 -3
- zenml/event_hub/base_event_hub.py +1 -1
- zenml/event_sources/base_event_source.py +11 -16
- zenml/exceptions.py +4 -0
- zenml/integrations/airflow/__init__.py +2 -6
- zenml/integrations/airflow/flavors/airflow_orchestrator_flavor.py +6 -7
- zenml/integrations/airflow/orchestrators/airflow_orchestrator.py +13 -249
- zenml/integrations/airflow/orchestrators/dag_generator.py +5 -3
- zenml/integrations/argilla/flavors/argilla_annotator_flavor.py +5 -4
- zenml/integrations/aws/__init__.py +1 -1
- zenml/integrations/aws/flavors/aws_container_registry_flavor.py +3 -2
- zenml/integrations/aws/flavors/sagemaker_orchestrator_flavor.py +11 -5
- zenml/integrations/aws/flavors/sagemaker_step_operator_flavor.py +6 -2
- zenml/integrations/aws/service_connectors/aws_service_connector.py +5 -4
- zenml/integrations/aws/step_operators/sagemaker_step_operator.py +1 -1
- zenml/integrations/azure/flavors/azureml_step_operator_flavor.py +4 -4
- zenml/integrations/azure/service_connectors/azure_service_connector.py +4 -3
- zenml/integrations/azure/step_operators/azureml_step_operator.py +2 -1
- zenml/integrations/bentoml/steps/bentoml_deployer.py +1 -1
- zenml/integrations/bitbucket/plugins/event_sources/bitbucket_webhook_event_source.py +8 -12
- zenml/integrations/comet/flavors/comet_experiment_tracker_flavor.py +1 -1
- zenml/integrations/constants.py +0 -1
- zenml/integrations/deepchecks/__init__.py +1 -0
- zenml/integrations/evidently/__init__.py +5 -3
- zenml/integrations/evidently/column_mapping.py +11 -3
- zenml/integrations/evidently/data_validators/evidently_data_validator.py +21 -3
- zenml/integrations/evidently/metrics.py +5 -6
- zenml/integrations/evidently/tests.py +5 -6
- zenml/integrations/facets/models.py +2 -6
- zenml/integrations/feast/__init__.py +3 -1
- zenml/integrations/feast/feature_stores/feast_feature_store.py +0 -23
- zenml/integrations/gcp/__init__.py +1 -1
- zenml/integrations/gcp/flavors/vertex_orchestrator_flavor.py +1 -1
- zenml/integrations/gcp/flavors/vertex_step_operator_flavor.py +1 -1
- zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +234 -103
- zenml/integrations/gcp/service_connectors/gcp_service_connector.py +57 -42
- zenml/integrations/gcp/step_operators/vertex_step_operator.py +1 -0
- zenml/integrations/github/code_repositories/github_code_repository.py +1 -1
- zenml/integrations/github/plugins/event_sources/github_webhook_event_source.py +9 -13
- zenml/integrations/great_expectations/__init__.py +1 -1
- zenml/integrations/great_expectations/data_validators/ge_data_validator.py +44 -44
- zenml/integrations/great_expectations/flavors/great_expectations_data_validator_flavor.py +35 -2
- zenml/integrations/great_expectations/ge_store_backend.py +24 -11
- zenml/integrations/great_expectations/materializers/ge_materializer.py +3 -3
- zenml/integrations/great_expectations/utils.py +5 -5
- zenml/integrations/huggingface/__init__.py +3 -0
- zenml/integrations/huggingface/flavors/huggingface_model_deployer_flavor.py +1 -1
- zenml/integrations/huggingface/steps/__init__.py +3 -0
- zenml/integrations/huggingface/steps/accelerate_runner.py +149 -0
- zenml/integrations/huggingface/steps/huggingface_deployer.py +2 -2
- zenml/integrations/hyperai/flavors/hyperai_orchestrator_flavor.py +1 -1
- zenml/integrations/hyperai/service_connectors/hyperai_service_connector.py +4 -3
- zenml/integrations/kubeflow/__init__.py +1 -1
- zenml/integrations/kubeflow/flavors/kubeflow_orchestrator_flavor.py +48 -81
- zenml/integrations/kubeflow/orchestrators/kubeflow_orchestrator.py +295 -245
- zenml/integrations/kubernetes/flavors/kubernetes_orchestrator_flavor.py +1 -1
- zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py +11 -2
- zenml/integrations/kubernetes/pod_settings.py +17 -31
- zenml/integrations/kubernetes/service_connectors/kubernetes_service_connector.py +8 -7
- zenml/integrations/label_studio/__init__.py +1 -3
- zenml/integrations/label_studio/annotators/label_studio_annotator.py +3 -4
- zenml/integrations/label_studio/flavors/label_studio_annotator_flavor.py +2 -2
- zenml/integrations/langchain/__init__.py +5 -1
- zenml/integrations/langchain/materializers/document_materializer.py +44 -8
- zenml/integrations/mlflow/__init__.py +9 -3
- zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py +1 -1
- zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py +29 -37
- zenml/integrations/mlflow/model_registries/mlflow_model_registry.py +4 -4
- zenml/integrations/mlflow/steps/mlflow_deployer.py +1 -1
- zenml/integrations/neptune/flavors/neptune_experiment_tracker_flavor.py +1 -1
- zenml/integrations/neural_prophet/__init__.py +5 -1
- zenml/integrations/pigeon/flavors/pigeon_annotator_flavor.py +1 -1
- zenml/integrations/s3/flavors/s3_artifact_store_flavor.py +9 -8
- zenml/integrations/seldon/seldon_client.py +52 -67
- zenml/integrations/seldon/services/seldon_deployment.py +3 -3
- zenml/integrations/seldon/steps/seldon_deployer.py +4 -4
- zenml/integrations/skypilot/flavors/skypilot_orchestrator_base_vm_config.py +15 -5
- zenml/integrations/skypilot_aws/__init__.py +1 -1
- zenml/integrations/skypilot_aws/flavors/skypilot_orchestrator_aws_vm_flavor.py +1 -1
- zenml/integrations/skypilot_azure/__init__.py +1 -1
- zenml/integrations/skypilot_azure/flavors/skypilot_orchestrator_azure_vm_flavor.py +1 -1
- zenml/integrations/skypilot_gcp/__init__.py +2 -1
- zenml/integrations/skypilot_gcp/flavors/skypilot_orchestrator_gcp_vm_flavor.py +1 -1
- zenml/integrations/skypilot_lambda/flavors/skypilot_orchestrator_lambda_vm_flavor.py +2 -2
- zenml/integrations/spark/flavors/spark_step_operator_flavor.py +1 -1
- zenml/integrations/spark/step_operators/spark_step_operator.py +2 -0
- zenml/integrations/tekton/__init__.py +1 -1
- zenml/integrations/tekton/flavors/tekton_orchestrator_flavor.py +66 -23
- zenml/integrations/tekton/orchestrators/tekton_orchestrator.py +547 -233
- zenml/integrations/tensorboard/__init__.py +1 -12
- zenml/integrations/tensorboard/services/tensorboard_service.py +3 -5
- zenml/integrations/tensorboard/visualizers/tensorboard_visualizer.py +6 -6
- zenml/integrations/tensorflow/__init__.py +2 -10
- zenml/integrations/tensorflow/materializers/keras_materializer.py +17 -9
- zenml/integrations/wandb/flavors/wandb_experiment_tracker_flavor.py +9 -14
- zenml/integrations/whylogs/flavors/whylogs_data_validator_flavor.py +1 -1
- zenml/lineage_graph/lineage_graph.py +1 -1
- zenml/logging/step_logging.py +15 -7
- zenml/materializers/built_in_materializer.py +3 -3
- zenml/materializers/pydantic_materializer.py +2 -2
- zenml/metadata/lazy_load.py +4 -4
- zenml/metadata/metadata_types.py +64 -4
- zenml/model/model.py +79 -54
- zenml/model_deployers/base_model_deployer.py +14 -12
- zenml/model_registries/base_model_registry.py +17 -15
- zenml/models/__init__.py +79 -206
- zenml/models/v2/base/base.py +54 -41
- zenml/models/v2/base/base_plugin_flavor.py +2 -6
- zenml/models/v2/base/filter.py +91 -76
- zenml/models/v2/base/page.py +2 -12
- zenml/models/v2/base/scoped.py +4 -7
- zenml/models/v2/core/api_key.py +22 -8
- zenml/models/v2/core/artifact.py +2 -2
- zenml/models/v2/core/artifact_version.py +74 -40
- zenml/models/v2/core/code_repository.py +37 -10
- zenml/models/v2/core/component.py +65 -16
- zenml/models/v2/core/device.py +14 -4
- zenml/models/v2/core/event_source.py +1 -2
- zenml/models/v2/core/flavor.py +74 -8
- zenml/models/v2/core/logs.py +68 -8
- zenml/models/v2/core/model.py +8 -4
- zenml/models/v2/core/model_version.py +25 -6
- zenml/models/v2/core/model_version_artifact.py +51 -21
- zenml/models/v2/core/model_version_pipeline_run.py +45 -13
- zenml/models/v2/core/pipeline.py +37 -72
- zenml/models/v2/core/pipeline_build.py +29 -17
- zenml/models/v2/core/pipeline_deployment.py +18 -6
- zenml/models/v2/core/pipeline_namespace.py +113 -0
- zenml/models/v2/core/pipeline_run.py +50 -22
- zenml/models/v2/core/run_metadata.py +59 -36
- zenml/models/v2/core/schedule.py +37 -24
- zenml/models/v2/core/secret.py +31 -12
- zenml/models/v2/core/service.py +64 -36
- zenml/models/v2/core/service_account.py +24 -11
- zenml/models/v2/core/service_connector.py +219 -44
- zenml/models/v2/core/stack.py +45 -17
- zenml/models/v2/core/step_run.py +28 -8
- zenml/models/v2/core/tag.py +8 -4
- zenml/models/v2/core/trigger.py +2 -2
- zenml/models/v2/core/trigger_execution.py +1 -0
- zenml/models/v2/core/user.py +18 -21
- zenml/models/v2/core/workspace.py +13 -3
- zenml/models/v2/misc/build_item.py +3 -3
- zenml/models/v2/misc/external_user.py +2 -6
- zenml/models/v2/misc/hub_plugin_models.py +9 -9
- zenml/models/v2/misc/loaded_visualization.py +2 -2
- zenml/models/v2/misc/service_connector_type.py +8 -17
- zenml/models/v2/misc/user_auth.py +7 -2
- zenml/new/pipelines/build_utils.py +3 -3
- zenml/new/pipelines/pipeline.py +17 -13
- zenml/new/pipelines/run_utils.py +103 -1
- zenml/orchestrators/base_orchestrator.py +10 -7
- zenml/orchestrators/local_docker/local_docker_orchestrator.py +1 -1
- zenml/orchestrators/step_launcher.py +28 -4
- zenml/orchestrators/step_runner.py +3 -6
- zenml/orchestrators/utils.py +1 -1
- zenml/plugins/base_plugin_flavor.py +6 -10
- zenml/plugins/plugin_flavor_registry.py +3 -7
- zenml/secret/base_secret.py +7 -8
- zenml/service_connectors/docker_service_connector.py +4 -3
- zenml/service_connectors/service_connector.py +5 -12
- zenml/service_connectors/service_connector_registry.py +2 -4
- zenml/services/container/container_service.py +1 -1
- zenml/services/container/container_service_endpoint.py +1 -1
- zenml/services/local/local_service.py +1 -1
- zenml/services/local/local_service_endpoint.py +1 -1
- zenml/services/service.py +16 -10
- zenml/services/service_type.py +4 -5
- zenml/services/terraform/terraform_service.py +1 -1
- zenml/stack/flavor.py +2 -6
- zenml/stack/flavor_registry.py +4 -4
- zenml/stack/stack.py +4 -1
- zenml/stack/stack_component.py +55 -31
- zenml/step_operators/step_operator_entrypoint_configuration.py +1 -0
- zenml/steps/base_step.py +34 -28
- zenml/steps/entrypoint_function_utils.py +3 -5
- zenml/steps/utils.py +12 -14
- zenml/utils/cuda_utils.py +50 -0
- zenml/utils/deprecation_utils.py +18 -20
- zenml/utils/dict_utils.py +1 -1
- zenml/utils/filesync_model.py +65 -28
- zenml/utils/function_utils.py +260 -0
- zenml/utils/json_utils.py +131 -0
- zenml/utils/mlstacks_utils.py +2 -2
- zenml/utils/package_utils.py +1 -1
- zenml/utils/pipeline_docker_image_builder.py +9 -0
- zenml/utils/pydantic_utils.py +270 -62
- zenml/utils/secret_utils.py +65 -12
- zenml/utils/source_utils.py +2 -2
- zenml/utils/typed_model.py +5 -3
- zenml/utils/typing_utils.py +243 -0
- zenml/utils/yaml_utils.py +1 -1
- zenml/zen_server/auth.py +2 -2
- zenml/zen_server/cloud_utils.py +6 -6
- zenml/zen_server/deploy/base_provider.py +1 -1
- zenml/zen_server/deploy/deployment.py +6 -8
- zenml/zen_server/deploy/docker/docker_zen_server.py +3 -4
- zenml/zen_server/deploy/local/local_provider.py +0 -1
- zenml/zen_server/deploy/local/local_zen_server.py +6 -6
- zenml/zen_server/deploy/terraform/terraform_zen_server.py +4 -6
- zenml/zen_server/exceptions.py +4 -1
- zenml/zen_server/feature_gate/zenml_cloud_feature_gate.py +1 -1
- zenml/zen_server/pipeline_deployment/utils.py +48 -68
- zenml/zen_server/rbac/models.py +2 -5
- zenml/zen_server/rbac/utils.py +11 -14
- zenml/zen_server/routers/auth_endpoints.py +2 -2
- zenml/zen_server/routers/pipeline_builds_endpoints.py +1 -1
- zenml/zen_server/routers/runs_endpoints.py +1 -1
- zenml/zen_server/routers/secrets_endpoints.py +3 -2
- zenml/zen_server/routers/server_endpoints.py +1 -1
- zenml/zen_server/routers/steps_endpoints.py +1 -1
- zenml/zen_server/routers/workspaces_endpoints.py +1 -1
- zenml/zen_stores/base_zen_store.py +46 -9
- zenml/zen_stores/migrations/utils.py +42 -46
- zenml/zen_stores/migrations/versions/0701da9951a0_added_service_table.py +1 -1
- zenml/zen_stores/migrations/versions/1041bc644e0d_remove_secrets_manager.py +5 -3
- zenml/zen_stores/migrations/versions/10a907dad202_delete_mlmd_tables.py +1 -1
- zenml/zen_stores/migrations/versions/26b776ad583e_redesign_artifacts.py +8 -10
- zenml/zen_stores/migrations/versions/37835ce041d2_optimizing_database.py +3 -3
- zenml/zen_stores/migrations/versions/46506f72f0ed_add_server_settings.py +10 -12
- zenml/zen_stores/migrations/versions/5994f9ad0489_introduce_role_permissions.py +3 -2
- zenml/zen_stores/migrations/versions/6917bce75069_add_pipeline_run_unique_constraint.py +4 -4
- zenml/zen_stores/migrations/versions/728c6369cfaa_add_name_column_to_input_artifact_pk.py +3 -2
- zenml/zen_stores/migrations/versions/743ec82b1b3c_update_size_of_build_images.py +2 -2
- zenml/zen_stores/migrations/versions/7500f434b71c_remove_shared_columns.py +3 -2
- zenml/zen_stores/migrations/versions/7834208cc3f6_artifact_project_scoping.py +8 -7
- zenml/zen_stores/migrations/versions/7b651bf6822e_track_secrets_in_db.py +6 -4
- zenml/zen_stores/migrations/versions/7e4a481d17f7_add_identity_table.py +2 -2
- zenml/zen_stores/migrations/versions/7f603e583dd7_fixed_migration.py +1 -1
- zenml/zen_stores/migrations/versions/a39c4184c8ce_remove_secrets_manager_flavors.py +2 -2
- zenml/zen_stores/migrations/versions/a91762e6be36_artifact_version_table.py +4 -4
- zenml/zen_stores/migrations/versions/alembic_start.py +1 -1
- zenml/zen_stores/migrations/versions/fbd7f18ced1e_increase_step_run_field_lengths.py +4 -4
- zenml/zen_stores/rest_zen_store.py +109 -49
- zenml/zen_stores/schemas/api_key_schemas.py +1 -1
- zenml/zen_stores/schemas/artifact_schemas.py +8 -8
- zenml/zen_stores/schemas/artifact_visualization_schemas.py +3 -3
- zenml/zen_stores/schemas/code_repository_schemas.py +1 -1
- zenml/zen_stores/schemas/component_schemas.py +8 -3
- zenml/zen_stores/schemas/device_schemas.py +8 -6
- zenml/zen_stores/schemas/event_source_schemas.py +3 -4
- zenml/zen_stores/schemas/flavor_schemas.py +5 -3
- zenml/zen_stores/schemas/model_schemas.py +26 -1
- zenml/zen_stores/schemas/pipeline_build_schemas.py +1 -1
- zenml/zen_stores/schemas/pipeline_deployment_schemas.py +4 -4
- zenml/zen_stores/schemas/pipeline_run_schemas.py +6 -6
- zenml/zen_stores/schemas/pipeline_schemas.py +5 -2
- zenml/zen_stores/schemas/run_metadata_schemas.py +2 -2
- zenml/zen_stores/schemas/secret_schemas.py +8 -5
- zenml/zen_stores/schemas/server_settings_schemas.py +3 -1
- zenml/zen_stores/schemas/service_connector_schemas.py +1 -1
- zenml/zen_stores/schemas/service_schemas.py +11 -2
- zenml/zen_stores/schemas/stack_schemas.py +1 -1
- zenml/zen_stores/schemas/step_run_schemas.py +11 -11
- zenml/zen_stores/schemas/tag_schemas.py +6 -2
- zenml/zen_stores/schemas/trigger_schemas.py +2 -2
- zenml/zen_stores/schemas/user_schemas.py +2 -2
- zenml/zen_stores/schemas/workspace_schemas.py +3 -1
- zenml/zen_stores/secrets_stores/aws_secrets_store.py +19 -20
- zenml/zen_stores/secrets_stores/azure_secrets_store.py +17 -20
- zenml/zen_stores/secrets_stores/base_secrets_store.py +79 -12
- zenml/zen_stores/secrets_stores/gcp_secrets_store.py +17 -20
- zenml/zen_stores/secrets_stores/hashicorp_secrets_store.py +4 -8
- zenml/zen_stores/secrets_stores/service_connector_secrets_store.py +10 -7
- zenml/zen_stores/secrets_stores/sql_secrets_store.py +5 -6
- zenml/zen_stores/sql_zen_store.py +196 -120
- zenml/zen_stores/zen_store_interface.py +33 -0
- {zenml_nightly-0.58.2.dev20240614.dist-info → zenml_nightly-0.58.2.dev20240622.dist-info}/METADATA +9 -7
- {zenml_nightly-0.58.2.dev20240614.dist-info → zenml_nightly-0.58.2.dev20240622.dist-info}/RECORD +311 -308
- zenml/integrations/kubeflow/utils.py +0 -95
- zenml/models/v2/base/internal.py +0 -37
- zenml/models/v2/base/update.py +0 -44
- {zenml_nightly-0.58.2.dev20240614.dist-info → zenml_nightly-0.58.2.dev20240622.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.58.2.dev20240614.dist-info → zenml_nightly-0.58.2.dev20240622.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.58.2.dev20240614.dist-info → zenml_nightly-0.58.2.dev20240622.dist-info}/entry_points.txt +0 -0
zenml/config/server_config.py
CHANGED
@@ -19,7 +19,7 @@ from secrets import token_hex
|
|
19
19
|
from typing import Any, Dict, List, Optional, Union
|
20
20
|
from uuid import UUID
|
21
21
|
|
22
|
-
from pydantic import BaseModel,
|
22
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
23
23
|
|
24
24
|
from zenml.constants import (
|
25
25
|
DEFAULT_ZENML_JWT_TOKEN_ALGORITHM,
|
@@ -46,6 +46,7 @@ from zenml.constants import (
|
|
46
46
|
from zenml.enums import AuthScheme
|
47
47
|
from zenml.logger import get_logger
|
48
48
|
from zenml.models import ServerDeploymentType
|
49
|
+
from zenml.utils.pydantic_utils import before_validator_handler
|
49
50
|
|
50
51
|
logger = get_logger(__name__)
|
51
52
|
|
@@ -270,30 +271,41 @@ class ServerConfiguration(BaseModel):
|
|
270
271
|
login_rate_limit_minute: int = DEFAULT_ZENML_SERVER_LOGIN_RATE_LIMIT_MINUTE
|
271
272
|
login_rate_limit_day: int = DEFAULT_ZENML_SERVER_LOGIN_RATE_LIMIT_DAY
|
272
273
|
|
273
|
-
secure_headers_server: Union[bool, str] =
|
274
|
-
|
275
|
-
|
274
|
+
secure_headers_server: Union[bool, str] = Field(
|
275
|
+
default=True,
|
276
|
+
union_mode="left_to_right",
|
276
277
|
)
|
277
|
-
|
278
|
-
|
278
|
+
secure_headers_hsts: Union[bool, str] = Field(
|
279
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_HSTS,
|
280
|
+
union_mode="left_to_right",
|
279
281
|
)
|
280
|
-
|
281
|
-
|
282
|
+
secure_headers_xfo: Union[bool, str] = Field(
|
283
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_XFO,
|
284
|
+
union_mode="left_to_right",
|
282
285
|
)
|
283
|
-
|
284
|
-
|
286
|
+
secure_headers_xxp: Union[bool, str] = Field(
|
287
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_XXP,
|
288
|
+
union_mode="left_to_right",
|
285
289
|
)
|
286
|
-
|
287
|
-
|
290
|
+
secure_headers_content: Union[bool, str] = Field(
|
291
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_CONTENT,
|
292
|
+
union_mode="left_to_right",
|
288
293
|
)
|
289
|
-
|
290
|
-
|
294
|
+
secure_headers_csp: Union[bool, str] = Field(
|
295
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_CSP,
|
296
|
+
union_mode="left_to_right",
|
291
297
|
)
|
292
|
-
|
293
|
-
|
298
|
+
secure_headers_referrer: Union[bool, str] = Field(
|
299
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_REFERRER,
|
300
|
+
union_mode="left_to_right",
|
294
301
|
)
|
295
|
-
|
296
|
-
|
302
|
+
secure_headers_cache: Union[bool, str] = Field(
|
303
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_CACHE,
|
304
|
+
union_mode="left_to_right",
|
305
|
+
)
|
306
|
+
secure_headers_permissions: Union[bool, str] = Field(
|
307
|
+
default=DEFAULT_ZENML_SERVER_SECURE_HEADERS_PERMISSIONS,
|
308
|
+
union_mode="left_to_right",
|
297
309
|
)
|
298
310
|
use_legacy_dashboard: bool = DEFAULT_ZENML_SERVER_USE_LEGACY_DASHBOARD
|
299
311
|
|
@@ -306,12 +318,14 @@ class ServerConfiguration(BaseModel):
|
|
306
318
|
|
307
319
|
_deployment_id: Optional[UUID] = None
|
308
320
|
|
309
|
-
@
|
310
|
-
|
321
|
+
@model_validator(mode="before")
|
322
|
+
@classmethod
|
323
|
+
@before_validator_handler
|
324
|
+
def _validate_config(cls, data: Dict[str, Any]) -> Dict[str, Any]:
|
311
325
|
"""Validate the server configuration.
|
312
326
|
|
313
327
|
Args:
|
314
|
-
|
328
|
+
data: The server configuration values.
|
315
329
|
|
316
330
|
Returns:
|
317
331
|
The validated server configuration values.
|
@@ -319,10 +333,10 @@ class ServerConfiguration(BaseModel):
|
|
319
333
|
Raises:
|
320
334
|
ValueError: If the server configuration is invalid.
|
321
335
|
"""
|
322
|
-
if
|
336
|
+
if data.get("auth_scheme") == AuthScheme.EXTERNAL:
|
323
337
|
# If the authentication scheme is set to `EXTERNAL`, the
|
324
338
|
# external authenticator URLs must be specified.
|
325
|
-
if not
|
339
|
+
if not data.get("external_login_url") or not data.get(
|
326
340
|
"external_user_info_url"
|
327
341
|
):
|
328
342
|
raise ValueError(
|
@@ -333,22 +347,22 @@ class ServerConfiguration(BaseModel):
|
|
333
347
|
|
334
348
|
# If the authentication scheme is set to `EXTERNAL`, the
|
335
349
|
# external cookie name must be specified.
|
336
|
-
if not
|
350
|
+
if not data.get("external_cookie_name"):
|
337
351
|
raise ValueError(
|
338
352
|
"The external cookie name must be specified when "
|
339
353
|
"using the EXTERNAL authentication scheme."
|
340
354
|
)
|
341
355
|
|
342
|
-
if cors_allow_origins :=
|
356
|
+
if cors_allow_origins := data.get("cors_allow_origins"):
|
343
357
|
origins = cors_allow_origins.split(",")
|
344
|
-
|
358
|
+
data["cors_allow_origins"] = origins
|
345
359
|
else:
|
346
|
-
|
360
|
+
data["cors_allow_origins"] = ["*"]
|
347
361
|
|
348
362
|
# if metadata is a string, convert it to a dictionary
|
349
|
-
if isinstance(
|
363
|
+
if isinstance(data.get("metadata"), str):
|
350
364
|
try:
|
351
|
-
|
365
|
+
data["metadata"] = json.loads(data["metadata"])
|
352
366
|
except json.JSONDecodeError as e:
|
353
367
|
raise ValueError(
|
354
368
|
f"The server metadata is not a valid JSON string: {e}"
|
@@ -356,15 +370,15 @@ class ServerConfiguration(BaseModel):
|
|
356
370
|
|
357
371
|
# if one of the secure headers options is set to a boolean value, set
|
358
372
|
# the corresponding value
|
359
|
-
for k, v in
|
373
|
+
for k, v in data.copy().items():
|
360
374
|
if k.startswith("secure_headers_") and isinstance(v, str):
|
361
375
|
if v.lower() in ["disabled", "no", "none", "false", "off", ""]:
|
362
|
-
|
376
|
+
data[k] = False
|
363
377
|
if v.lower() in ["enabled", "yes", "true", "on"]:
|
364
378
|
# Revert to the default value if the header is enabled
|
365
|
-
del
|
379
|
+
del data[k]
|
366
380
|
|
367
|
-
return
|
381
|
+
return data
|
368
382
|
|
369
383
|
@property
|
370
384
|
def deployment_id(self) -> UUID:
|
@@ -490,18 +504,8 @@ class ServerConfiguration(BaseModel):
|
|
490
504
|
|
491
505
|
return ServerConfiguration(**env_server_config)
|
492
506
|
|
493
|
-
|
494
|
-
"""Pydantic configuration class."""
|
495
|
-
|
507
|
+
model_config = ConfigDict(
|
496
508
|
# Allow extra attributes from configs of previous ZenML versions to
|
497
509
|
# permit downgrading
|
498
|
-
extra
|
499
|
-
|
500
|
-
# are mutable and not included in serialization
|
501
|
-
underscore_attrs_are_private = True
|
502
|
-
|
503
|
-
# This is needed to allow correct handling of SecretStr values during
|
504
|
-
# serialization.
|
505
|
-
json_encoders = {
|
506
|
-
SecretStr: lambda v: v.get_secret_value() if v else None
|
507
|
-
}
|
510
|
+
extra="allow",
|
511
|
+
)
|
zenml/config/source.py
CHANGED
@@ -14,10 +14,17 @@
|
|
14
14
|
"""Source classes."""
|
15
15
|
|
16
16
|
from enum import Enum
|
17
|
-
from typing import TYPE_CHECKING, Any,
|
17
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional
|
18
18
|
from uuid import UUID
|
19
19
|
|
20
|
-
from pydantic import
|
20
|
+
from pydantic import (
|
21
|
+
BaseModel,
|
22
|
+
BeforeValidator,
|
23
|
+
ConfigDict,
|
24
|
+
SerializeAsAny,
|
25
|
+
field_validator,
|
26
|
+
)
|
27
|
+
from typing_extensions import Annotated
|
21
28
|
|
22
29
|
from zenml.logger import get_logger
|
23
30
|
|
@@ -130,10 +137,29 @@ class Source(BaseModel):
|
|
130
137
|
"""
|
131
138
|
return self.attribute is None
|
132
139
|
|
133
|
-
|
134
|
-
"""Pydantic config class."""
|
140
|
+
model_config = ConfigDict(extra="allow")
|
135
141
|
|
136
|
-
|
142
|
+
def model_dump(self, **kwargs: Any) -> Dict[str, Any]:
|
143
|
+
"""Dump the source as a dictionary.
|
144
|
+
|
145
|
+
Args:
|
146
|
+
**kwargs: Additional keyword arguments.
|
147
|
+
|
148
|
+
Returns:
|
149
|
+
The source as a dictionary.
|
150
|
+
"""
|
151
|
+
return super().model_dump(serialize_as_any=True, **kwargs)
|
152
|
+
|
153
|
+
def model_dump_json(self, **kwargs: Any) -> str:
|
154
|
+
"""Dump the source as a JSON string.
|
155
|
+
|
156
|
+
Args:
|
157
|
+
**kwargs: Additional keyword arguments.
|
158
|
+
|
159
|
+
Returns:
|
160
|
+
The source as a JSON string.
|
161
|
+
"""
|
162
|
+
return super().model_dump_json(serialize_as_any=True, **kwargs)
|
137
163
|
|
138
164
|
|
139
165
|
class DistributionPackageSource(Source):
|
@@ -148,7 +174,8 @@ class DistributionPackageSource(Source):
|
|
148
174
|
version: Optional[str] = None
|
149
175
|
type: SourceType = SourceType.DISTRIBUTION_PACKAGE
|
150
176
|
|
151
|
-
@
|
177
|
+
@field_validator("type")
|
178
|
+
@classmethod
|
152
179
|
def _validate_type(cls, value: SourceType) -> SourceType:
|
153
180
|
"""Validate the source type.
|
154
181
|
|
@@ -182,7 +209,8 @@ class CodeRepositorySource(Source):
|
|
182
209
|
subdirectory: str
|
183
210
|
type: SourceType = SourceType.CODE_REPOSITORY
|
184
211
|
|
185
|
-
@
|
212
|
+
@field_validator("type")
|
213
|
+
@classmethod
|
186
214
|
def _validate_type(cls, value: SourceType) -> SourceType:
|
187
215
|
"""Validate the source type.
|
188
216
|
|
@@ -201,39 +229,21 @@ class CodeRepositorySource(Source):
|
|
201
229
|
return value
|
202
230
|
|
203
231
|
|
204
|
-
def
|
205
|
-
"""
|
206
|
-
|
207
|
-
In older versions, sources (sometimes also called class paths) like
|
208
|
-
`zenml.materializers.BuiltInMaterializer` were stored as strings in our
|
209
|
-
configuration classes. These strings got replaced by a separate class, and
|
210
|
-
this function returns a validator to convert those old strings to the new
|
211
|
-
classes.
|
232
|
+
def convert_source(source: Any) -> Any:
|
233
|
+
"""Converts an old source string to a source object.
|
212
234
|
|
213
235
|
Args:
|
214
|
-
|
236
|
+
source: Source string or object.
|
215
237
|
|
216
238
|
Returns:
|
217
|
-
|
218
|
-
to convert source fields.
|
239
|
+
The converted source.
|
219
240
|
"""
|
241
|
+
if isinstance(source, str):
|
242
|
+
source = Source.from_import_path(source)
|
220
243
|
|
221
|
-
|
222
|
-
def _convert_source(
|
223
|
-
cls: Type[BaseModel], value: Union[Source, str, None]
|
224
|
-
) -> Optional[Source]:
|
225
|
-
"""Converts an old source string to a source object.
|
226
|
-
|
227
|
-
Args:
|
228
|
-
cls: The class on which the attributes are defined.
|
229
|
-
value: Source string or object.
|
244
|
+
return source
|
230
245
|
|
231
|
-
Returns:
|
232
|
-
The converted source.
|
233
|
-
"""
|
234
|
-
if isinstance(value, str):
|
235
|
-
value = Source.from_import_path(value)
|
236
|
-
|
237
|
-
return value
|
238
246
|
|
239
|
-
|
247
|
+
SourceWithValidator = Annotated[
|
248
|
+
SerializeAsAny[Source], BeforeValidator(convert_source)
|
249
|
+
]
|
@@ -24,7 +24,12 @@ from typing import (
|
|
24
24
|
Union,
|
25
25
|
)
|
26
26
|
|
27
|
-
from pydantic import
|
27
|
+
from pydantic import (
|
28
|
+
ConfigDict,
|
29
|
+
SerializeAsAny,
|
30
|
+
field_validator,
|
31
|
+
model_validator,
|
32
|
+
)
|
28
33
|
|
29
34
|
from zenml.artifacts.external_artifact_config import (
|
30
35
|
ExternalArtifactConfiguration,
|
@@ -33,12 +38,13 @@ from zenml.client_lazy_loader import ClientLazyLoader
|
|
33
38
|
from zenml.config.base_settings import BaseSettings, SettingsOrDict
|
34
39
|
from zenml.config.constants import DOCKER_SETTINGS_KEY, RESOURCE_SETTINGS_KEY
|
35
40
|
from zenml.config.retry_config import StepRetryConfig
|
36
|
-
from zenml.config.source import Source,
|
41
|
+
from zenml.config.source import Source, SourceWithValidator
|
37
42
|
from zenml.config.strict_base_model import StrictBaseModel
|
38
43
|
from zenml.logger import get_logger
|
39
44
|
from zenml.model.lazy_load import ModelVersionDataLazyLoader
|
40
45
|
from zenml.model.model import Model
|
41
46
|
from zenml.utils import deprecation_utils
|
47
|
+
from zenml.utils.pydantic_utils import before_validator_handler
|
42
48
|
|
43
49
|
if TYPE_CHECKING:
|
44
50
|
from zenml.config import DockerSettings, ResourceSettings
|
@@ -54,25 +60,30 @@ class PartialArtifactConfiguration(StrictBaseModel):
|
|
54
60
|
# for all steps/outputs
|
55
61
|
default_materializer_source: Optional[Source] = None
|
56
62
|
|
57
|
-
@
|
63
|
+
@model_validator(mode="before")
|
64
|
+
@classmethod
|
65
|
+
@before_validator_handler
|
58
66
|
def _remove_deprecated_attributes(
|
59
|
-
cls,
|
67
|
+
cls, data: Dict[str, Any]
|
60
68
|
) -> Dict[str, Any]:
|
61
69
|
"""Removes deprecated attributes from the values dict.
|
62
70
|
|
63
71
|
Args:
|
64
|
-
|
72
|
+
data: The values dict used to instantiate the model.
|
65
73
|
|
66
74
|
Returns:
|
67
75
|
The values dict without deprecated attributes.
|
68
76
|
"""
|
69
77
|
deprecated_attributes = ["artifact_source"]
|
78
|
+
|
70
79
|
for deprecated_attribute in deprecated_attributes:
|
71
|
-
if deprecated_attribute in
|
72
|
-
|
73
|
-
|
80
|
+
if deprecated_attribute in data:
|
81
|
+
data.pop(deprecated_attribute)
|
82
|
+
|
83
|
+
return data
|
74
84
|
|
75
|
-
@
|
85
|
+
@field_validator("materializer_source", mode="before")
|
86
|
+
@classmethod
|
76
87
|
def _convert_source(
|
77
88
|
cls,
|
78
89
|
value: Union[None, Source, Dict[str, Any], str, Tuple[Source, ...]],
|
@@ -88,7 +99,7 @@ class PartialArtifactConfiguration(StrictBaseModel):
|
|
88
99
|
if isinstance(value, str):
|
89
100
|
value = (Source.from_import_path(value),)
|
90
101
|
elif isinstance(value, dict):
|
91
|
-
value = (Source.
|
102
|
+
value = (Source.model_validate(value),)
|
92
103
|
elif isinstance(value, Source):
|
93
104
|
value = (value,)
|
94
105
|
|
@@ -100,7 +111,8 @@ class ArtifactConfiguration(PartialArtifactConfiguration):
|
|
100
111
|
|
101
112
|
materializer_source: Tuple[Source, ...]
|
102
113
|
|
103
|
-
@
|
114
|
+
@field_validator("materializer_source", mode="before")
|
115
|
+
@classmethod
|
104
116
|
def _convert_source(
|
105
117
|
cls, value: Union[Source, Dict[str, Any], str, Tuple[Source, ...]]
|
106
118
|
) -> Tuple[Source, ...]:
|
@@ -115,7 +127,7 @@ class ArtifactConfiguration(PartialArtifactConfiguration):
|
|
115
127
|
if isinstance(value, str):
|
116
128
|
value = (Source.from_import_path(value),)
|
117
129
|
elif isinstance(value, dict):
|
118
|
-
value = (Source.
|
130
|
+
value = (Source.model_validate(value),)
|
119
131
|
elif isinstance(value, Source):
|
120
132
|
value = (value,)
|
121
133
|
|
@@ -133,18 +145,15 @@ class StepConfigurationUpdate(StrictBaseModel):
|
|
133
145
|
step_operator: Optional[str] = None
|
134
146
|
experiment_tracker: Optional[str] = None
|
135
147
|
parameters: Dict[str, Any] = {}
|
136
|
-
settings: Dict[str, BaseSettings] = {}
|
148
|
+
settings: Dict[str, SerializeAsAny[BaseSettings]] = {}
|
137
149
|
extra: Dict[str, Any] = {}
|
138
|
-
failure_hook_source: Optional[
|
139
|
-
success_hook_source: Optional[
|
150
|
+
failure_hook_source: Optional[SourceWithValidator] = None
|
151
|
+
success_hook_source: Optional[SourceWithValidator] = None
|
140
152
|
model: Optional[Model] = None
|
141
153
|
retry: Optional[StepRetryConfig] = None
|
142
154
|
|
143
155
|
outputs: Mapping[str, PartialArtifactConfiguration] = {}
|
144
156
|
|
145
|
-
_convert_source = convert_source_validator(
|
146
|
-
"failure_hook_source", "success_hook_source"
|
147
|
-
)
|
148
157
|
_deprecation_validator = deprecation_utils.deprecate_pydantic_attributes(
|
149
158
|
"name"
|
150
159
|
)
|
@@ -160,27 +169,37 @@ class PartialStepConfiguration(StepConfigurationUpdate):
|
|
160
169
|
client_lazy_loaders: Mapping[str, ClientLazyLoader] = {}
|
161
170
|
outputs: Mapping[str, PartialArtifactConfiguration] = {}
|
162
171
|
|
172
|
+
# TODO: In Pydantic v2, the `model_` is a protected namespaces for all
|
173
|
+
# fields defined under base models. If not handled, this raises a warning.
|
174
|
+
# It is possible to suppress this warning message with the following
|
175
|
+
# configuration, however the ultimate solution is to rename these fields.
|
176
|
+
# Even though they do not cause any problems right now, if we are not
|
177
|
+
# careful we might overwrite some fields protected by pydantic.
|
178
|
+
model_config = ConfigDict(protected_namespaces=())
|
179
|
+
|
163
180
|
# Override the deprecation validator as we do not want to deprecate the
|
164
181
|
# `name`` attribute on this class.
|
165
182
|
_deprecation_validator = deprecation_utils.deprecate_pydantic_attributes()
|
166
183
|
|
167
|
-
@
|
168
|
-
|
169
|
-
|
170
|
-
) ->
|
184
|
+
@model_validator(mode="before")
|
185
|
+
@classmethod
|
186
|
+
@before_validator_handler
|
187
|
+
def _remove_deprecated_attributes(cls, data: Any) -> Any:
|
171
188
|
"""Removes deprecated attributes from the values dict.
|
172
189
|
|
173
190
|
Args:
|
174
|
-
|
191
|
+
data: The values dict used to instantiate the model.
|
175
192
|
|
176
193
|
Returns:
|
177
194
|
The values dict without deprecated attributes.
|
178
195
|
"""
|
179
196
|
deprecated_attributes = ["docstring", "inputs"]
|
197
|
+
|
180
198
|
for deprecated_attribute in deprecated_attributes:
|
181
|
-
if deprecated_attribute in
|
182
|
-
|
183
|
-
|
199
|
+
if deprecated_attribute in data:
|
200
|
+
data.pop(deprecated_attribute)
|
201
|
+
|
202
|
+
return data
|
184
203
|
|
185
204
|
|
186
205
|
class StepConfiguration(PartialStepConfiguration):
|
@@ -200,7 +219,10 @@ class StepConfiguration(PartialStepConfiguration):
|
|
200
219
|
model_or_dict: SettingsOrDict = self.settings.get(
|
201
220
|
RESOURCE_SETTINGS_KEY, {}
|
202
221
|
)
|
203
|
-
|
222
|
+
|
223
|
+
if isinstance(model_or_dict, BaseSettings):
|
224
|
+
model_or_dict = model_or_dict.model_dump()
|
225
|
+
return ResourceSettings.model_validate(model_or_dict)
|
204
226
|
|
205
227
|
@property
|
206
228
|
def docker_settings(self) -> "DockerSettings":
|
@@ -214,7 +236,9 @@ class StepConfiguration(PartialStepConfiguration):
|
|
214
236
|
model_or_dict: SettingsOrDict = self.settings.get(
|
215
237
|
DOCKER_SETTINGS_KEY, {}
|
216
238
|
)
|
217
|
-
|
239
|
+
if isinstance(model_or_dict, BaseSettings):
|
240
|
+
model_or_dict = model_or_dict.model_dump()
|
241
|
+
return DockerSettings.model_validate(model_or_dict)
|
218
242
|
|
219
243
|
|
220
244
|
class InputSpec(StrictBaseModel):
|
@@ -227,14 +251,12 @@ class InputSpec(StrictBaseModel):
|
|
227
251
|
class StepSpec(StrictBaseModel):
|
228
252
|
"""Specification of a pipeline."""
|
229
253
|
|
230
|
-
source:
|
254
|
+
source: SourceWithValidator
|
231
255
|
upstream_steps: List[str]
|
232
256
|
inputs: Dict[str, InputSpec] = {}
|
233
257
|
# The default value is to ensure compatibility with specs of version <0.2
|
234
258
|
pipeline_parameter_name: str = ""
|
235
259
|
|
236
|
-
_convert_source = convert_source_validator("source")
|
237
|
-
|
238
260
|
def __eq__(self, other: Any) -> bool:
|
239
261
|
"""Returns whether the other object is referring to the same step.
|
240
262
|
|
zenml/config/step_run_info.py
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
"""Step run info."""
|
15
15
|
|
16
|
+
from typing import Any, Callable
|
16
17
|
from uuid import UUID
|
17
18
|
|
18
19
|
from zenml.config.pipeline_configurations import PipelineConfiguration
|
@@ -31,6 +32,8 @@ class StepRunInfo(StrictBaseModel):
|
|
31
32
|
config: StepConfiguration
|
32
33
|
pipeline: PipelineConfiguration
|
33
34
|
|
35
|
+
force_write_logs: Callable[..., Any]
|
36
|
+
|
34
37
|
def get_image(self, key: str) -> str:
|
35
38
|
"""Gets the Docker image for the given key.
|
36
39
|
|
zenml/config/store_config.py
CHANGED
@@ -15,11 +15,12 @@
|
|
15
15
|
|
16
16
|
from typing import Any, Dict, Optional
|
17
17
|
|
18
|
-
from pydantic import BaseModel,
|
18
|
+
from pydantic import BaseModel, ConfigDict, SerializeAsAny, model_validator
|
19
19
|
|
20
20
|
from zenml.config.secrets_store_config import SecretsStoreConfiguration
|
21
21
|
from zenml.enums import StoreType
|
22
22
|
from zenml.logger import get_logger
|
23
|
+
from zenml.utils.pydantic_utils import before_validator_handler
|
23
24
|
|
24
25
|
logger = get_logger(__name__)
|
25
26
|
|
@@ -43,8 +44,10 @@ class StoreConfiguration(BaseModel):
|
|
43
44
|
|
44
45
|
type: StoreType
|
45
46
|
url: str
|
46
|
-
secrets_store: Optional[SecretsStoreConfiguration] = None
|
47
|
-
backup_secrets_store: Optional[
|
47
|
+
secrets_store: Optional[SerializeAsAny[SecretsStoreConfiguration]] = None
|
48
|
+
backup_secrets_store: Optional[
|
49
|
+
SerializeAsAny[SecretsStoreConfiguration]
|
50
|
+
] = None
|
48
51
|
|
49
52
|
@classmethod
|
50
53
|
def supports_url_scheme(cls, url: str) -> bool:
|
@@ -61,38 +64,36 @@ class StoreConfiguration(BaseModel):
|
|
61
64
|
"""
|
62
65
|
return True
|
63
66
|
|
64
|
-
@
|
65
|
-
|
67
|
+
@model_validator(mode="before")
|
68
|
+
@classmethod
|
69
|
+
@before_validator_handler
|
70
|
+
def validate_store_config(cls, data: Dict[str, Any]) -> Dict[str, Any]:
|
66
71
|
"""Validate the secrets store configuration.
|
67
72
|
|
68
73
|
Args:
|
69
|
-
|
74
|
+
data: The values of the store configuration.
|
70
75
|
|
71
76
|
Returns:
|
72
77
|
The values of the store configuration.
|
73
78
|
"""
|
74
|
-
if
|
75
|
-
return
|
79
|
+
if data.get("secrets_store") is None:
|
80
|
+
return data
|
76
81
|
|
77
82
|
# Remove the legacy REST secrets store configuration since it is no
|
78
83
|
# longer supported/needed
|
79
|
-
secrets_store =
|
84
|
+
secrets_store = data["secrets_store"]
|
80
85
|
if isinstance(secrets_store, dict):
|
81
86
|
secrets_store_type = secrets_store.get("type")
|
82
87
|
if secrets_store_type == "rest":
|
83
|
-
del
|
84
|
-
|
85
|
-
return values
|
88
|
+
del data["secrets_store"]
|
86
89
|
|
87
|
-
|
88
|
-
"""Pydantic configuration class."""
|
90
|
+
return data
|
89
91
|
|
92
|
+
model_config = ConfigDict(
|
90
93
|
# Validate attributes when assigning them. We need to set this in order
|
91
94
|
# to have a mix of mutable and immutable attributes
|
92
|
-
validate_assignment
|
95
|
+
validate_assignment=True,
|
93
96
|
# Allow extra attributes to be set in the base class. The concrete
|
94
97
|
# classes are responsible for validating the attributes.
|
95
|
-
extra
|
96
|
-
|
97
|
-
# are mutable and not included in serialization
|
98
|
-
underscore_attrs_are_private = True
|
98
|
+
extra="allow",
|
99
|
+
)
|
@@ -13,14 +13,10 @@
|
|
13
13
|
# permissions and limitations under the License.
|
14
14
|
"""Strict immutable pydantic model."""
|
15
15
|
|
16
|
-
from pydantic import BaseModel,
|
16
|
+
from pydantic import BaseModel, ConfigDict
|
17
17
|
|
18
18
|
|
19
19
|
class StrictBaseModel(BaseModel):
|
20
20
|
"""Immutable pydantic model which prevents extra attributes."""
|
21
21
|
|
22
|
-
|
23
|
-
"""Pydantic config class."""
|
24
|
-
|
25
|
-
allow_mutation = False
|
26
|
-
extra = Extra.forbid
|
22
|
+
model_config = ConfigDict(frozen=True, extra="forbid")
|
zenml/constants.py
CHANGED
@@ -69,6 +69,30 @@ def handle_json_env_var(
|
|
69
69
|
return default
|
70
70
|
|
71
71
|
|
72
|
+
def is_true_string_value(value: Any) -> bool:
|
73
|
+
"""Checks if the given value is a string representation of 'True'.
|
74
|
+
|
75
|
+
Args:
|
76
|
+
value: the value to check.
|
77
|
+
|
78
|
+
Returns:
|
79
|
+
Whether the input value represents a string version of 'True'.
|
80
|
+
"""
|
81
|
+
return value in ["1", "y", "yes", "True", "true"]
|
82
|
+
|
83
|
+
|
84
|
+
def is_false_string_value(value: Any) -> bool:
|
85
|
+
"""Checks if the given value is a string representation of 'False'.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
value: the value to check.
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
Whether the input value represents a string version of 'False'.
|
92
|
+
"""
|
93
|
+
return value in ["0", "n", "no", "False", "false"]
|
94
|
+
|
95
|
+
|
72
96
|
def handle_bool_env_var(var: str, default: bool = False) -> bool:
|
73
97
|
"""Converts normal env var to boolean.
|
74
98
|
|
@@ -80,9 +104,9 @@ def handle_bool_env_var(var: str, default: bool = False) -> bool:
|
|
80
104
|
The converted value.
|
81
105
|
"""
|
82
106
|
value = os.getenv(var)
|
83
|
-
if value
|
107
|
+
if is_true_string_value(value):
|
84
108
|
return True
|
85
|
-
elif value
|
109
|
+
elif is_false_string_value(value):
|
86
110
|
return False
|
87
111
|
return default
|
88
112
|
|