Skip to content

Commit

Permalink
fix: update deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
sujuka99 committed Oct 24, 2023
1 parent 78001a2 commit f80d6e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions kpops/components/base_components/helm_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def helm_chart(self) -> str:
@property
def helm_flags(self) -> HelmFlags:
"""Return shared flags for Helm commands."""
auth_flags = self.repo_config.repo_auth_flags.dict() if self.repo_config else {}
auth_flags = self.repo_config.repo_auth_flags.model_dump() if self.repo_config else {}
return HelmFlags(
**auth_flags,
version=self.version,
Expand All @@ -90,7 +90,7 @@ def helm_flags(self) -> HelmFlags:
def template_flags(self) -> HelmTemplateFlags:
"""Return flags for Helm template command."""
return HelmTemplateFlags(
**self.helm_flags.dict(),
**self.helm_flags.model_dump(),
api_version=self.config.helm_config.api_version,
)

Expand All @@ -108,7 +108,7 @@ def template(self) -> None:
@property
def deploy_flags(self) -> HelmUpgradeInstallFlags:
"""Return flags for Helm upgrade install command."""
return HelmUpgradeInstallFlags(**self.helm_flags.dict())
return HelmUpgradeInstallFlags(**self.helm_flags.model_dump())

@override
def deploy(self, dry_run: bool) -> None:
Expand Down Expand Up @@ -139,7 +139,7 @@ def to_helm_values(self) -> dict:
:returns: Thte values to be used by Helm
"""
return self.app.dict(by_alias=True, exclude_none=True, exclude_defaults=True)
return self.app.model_dump(by_alias=True, exclude_none=True, exclude_defaults=True)

def print_helm_diff(self, stdout: str) -> None:
"""Print the diff of the last and current release of this component.
Expand All @@ -156,11 +156,12 @@ def print_helm_diff(self, stdout: str) -> None:
new_release = Helm.load_manifest(stdout)
self.helm_diff.log_helm_diff(log, current_release, new_release)

# TODO(Ivan Yordanov): replace with a function decorated with `@model_serializer`
@override
def dict(self, *, exclude=None, **kwargs) -> dict[str, Any]:
# HACK: workaround for Pydantic to exclude cached properties during model export
if exclude is None:
exclude = set()
exclude.add("helm")
exclude.add("helm_diff")
return super().dict(exclude=exclude, **kwargs)
return super().model_dump(exclude=exclude, **kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest.mock import MagicMock

import pytest
from pydantic import AnyHttpUrl, BaseModel, parse_obj_as
from pydantic import AnyHttpUrl, BaseModel, TypeAdapter
from pytest_mock import MockerFixture
from schema_registry.client.schema import AvroSchema
from schema_registry.client.utils import SchemaVersion
Expand Down Expand Up @@ -74,7 +74,7 @@ def kpops_config_with_sr_enabled() -> KpopsConfig:
environment="development",
kafka_brokers="broker:9092",
schema_registry=SchemaRegistryConfig(
enabled=True, url=parse_obj_as(AnyHttpUrl, "http://mock:8081")
enabled=True, url=TypeAdapter(AnyHttpUrl).validate_python("http://mock:8081")
),
)

Expand All @@ -87,7 +87,7 @@ def test_load_schema_handler(kpops_config_with_sr_enabled: KpopsConfig):
SchemaHandler,
)

config_disable = kpops_config_with_sr_enabled.copy()
config_disable = kpops_config_with_sr_enabled.model_copy()
config_disable.schema_registry = SchemaRegistryConfig(enabled=False)

assert (
Expand Down

0 comments on commit f80d6e8

Please sign in to comment.