Skip to content

Commit

Permalink
Merge pull request #71 from fdroessler/feat/pydantic-v2
Browse files Browse the repository at this point in the history
Add support for pydantic v2
  • Loading branch information
marrrcin authored Aug 25, 2023
2 parents 38c7736 + c1936b8 commit 6cab079
Show file tree
Hide file tree
Showing 4 changed files with 726 additions and 774 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

- Added support for pydantic v2 and bumped minimal required pydantic version to `2.0.0`

## [0.5.0] - 2023-08-11

- [🚀 New dataset] Added support for `AzureMLAssetDataSet` based on Azure ML SDK v2 (fsspec) by [@tomasvanpottelbergh](https://github.com/tomasvanpottelbergh) & [@froessler](https://github.com/fdroessler)
Expand Down
18 changes: 11 additions & 7 deletions kedro_azureml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from typing import Dict, Optional, Type

import yaml
from pydantic import BaseModel, validator
from pydantic import BaseModel, Field, field_validator
from typing_extensions import Annotated

from kedro_azureml.utils import update_dict

Expand Down Expand Up @@ -39,7 +40,8 @@ def _create_default_dict_with(
default_value = (value := value or {}).get("__default__", default)
return dict_cls(lambda: default_value, value)

@validator("compute", always=True)
@field_validator("compute")
@classmethod
def _validate_compute(cls, value):
return AzureMLConfig._create_default_dict_with(
value, ComputeConfig(cluster_name="{cluster_name}")
Expand All @@ -49,11 +51,13 @@ def _validate_compute(cls, value):
resource_group: str
workspace_name: str
experiment_name: str
compute: Optional[Dict[str, ComputeConfig]]
temporary_storage: Optional[AzureTempStorageConfig]
environment_name: Optional[str]
code_directory: Optional[str]
working_directory: Optional[str]
compute: Annotated[
Optional[Dict[str, ComputeConfig]], Field(validate_default=True)
] = None
temporary_storage: Optional[AzureTempStorageConfig] = None
environment_name: Optional[str] = None
code_directory: Optional[str] = None
working_directory: Optional[str] = None
pipeline_data_passing: Optional[PipelineDataPassingConfig] = None


Expand Down
Loading

0 comments on commit 6cab079

Please sign in to comment.