#@Helder Correia ๐ coincidentally I'm
1 messages ยท Page 1 of 1 (latest)
You seem to have Python 3.9 locally. You need at least 3.10, but the runtime container for modules uses 3.11.
What's the dependency you're trying to install?
I'm trying to upgrade but this is the latest brew will give me apparently
I would have preferred to not have python installed at all, note to self: make a dagger module for developing dagger modules in a container ๐
I'm trying to install ollama
(they just released a lib today)
You can try using hatch. It manages virtual envs for you and python versions as well.
This is my module:
import dagger
from dagger import dag, function
import ollama
@function
def llama2(prompt: str) -> str:
response = ollama.chat(model='llama2', messages=[
{
'role': 'user',
'content': prompt,
},
])
return response['message']['content']
dagger functions fails with an import error (I think)
You need to add the dependency to pyproject.toml
Doesn't pip install handle that for me?
pip install is like go get. You want it in go.mod. Like this: https://github.com/dagger/dagger/blob/e1a3764f9fcd676374a504e37eb7334e31e2c639/sdk/python/pyproject.toml#L29
[project]
name = "main"
version = "0.0.0"
dependencies = [
"ollama",
]
OK I manually added it, getting same error
$ cat pyproject.toml
[project]
name = "main"
version = "0.0.0"
dependencies = [
"ollama"
]
Where's your source? It should be in src/main.py.
yes (I started from the mod init template
Can you show me the full error then?
Ah, I tried just running python3 ./src/main.py and there was a typo. But dagger functions didn't complain about the typo at all as far as I can tell
It doesn't work like that ๐ The "script" isn't executed directly. It's imported.
Yup that was it. Typo in main.py triggered an error that appears unrelated (will paste)
Python modules are built like packages that are installed, not scripts to execute.
My point is that the actual error is not visible in what dagger functions outputs
In any case: yay, I got my first python dagger module to build ๐
The error should be at the end of the stack trace. Looks like you had a bad indent on return ๐
the error is the only thing inside the big boxes (which are guess are for the stackframe)
The actual error is SyntaxError: 'return' outside function. The boxes are from the stack trace, yes.
I guess there's always an adaptation period to the DX of different languages... I haven't used python tooling in a while. Not super impressed by the ergonomics overall. I remember being super used to it 10 years ago
OK I'm moving on to the next problem, seems ollama-related this time ๐
thank you for your help!
It's not great today, it's been hard to find a standard. There's fragmentation and paralysis in moving in a unified direction.
(oh I just understood why I was on python 3.9. It only happens when source .venv/bin/activate
That means you created that .venv with an older version then.
Most likely the one that comes with your OS.
Instead of the one from homebrew.
Which command creates the .venv?
the only commands I typed were copy-pasted from the dagger docs, pretty much
Yes, but the docs assume the python in your PATH is the correct one for you.
ah I probably ran it before upgrading python then
This is all usually managed by a tool like hatch or poetry. It's unfortunate that by not choosing a tool, beginners are left with a more complicated setup thinking that it's harder than it is (I wrote about this in https://linear.app/dagger/issue/DOCS-41/simplify-installation-instructions-for-the-python-sdk).
Ah I see, you want to change the docs to assume noob python devs and pick a tool for them - then maybe give alternative instructions to experts who already have their favorite tool?
No need to give instructions to experts. This is all pretty basic to experienced developers. But yes, it only confuses beginners otherwise.