You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openwhisk.apache.org by Kei Sawada <k...@swd.cc> on 2018/06/06 09:39:34 UTC

About Ruby2.5 runtime support proposal(in relation to #3725)

Hi,

This email is follow-up from #3725 which proposes Ruby2.5 runtime addition.
https://github.com/apache/incubator-openwhisk/pull/3725

> (perhaps including a small example on how to try it)
Here is a quick introduction on how to use and test this runtime. Excuse me
in advance for a little bit awkward installation step, I guess there would
be better way to do this with fewer steps.

```
# 1. Setting up both openwhisk and openwhisk-runtime-ruby
git clone https://github.com/remore/incubator-openwhisk.git
cd incubator-openwhisk
git checkout origin/add-ruby-as-a-kind
cd tools/vagrant
./hello  # fail here because pulling image from openwhisk/action-ruby-v2.5
is not possible yet
vagrant ssh
git clone https://github.com/remore/openwhisk-runtime-ruby.git
cd openwhisk-runtime-ruby/core/ruby2.5Action/
docker build -t action-ruby-v2.5 -t whisk/action-ruby-v2.5
openwhisk/action-ruby-v2.5 .
exit  # go back to the host machine
vagrant provision  # resume installation

# 2. Creating a ruby action
vagrant ssh
cd openwhisk-runtime-ruby
echo -e "def main(param)\n  {result: param}\nend" > my_action.rb
wsk action update myAction my_action.rb --docker whisk/action-ruby-v2.5
./gradlew core:ruby2.5Action:distDocker

# 3. Try it out
wsk action invoke myAction --result -p message hello

# 4. Test it
cd ../openwhisk && ./gradlew install && cd ../openwhisk-runtime-ruby
./gradlew :tests:test --tests *actionContainers.Ruby25ActionContainerTests*
```

Best,
Kei

Re: About Ruby2.5 runtime support proposal(in relation to #3725)

Posted by Kei Sawada <k...@swd.cc>.
> > If you had time to write up generic instructions for creating a new
> > runtime, based on your experiences, it would help others add more. It has
> > been something we've been meaning to do since the PHP runtime.
> >
> > Also, if you get time, adding a simple OpenWhisk Ruby client library to
> the
> > default runtime would be really useful from a "developer" experience POV.
> > Just making it easy for developers to invoke functions & triggers from
> the
> > runtime would be 80% of the methods needed.
>

Yes if this PR goes well, I'm willing to do/consider both. Thanks for your
insight.


> diff --git a/ansible/files/runtimes.json b/ansible/files/runtimes.json
> index 44cb30f2..96a65001 100644
> --- a/ansible/files/runtimes.json
> +++ b/ansible/files/runtimes.json
> @@ -109,6 +109,17 @@
>                      "name": "action-php-v7.1"
>                  }
>              }
> +        ],
> +        "ruby": [
> +            {
> +                "kind": "ruby:2.5",
> +                "default": true,
> +                "deprecated": false,
> +                "image": {
> +                    "prefix": "remore",
> +                    "name": "openwhisk-runtime-ruby"
> +                }
> +            }
>          ]
>

Thank you for the better instruction. Definitely this looks nicer.

Best,
Kei

Re: About Ruby2.5 runtime support proposal(in relation to #3725)

Posted by Rodric Rabbah <ro...@gmail.com>.
Kei, thanks for the runtime contribution.

Also thanks for pushing the image to docker hub... this makes it easier to
try the runtime quickly [1].


> cat main.rb
def main(args)
  name = args["name"] || "stranger"
  greeting = "Hello #{name}!"
  print greeting
  { "greeting" => greeting }
end

> wsk -i action update ruby main.rb --kind ruby:2.5
ok: updated action ruby

> wsk -i action invoke ruby -r -p name ruby
{
    "greeting": "Hello ruby!"
}

To do this, all I did was modify ansible/files/runtime.json as follows and
redeployed the controller and invoker.

> diff --git a/ansible/files/runtimes.json b/ansible/files/runtimes.json
index 44cb30f2..96a65001 100644
--- a/ansible/files/runtimes.json
+++ b/ansible/files/runtimes.json
@@ -109,6 +109,17 @@
                     "name": "action-php-v7.1"
                 }
             }
+        ],
+        "ruby": [
+            {
+                "kind": "ruby:2.5",
+                "default": true,
+                "deprecated": false,
+                "image": {
+                    "prefix": "remore",
+                    "name": "openwhisk-runtime-ruby"
+                }
+            }
         ]


On Wed, Jun 6, 2018 at 6:26 AM, James Thomas <jt...@gmail.com> wrote:

