#Read files in ~/ from function

1 messages · Page 1 of 1 (latest)

quartz spindle
#

Hey,

I am currently using a file argument --ollama-key-pub ~/.ollama/id_ed25519.pub to read a file.

How can I get a File object directly from my dagger function, without requiring the user to pass the path?

Code: https://github.com/adrienbrault/hf-gguf-to-ollama/blob/89d96914902effb220728581c3ed949dcb849ffd/dagger/src/index.ts#L90-L94

TS SDK

GitHub

Contribute to adrienbrault/hf-gguf-to-ollama development by creating an account on GitHub.

grim mountain
#

Hi @quartz spindle! TL;DR: users always have to specify what the functions require. This is because module function get executed in a sandboxed environment, they do not get executed directly on the host. If you are running your functions locally, you will see that there is a dagger engine container running (docker ps to check!). That is where the magic happens. There are quite a few reasons of why Dagger went in this direction. If you want a quick overview of the architecture check out our docs: https://docs.dagger.io/manuals/developer/overview/482011/architecture

  1. You execute a Dagger CLI command like dagger call against a Dagger Module. The CLI either connects to an existing engine or provisions one on-the-fly. Once connected, it opens a new session with the Dagger Engine.
quartz spindle
#

Got it. So if a function requires a lot of arguments and I want to make the usage simpler, I pretty much have to "wrap" my dagger function in a bash script?

#

Like, I can't even provide a default path?

grim mountain
grim mountain
quartz spindle
#

I would want ~/.ollama/id_ed25519.pub to be the default value for --ollama-key-pub

grim mountain
#

I see. Default values for more complex types is a bit trickier, by the time the runtime knows what it wants to execute it is already in the sandboxed environment. At the moment we don't support using a string as a default file for a file. There is a bit more info here in regards to default values for complex types: https://docs.dagger.io/manuals/developer/typescript/520201/constructor#default-values-for-complex-types

Sometimes it's convenient to have a special function for constructing the main module object. This can, for example, be a simple way to accept module-wide configuration.

quartz spindle
#

ok, what about dagger config ? Could I set argument values just once with it?

#

eg

dagger config --ollama-pub-key ...
dagger call ... # omit --ollama-pub-key
lyric moon