clipper icon indicating copy to clipboard operation
clipper copied to clipboard

RClipper Error in POST: Error in if (encoding.mode == \"NULL\") {: argument is of length zero\n\"}

Open csmithnm opened this issue 6 years ago • 0 comments

I am on the process of trying to get my own example of RClipper to work using an R data frame, but I just can't seem to get it to work. The error that I get when I submit the "curl" via the REST API has been giving me the following error: {"query_id":9,"output":"{\"error\": Error in if (encoding.mode == \"NULL\") {: argument is of length zero\n\"}","default":false}

I have tried numerous formats for the "curl" REST API call, but I usually either get the above error or this one: {"error":"Json error","cause":"Error parsing JSON: JSON parse error: Invalid value. (offset 11)\n. Expected JSON schema: \n {\n \"input\" := [double] | [int] | [string] | [byte] | [float],\n }\n"}

I believe the issue is with how I am formatting the POST "input" for a data frame with multiple string columns. Should I be using a list()? Or some other data structure to represent multiple string fields like: mpg and carmodel? Or is the "sample_input" format incorrect?

R Data Frame Trying to Implement: mtcars <- data.frame( mpg="21", carmodel="Mazda RX4" )

R Function Code: library(Rclipper) pred_mtcars_fn = function(mtcars) { str(mtcars) return(as.character(mtcars)) } Rclipper::build_model("r-mtcars", 91, pred_mtcars_fn, sample_input = data.frame(mpg="21", carmodel="Mazda RX4"))

Deploy Model: clipper_conn.deploy_model("r-mtcars", "91", "strings", "r-mtcars:91", num_replicas=1)

POST Query of Model: curl -X POST --header \"Content-Type:application/json\" -d '{"input": "[[{\"mpg\":\"21\",\"carmodel\":\"Mazda RX4\"}]]"}' 127.0.0.1:1337/app_mtcars/predict

Error Message from POST: {"query_id":9,"output":"{\"error\": Error in if (encoding.mode == \"NULL\") {: argument is of length zero\n\"}","default":false}

csmithnm avatar May 10 '18 22:05 csmithnm