Hi all
I've tried to do something like this (https://docs.dagger.io/api/constructor/#simple-constructor) i.e. having a class constructor where I'll initialize a custom class and it didn't work.
So far I've understood, my own class Environment is not serializable but, yes, I've well create a to_dict() or__dict__() method as suggested by IA tools.
My Main class looks like this (simplified):
from .core.environment import Environment
@object_type
class Src:
env: Environment
@classmethod
async def create(cls):
# [...]
env: Environment = cls.__load_environment()
# [...]
return cls(env=env)
My Environment class is there to store all my attributes. Nothing special there.
Looks like this:
class Environment:
def __init__(self, project_type="", base_image="", verbose=False):
self.base_image: str = project_type
self.project_type: str = base_image
self.verbose: bool = verbose
def to_dict(self):
return {
"project_type": self.project_type,
"base_image": self.base_image,
"verbose": self.verbose,
}
I've the feeling something has to be done in the Dagger CI Python SDK to allow the constructor to serialize/deserialize my class but not sure.