sparse-intern-71089
01/27/2022, 9:20 AMgreat-queen-39697
01/27/2022, 3:48 PMgreat-queen-39697
01/27/2022, 3:49 PMgreat-sunset-355
01/31/2022, 10:16 AMfrom typing import Sequence, TypeVar, Union
from pydantic import BaseModel
import pulumi
T = TypeVar("T")
PulumiSequenceInputLike = Union[Sequence[T], pulumi.Output[T]]
PulumiInputLike = Union[T, pulumi.Output[T]]
class AutoScalingArgs(BaseModel):
"""Fargate autoscaling arguments."""
memory_target_value: PulumiInputLike[int] = 60
"""Scale up when memory usage exceeds the value [%]."""
cpu_target_value: PulumiInputLike[int] = 60
"""Scale up when CPU usage exceeds the value [%]."""
max_tasks: PulumiInputLike[int] = 4
min_tasks: PulumiInputLike[int] = 1
desired_count: PulumiInputLike[int] = 1
class Config:
arbitrary_types_allowed = True
glamorous-forest-5773
02/22/2022, 11:41 AMpulumi.input_type
decorator is messing up the pydantic attributesglamorous-forest-5773
02/22/2022, 11:41 AMgreat-sunset-355
02/22/2022, 11:45 AMInput
type, you need to use Output
as a typeglamorous-forest-5773
02/22/2022, 11:46 AMglamorous-forest-5773
02/22/2022, 11:46 AM@pulumi.runtime.test
def test_person_with_default():
from pydantic import BaseModel
from typing import TypeVar, Union, Optional
T = TypeVar("T")
Input = Union[T, pulumi.Output[T]]
class PulumiBaseModel(BaseModel):
class Config:
arbitrary_types_allowed = True
@pulumi.input_type
class Person(PulumiBaseModel):
name: Optional[Input[str]] = "John Doe"
a = Person()
def check(a):
assert a.name == "John Doe"
return pulumi.Output.from_input(a).apply(check)
glamorous-forest-5773
02/22/2022, 11:47 AMglamorous-forest-5773
02/22/2022, 11:48 AMtest_person_with_default Failed: [undefined]TypeError: __create_fn__.<locals>.__init__() missing 1 required keyword-only argument: 'name'
glamorous-forest-5773
02/22/2022, 11:48 AMgreat-sunset-355
02/22/2022, 2:21 PMglamorous-forest-5773
02/23/2022, 7:14 AM