Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R Support #201

Closed
NoahMarconi opened this issue Mar 1, 2016 · 10 comments
Closed

R Support #201

NoahMarconi opened this issue Mar 1, 2016 · 10 comments

Comments

@NoahMarconi
Copy link

Hi, any barriers to adding R support? What would be involved?

@Marak
Copy link
Collaborator

Marak commented Mar 1, 2016

Shouldn't be very hard.

Someone else was asking about this before, but I can't find the thread.

@Marak
Copy link
Collaborator

Marak commented Mar 3, 2016

@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.

@Marak
Copy link
Collaborator

Marak commented Apr 15, 2016

@NoahMarconi - A $100 bounty has been posted to add this feature.

https://www.bountysource.com/issues/31490232-r-support

:-)

@NoahMarconi
Copy link
Author

@Marak I'll take a look on Sunday. That Python example looks like something I can replicate in R.

@Marak
Copy link
Collaborator

Marak commented Apr 15, 2016

@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.

@NoahMarconi
Copy link
Author

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.

@Marak
Copy link
Collaborator

Marak commented Apr 18, 2016

@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

@Marak
Copy link
Collaborator

Marak commented Apr 18, 2016

@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

@NoahMarconi
Copy link
Author

@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

@Marak
Copy link
Collaborator

Marak commented Sep 30, 2016

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

@Marak Marak closed this as completed Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants