Using Your Local R Environment to Deploy Blockspring Functions

Test Run Your New Function Locally

Your sample function reads parameters from request$params. request$params is automatically populated with any inputs you pass to your function. See it in action as JSON via STDIN (recommended):

$ echo '{"first_name":"Paul","age":26}' | blockspring run Rscript block.R
{"_blockspring_spec":true,"_errors":[],"intro":"Hi! My name is Paul and my age is 26"}

You can also use command line arguments:

$ blockspring run Rscript block.R --first_name=Jason --age=13
{"_blockspring_spec":true,"_errors":[],"intro":"Hi! My name is Jason and my age is 13"}

The results should look familiar. You passed in two parameters, first name and age, and got back the same string you saw when running the function on its homepage.

When running locally, you'll also see two additional keys in the result. _blockspring_spec is a flag that tells Blockspring whether your function is providing outputs according to Blockspring's specification. _errors contains any errors that you might have outputted with your function. Learn more about the Blockspring specifications and errors with the API reference manual.

Note: Include blockspring run to authenticate you on each execution. If you are not remotely calling other Blockspring functions within your function, then blockspring run is unnecessary and you can just call Rscript block.R.