yamlscript 2024-04-29

Is there any example code of using external libraries in yamlscript?

I have an example of using a babashka Pod from YS. I'll see if I can find it.

Here's an example of using a bb Pod in ys:

$ cat pod-test.ys 
!yamlscript/v0

use-pod: \'org::babashka/go-sqlite3 "0.2.3"

require pod::babashka::go-sqlite3: => sqlite

say:
  sqlite/query:
    .":memory:"
    ["SELECT 41 + 1 AS sum"]
The pod is autoinstalled on first run:
$ ys pod-test.ys 
Downloading pod org.babashka/go-sqlite3 (0.2.3)
Successfully installed pod org.babashka/go-sqlite3 (0.2.3)
[{:sum 42}]
And then subsequently:
$ time ys pod-test.ys 
[{:sum 42}]

real    0m0.040s
user    0m0.014s
sys     0m0.028s

I want to spend more time on making it even easier to use external libraries and pods. @danielmartincraig if you (or anyone) has specific needs, let me know. It's always good to have a "customer" driving implementation.... 🙂

I have a pod that I'm developing, called graph-rag-pod In bb I can load it like so: (babashka.pods/load-pod "build/graph-rag-pod.js") Is there an equivalent in ys?

🙌 1

use-pod: "build/graph-rag-pod.js"
I'm trying this but getting Error: Wrong number of args (1) passed to: ys.std/use-pod

(defn use-pod [pod-name version]
  (ys/load-pod pod-name version))

Is there a way to call babaska’s load-pod? Or does use-pod support pods from my local file system?

I haven't looked at pods since april tbh

is this public code?

give me a minute

try pods/load-pod('build/graph-rag-pod.js')

OK I'll try that, thanks!

let me know if it works or not

I'm doing this, but I see an error:

#!/usr/bin/env ys-0

pods/load-pod('../.esbuild/.build/src/graph-rag-pod.js')

require pod::swacorp::graph-rag-pod: => grp

say: "hello"
this is the error:
Error: mapping values are not allowed here
 in reader, line 5, column 36:
    require pod::swacorp::graph-rag-pod: => grp
                                       ^
{:eval [], :debug-stage {}}

when you can share the code I can look into it

thanks. I'm still learning to navigate the process for releasing open source stuff here so it may not be soon that I'm able to share

you can also try to make a repro of the problem with some other pod

I don't have a repro to share, but I can report that the following seems to work:

graph-rag-pod =: pods/load-pod('../.esbuild/.build/src/graph-rag-pod.js')
require pod::swacorp::graph-rag-pod: => grp
say: "hello"

That's good. I'll try to revisit pod usage this weekend

trying to get 0.1.77 out which has a ton of cool new stuff

🎉 1

Thanks for the response on my GH issue

👍 1