Search code examples
opencpu

Adding Custom Function to OpenCPU Store


I am trying to figure out how to add a custom function to my OpenCPU store.

I understand that we have to create an object in R/tmp. After creating a store in /home/, Then we have to move that object from R/tmp to /home/store/ using:

PUT /home/[store name]/[object name]

It's easy to do with functions/packages already in R/pub, but when I try to do it with my own custom function, I get stuck.

I can create an R/tmp/[hashkey] object with my own custom function at this webpage, in the third form:

http://public.opencpu.org/userapps/opencpu/opencpu.demo/runcode/

Which returns:

{
    "object" : "x0188b9b9ce",
    "graphs" : [],
    "files" : {}
}

So I move this to my store via

PUT /home/[store name]/new.function

with parameter: object = 'x0188b9b9ce'

and then I see:

[
 "/R/user/[user name]/[store name]/new.function"
]

But when I:

POST /R/user/[user name]/[store name]/new.function/save

I get this response:

HTTP 400 Bad Request
Object: new.function not found in /R/user/[user name]/[store name]/

So what am I doing wrong?

And yes, I have replaced [user name] and [store name] with actual strings, I just wanted to keep it as straightforward as possible and clearly connected to the documentation.


Solution

  • This was a server side problem. Posting and using a custom function via the above will work. Thanks to Jeroen for making the needed changes to the host server firewall.