#@Helder Correia Any chance you could
1 messages · Page 1 of 1 (latest)
For some reason it's working fine in another module:
.
└── dagger
├── poetry.lock
├── pyproject.toml
├── sdk
│ └── src
│ └── dagger
│ ├── client
│ ├── _codegen
│ ├── _engine
│ └── mod
└── src
└── main.py
The difference is that the second module was created/init on 0.10, the first was updated to 0.10 manually...
Since you have multiple files, they should be in a package instead of directly in src. See https://docs.dagger.io/developer-guide/python/820256/module-structure#multiple-files
I should probably default dagger init to src/main/__init__.py instead of src/main.py.
That'd be ideal I think, I'd imagine multiple files to be quite common
Still getting that same error after moving the files into a package and renaming the module to main
Do I also need to include the package main, even when the name of the module is main...
That hasn't worked either, hah
A package called main must be installed, but you can have a different project name in pyproject.toml as long as you correctly include the main package with, e.g., include. See https://docs.dagger.io/developer-guide/python/820256/module-structure#project-name
This isn't correct:
packages = [{ include = "main" }]
Because you're missing src.
Your import from constants isn't right either, since it should be in the main package rather than top level constants.
@charred peak try this:
diff --git a/lambda/dagger/pyproject.toml b/lambda/dagger/pyproject.toml
index ea88973..25158f1 100644
--- a/lambda/dagger/pyproject.toml
+++ b/lambda/dagger/pyproject.toml
@@ -3,7 +3,7 @@ name = "main"
version = "0.1.1"
description = "Lambda Dagger module"
authors = ["Mjb141"]
-packages = [{ include = "main" }]
+packages = [{ include = "main", from = "src" }]
[tool.poetry.dependencies]
python = "^3.11"
diff --git a/lambda/dagger/src/main/main.py b/lambda/dagger/src/main/main.py
index 2cbc905..d2b1bba 100644
--- a/lambda/dagger/src/main/main.py
+++ b/lambda/dagger/src/main/main.py
@@ -2,7 +2,7 @@ import dagger
from dagger import dag, function, object_type, Doc
from typing import Annotated
-from constants import *
+from .constants import *
@object_type
That's done it, thanks.
The error is confusing because it there's an error during import, the error message is "did you create a src/main.py file?"
Indeed
The underlying error should surface more easily.
I've added it to the backlog and will fix it soon 🙂
Worth asking what other Python users think about this as well?