#Dependencies

1 messages · Page 1 of 1 (latest)

digital matrix
#

Yes, all the time. How are you trying to do it?

drifting kayak
#

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"])
drifting kayak
#
"""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)
digital matrix
drifting kayak
#

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

digital matrix
#

What's your IDE?

drifting kayak
#
[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

digital matrix
#

Where's your virtual env?

#

Poetry puts it in a global place, right? Can you check if VSCode found it?

drifting kayak
#

I'm using devcontainers so I don't have a venv

digital matrix
#

Just like any Python project, VSCode needs to know the virtual env for the project. devcontainers or not.

drifting kayak
#

here is my poetry venv /home/vscode/.cache/pypoetry/virtualenvs

digital matrix
#

With Dagger, it should be just like any Python/Poetry project.

drifting kayak
#

ok, I can take it from here, I can do some digging

#

very helpful Helder, appreciate it

plucky gyro
#

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.