#@Helder Correia ๐Ÿ‘‹ coincidentally I'm

1 messages ยท Page 1 of 1 (latest)

lapis wraith
#

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?

drifting turtle
#

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)

lapis wraith
#

You can try using hatch. It manages virtual envs for you and python versions as well.

drifting turtle
#

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)

lapis wraith
#

Brew does have 3.11 though.

#
brew install python@3.11
lapis wraith
drifting turtle
#

Doesn't pip install handle that for me?

lapis wraith
drifting turtle
#

OK I manually added it, getting same error

#
$ cat pyproject.toml 
[project]
name = "main"
version = "0.0.0"
dependencies = [
  "ollama"
]
lapis wraith
#

Where's your source? It should be in src/main.py.

drifting turtle
#

yes (I started from the mod init template

lapis wraith
#

Can you show me the full error then?

drifting turtle
#

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

lapis wraith
#

It doesn't work like that ๐Ÿ™‚ The "script" isn't executed directly. It's imported.

drifting turtle
#

Yup that was it. Typo in main.py triggered an error that appears unrelated (will paste)

lapis wraith
#

Python modules are built like packages that are installed, not scripts to execute.

drifting turtle
#

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 ๐Ÿ™‚

lapis wraith
#

The error should be at the end of the stack trace. Looks like you had a bad indent on return ๐Ÿ˜„

drifting turtle
#

facepalm the error is the only thing inside the big boxes (which are guess are for the stackframe)

lapis wraith
#

The actual error is SyntaxError: 'return' outside function. The boxes are from the stack trace, yes.

drifting turtle
#

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!

lapis wraith
#

It's not great today, it's been hard to find a standard. There's fragmentation and paralysis in moving in a unified direction.

drifting turtle
#

(oh I just understood why I was on python 3.9. It only happens when source .venv/bin/activate

lapis wraith
#

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.

drifting turtle
#

Which command creates the .venv?

lapis wraith
#

python -m venv PATH

#

Make sure python -V is what you expect (or which python).

drifting turtle
#

the only commands I typed were copy-pasted from the dagger docs, pretty much

lapis wraith
#

Yes, but the docs assume the python in your PATH is the correct one for you.

drifting turtle
#

ah I probably ran it before upgrading python then

lapis wraith
drifting turtle
#

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?

lapis wraith
#

No need to give instructions to experts. This is all pretty basic to experienced developers. But yes, it only confuses beginners otherwise.