> This looks excellent - I've seen lots of people asking about Ruby support
> before!
>
> If you had time to write up generic instructions for creating a new
> runtime, based on your experiences, it would help others add more. It has
> been something we've been meaning to do since the PHP runtime.
>
> Also, if you get time, adding a simple OpenWhisk Ruby client library to the
> default runtime would be really useful from a "developer" experience POV.
> Just making it easy for developers to invoke functions & triggers from the
> runtime would be 80% of the methods needed.
>
> Thanks for the contribution - looking forward to promoting this!
>
>
> On 6 June 2018 at 10:39, Kei Sawada <k...@swd.cc> wrote:
>
> > Hi,
> >
> > This email is follow-up from #3725 which proposes Ruby2.5 runtime
> addition.
> > https://github.com/apache/incubator-openwhisk/pull/3725
> >
> > > (perhaps including a small example on how to try it)
> > Here is a quick introduction on how to use and test this runtime. Excuse
> me
> > in advance for a little bit awkward installation step, I guess there
> would
> > be better way to do this with fewer steps.
> >
> > ```
> > # 1. Setting up both openwhisk and openwhisk-runtime-ruby
> > git clone https://github.com/remore/incubator-openwhisk.git
> > cd incubator-openwhisk
> > git checkout origin/add-ruby-as-a-kind
> > cd tools/vagrant
> > ./hello  # fail here because pulling image from
> openwhisk/action-ruby-v2.5
> > is not possible yet
> > vagrant ssh
> > git clone https://github.com/remore/openwhisk-runtime-ruby.git
> > cd openwhisk-runtime-ruby/core/ruby2.5Action/
> > docker build -t action-ruby-v2.5 -t whisk/action-ruby-v2.5
> > openwhisk/action-ruby-v2.5 .
> > exit  # go back to the host machine
> > vagrant provision  # resume installation
> >
> > # 2. Creating a ruby action
> > vagrant ssh
> > cd openwhisk-runtime-ruby
> > echo -e "def main(param)\n  {result: param}\nend" > my_action.rb
> > wsk action update myAction my_action.rb --docker whisk/action-ruby-v2.5
> > ./gradlew core:ruby2.5Action:distDocker
> >
> > # 3. Try it out
> > wsk action invoke myAction --result -p message hello
> >
> > # 4. Test it
> > cd ../openwhisk && ./gradlew install && cd ../openwhisk-runtime-ruby
> > ./gradlew :tests:test --tests *actionContainers.
> > Ruby25ActionContainerTests*
> > ```
> >
> > Best,
> > Kei
> >
>
>
>
> --
> Regards,
> James Thomas
>

Re: About Ruby2.5 runtime support proposal(in relation to #3725)

Posted by James Thomas <jt...@gmail.com>.
This looks excellent - I've seen lots of people asking about Ruby support
before!

If you had time to write up generic instructions for creating a new
runtime, based on your experiences, it would help others add more. It has
been something we've been meaning to do since the PHP runtime.

Also, if you get time, adding a simple OpenWhisk Ruby client library to the
default runtime would be really useful from a "developer" experience POV.
Just making it easy for developers to invoke functions & triggers from the
runtime would be 80% of the methods needed.

Thanks for the contribution - looking forward to promoting this!


On 6 June 2018 at 10:39, Kei Sawada <k...@swd.cc> wrote:

> Hi,
>
> This email is follow-up from #3725 which proposes Ruby2.5 runtime addition.
> https://github.com/apache/incubator-openwhisk/pull/3725
>
> > (perhaps including a small example on how to try it)
> Here is a quick introduction on how to use and test this runtime. Excuse me
> in advance for a little bit awkward installation step, I guess there would
> be better way to do this with fewer steps.
>
> ```
> # 1. Setting up both openwhisk and openwhisk-runtime-ruby
> git clone https://github.com/remore/incubator-openwhisk.git
> cd incubator-openwhisk
> git checkout origin/add-ruby-as-a-kind
> cd tools/vagrant
> ./hello  # fail here because pulling image from openwhisk/action-ruby-v2.5
> is not possible yet
> vagrant ssh
> git clone https://github.com/remore/openwhisk-runtime-ruby.git
> cd openwhisk-runtime-ruby/core/ruby2.5Action/
> docker build -t action-ruby-v2.5 -t whisk/action-ruby-v2.5
> openwhisk/action-ruby-v2.5 .
> exit  # go back to the host machine
> vagrant provision  # resume installation
>
> # 2. Creating a ruby action
> vagrant ssh
> cd openwhisk-runtime-ruby
> echo -e "def main(param)\n  {result: param}\nend" > my_action.rb
> wsk action update myAction my_action.rb --docker whisk/action-ruby-v2.5
> ./gradlew core:ruby2.5Action:distDocker
>
> # 3. Try it out
> wsk action invoke myAction --result -p message hello
>
> # 4. Test it
> cd ../openwhisk && ./gradlew install && cd ../openwhisk-runtime-ruby
> ./gradlew :tests:test --tests *actionContainers.
> Ruby25ActionContainerTests*
> ```
>
> Best,
> Kei
>



-- 
Regards,
James Thomas