Hi, I want to use this module :
! 'Client' object has no attribute 'K3S'
but with python SDK. My linter does not recongnize it and dagger through thhis error too :
! 'Client' object has no attribute 'k3s'
1 messages · Page 1 of 1 (latest)
Hi, I want to use this module :
! 'Client' object has no attribute 'K3S'
but with python SDK. My linter does not recongnize it and dagger through thhis error too :
! 'Client' object has no attribute 'k3s'
from typing import Annotated, Optional
import dagger
from dagger import Doc, dag, function, object_type
@object_type
class HelloDagger:
@function
def deploy_nginx(self) -> str:
"""Deploy k3s server and install nginx helm chart."""
return dag.k3s("name").container()
dagger/client/gen.py add K3S type but still... I cannot run this command.
This is working :
dagger -m github.com/tonirvega/daggerverse-1/k3s@baf50b6d7d4889ebd4be0e5f3db9e10d428da676 call --name test server up
That's super stange particularly because the gen.py has that method
Please confirm under the Client type the name of the method that got generated. It's probable that it's k3_s due to how naming conversions work. Note that that's different from the K3S type, which is what this method under Client returns.
This would be surprising as the Daggerverse shows type generated is k3s: https://daggerverse.dev/mod/github.com/marcosnils/daggerverse/k3s@e0bd6b9f5519c49db4b6eb0689927214720976f9#K3S.server
Not surprising to me, as Python's codegen is written in Python and daggerverse is written in Go, right? Basically not using the same library for converting names, leading to drift. We need to check if the functions used in conversions in daggerverse match the target languages' codegen naming conversion rules.
I would actually expect it to be "k_3_s", but this is why it isn't: https://github.com/graphql-python/graphql-core/issues/140
This is the regex being used: https://github.com/graphql-python/graphql-core/blob/46244446c66ca3033f5295f6c796108e4c1f7365/src/graphql/pyutils/convert_case.py#L9
_re_camel_to_snake = re.compile(r"([a-z]|[A-Z0-9]+)(?=[A-Z])")
Hi, thanks for looking at this.
dagger functions returns gives deploy-k-3-s with def deploy_k3s
The generated client is :
class Client(root)
...
def k3_s(self, name: str, *, image: str | None = "rancher/k3s:latest",) -> K3S:
_args = [
Arg("name", name),
Arg("image", image, "rancher/k3s:latest"),
]
_ctx = self._select("k3S", _args)
return K3S(_ctx)
so I try :
deploy_k3s(name: str) -> dagger.Container:
return (
dag.k3_s(name)
.container()
)
-> and get :
✘ .deployK3S(name: "test"): Container! 4.4s
! Method dagger.client.gen.Client.k3_s() parameter name="HelloDagger()" was expected to be of type <class 'str'>.