Closed NoahMarconi closed 8 years ago
Shouldn't be very hard.
Someone else was asking about this before, but I can't find the thread.
@NoahMarconi -
The best way to get a new language added would be to first commit a new target binary which will be mapped to HTTP req / res.
We have a separate binary for each language. Here is one used for python:
https://github.com/bigcompany/hook.io/blob/master/bin/run-hook-python
You'll see that certain command line arguments are passed into the binary, such as -c
, which contains the code. All that needs to be done is to execute that code and send the result to stdout
.
Once we have a new run-r
binary, I should be able to integrate the language into the system with only a few lines of code and then configure R itself on the worker instance.
@NoahMarconi - A $100 bounty has been posted to add this feature.
https://www.bountysource.com/issues/31490232-r-support
:-)
@Marak I'll take a look on Sunday. That Python example looks like something I can replicate in R.
@NoahMarconi - Amazing! I appreciate the effort. I know $100 isn't very much for the work, but I hope it provides at least a small amount of incentive.
If you get stuck on anything while trying to dev this, I'd suggest working around it. Get as much done as you can and I can collaborate with you. You could probably build a proof of concept without actually installing and configuring an entire hook.io
.
You may be able to build a simple test using STDIN and STDOUT? https://github.com/bigcompany/run-service/blob/master/examples/console.js
I'd suggest creating a fork of hook.io
, and just checking in as much R related integration code as you can. Even if its not working at all, I can push all the non-R stuff forward to make it work.
Is this all that's needed to match the Python support?
https://gist.github.com/NoahMarconi/bf29ebc5f5a10017f5a3f4c6f3145bc5
Once those install steps are complete to install an R runtime and the relavant deps, you can run a command line test with something like:
run-r -c "cat(rnorm(n=10, mean=0), '\n')"
If that works I can submit a pull request.
As an immediate follow up, what are the other arguments for (-s, -e)? I can look into adding support there and then follow up with some example R hooks.
@NoahMarconi - I think that looks mostly good! It should actually be pretty easy to add new language support.
You'll still want to generate a hook
variable in same way that the R
service can access.
Some runtimes use global scope, others wrap in a function scope.
You should figure out what is best practice for R
( dictionary versus hash versus object etc ) to store the hook.params
and hook.env
variables. Most of the runtimes use objects / hashes / dicts, others ( like bash
) generate command line arguments.
Best to look around a bit. You can test locally by simply passing in a json object, or individual generated command line arguments.
see:
https://hook.io/marak/examples-bash-hello-world/source https://github.com/bigcompany/hook.io/blob/master/lib/resources/hook/generateCommandLineArguments/bash/index.js https://github.com/bigcompany/hook.io/blob/master/bin/run-hook-python#L15 https://github.com/bigcompany/hook.io/blob/master/lib/resources/hook/generateCommandLineArguments/python/index.js
@NoahMarconi - Quick google search tells me we probably will want to use the following library to parse incoming arguments JSON in R
:
https://cran.r-project.org/web/packages/jsonlite/vignettes/json-aaquickstart.html
@Marak awesome, I'll add that in and submit a pull request. I might need a couple days but it looks like a quick addition
Closing issue.
This is no longer applicable, as all core spawning logic has been moved to: https://github.com/stackvana/stack
If anyone is interested in adding R support, please file a new issue at: https://github.com/stackvana/stack/issues/new
Any changes to stack
will propagate down-stream to hook.io
Hi, any barriers to adding R support? What would be involved?