#Dependencies
1 messages · Page 1 of 1 (latest)
I have multiple modules in one repo. so it's local references. I do a dagger install and then try to call the dagger fuction and get this error:
Function execution error: 'Client' object has no attribute 'sample_function'
Here is my dagger.json:
{
"name": "tests",
"sdk": "python",
"dependencies": [
{
"name": "build",
"source": "../build"
}
],
"source": ".",
"engineVersion": "v0.10.0"
}
import dagger
from dagger import dag, function, object_type
@object_type
class Version:
@function
def sample_function(self) -> dagger.Container:
"""Creates"""
return dag.container().from_("alpine:latest").with_exec(["echo", "sample"])
"""A generated module for Tests functions"""
import dagger
from dagger import dag, function, object_type
@object_type
class Tests:
@function
async def build(self, src: dagger.Directory):
res = await dag.sample_function(src)
In the CLI the module name is omitted for convenience, but when using dag, or raw API queries, you have to start with the module's name. What's the name on the build dependency? The directory seems to be called "build", but you only show a "Version" object. If that's the actual name of that Dagger Module:
await dag.version().sample_function()
ahhhhhhhhhhhhhhh
let me try that
re the file path, I make a mistake when copy-pasting, i did the wrong file
but that worked! thanks @digital matrix
One more question, why is the intellisense not working in my IDE? I ran the poetry install for the sdk
What's your IDE?
[tool.poetry]
name = "main"
version = "0.0.0"
description = "Test module"
authors = ["user"]
[tool.poetry.dependencies]
python = "^3.11"
[tool.poetry.group.dev.dependencies]
dagger-io = {path = "sdk", develop = true}
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
vscode
Where's your virtual env?
Poetry puts it in a global place, right? Can you check if VSCode found it?
I'm using devcontainers so I don't have a venv
Just like any Python project, VSCode needs to know the virtual env for the project. devcontainers or not.
here is my poetry venv /home/vscode/.cache/pypoetry/virtualenvs
Don't know how your devcontainer is setup and I don't use it myself. There seems to be lots of resources online though. I'm just picking some off a search. https://www.richtman.au/blog/poetry-package-development-with-vscode-devcontainers/
Challenges and workarounds for development containers
With Dagger, it should be just like any Python/Poetry project.
ok, I can take it from here, I can do some digging
very helpful Helder, appreciate it
Hello, I just came across this thread for structuring python code in dagger-modules.
I have split the module functions across multiple files to better organize it.
However, when i run the command dagger -m moduleA functions I do not see the functions I created in the other files. It only shows the functions from the __init__.py file.
Here are some screenshots:
- module code + directory structure
- command ran
any advice on correctly setting it up would be greatly appreciated.