extism / ruby-sdk

Extism Ruby Host SDK - easily run WebAssembly modules / plugins from Ruby applications
https://extism.org
BSD 3-Clause "New" or "Revised" License
12 stars 1 forks source link

count_vowels.wasm fails #22

Closed brandondrew closed 4 months ago

brandondrew commented 4 months ago

The code in irb says it all:

irb(main):007> plugin = Extism::Plugin.new(manifest, config: { vowels: "aeiouyAEIOUY" })
=> #<Extism::Plugin:0x0000000121c32ae0 @plugin=#<FFI::Pointer address=0x00000001052f0d50>>
irb(main):008> plugin.call("count_vowels", "Yellow, World!")
=> "{\"count\":3,\"total\":3,\"vowels\":\"aeiouAEIOU\"}"

The "count" should be 4: Y, e, o, and o, but we can see that the configuration for vowels was not accepted.

bhelx commented 4 months ago

Thank you! Will take a look today

bhelx commented 4 months ago

I suspect something is wrong with the plugin as the CLI is also showing this behavior. Will see if i can figure out why.

[I] ben@dylibso ~> extism call count_vowels.wasm count_vowels --input="Yellow World" --config='{"vowels": "aeiouyAEIOUY"}'
{"count":3,"total":3,"vowels":"aeiouAEIOU"}
bhelx commented 4 months ago

Nevermind, I think I invoked it incorrectly:

extism call https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm count_vowels --input="Yello World" --config vowels=aeiouyAEIOUY
{"count":4,"total":4,"vowels":"aeiouyAEIOUY"}
bhelx commented 4 months ago

Just realized in case someone gets lost, i should have used --set-config

extism call https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm count_vowels
 --input="Yello World" --set-config='{"vowels": "aeiouyAEIOUY"}'
 {"count":4,"total":4,"vowels":"aeiouyAEIOUY"}
 extism call --help | grep config
      --config stringArray                      Set config values, should be in KEY=VALUE format
      --set-config config                       Create config object using JSON, this will be merged with any config arguments
bhelx commented 4 months ago

Sorry I'm just now getting back to this. Pulled out the debugger and seems there was some bad logic involved in the ruby code https://github.com/extism/ruby-sdk/pull/23

Will get this merged and release as 1.0.1

bhelx commented 4 months ago

Deployed as 1.0.1

Please give it a try if you don't mind @brandondrew

brandondrew commented 4 months ago

Deployed as 1.0.1

Please give it a try if you don't mind @brandondrew

Yes, that works now! Thanks!