sol-eng / plumber-model

Plumber ML Model deployment example
Apache License 2.0
44 stars 27 forks source link

Error in spec$paths$`/predict`$post$requestBody #7

Open RafaelEduardoDiaz opened 3 years ago

RafaelEduardoDiaz commented 3 years ago

I am trying to run the entrypoint.R of the tutorial of the material used in the conference, however I get this error.

library(plumber)

pr <- plumb("plumber.R")

pr$run(port = 5762,
      swagger = function(pr, spec, ...){
        # Define request body for POST to /predict
        spec$paths$`/predict`$post$requestBody <- list(
          description = "New data to predict",
          required = TRUE,
          content = list(
            `application/json` = list(
              # Define JSON schema
              schema = list(
                title = "Car",
                required = c("cyl", "hp"),
                properties = list(
                  cyl = list(type = "integer"),
                  hp = list(type = "integer")
                )
              )
            )
          )
        )
        spec
      })

Running plumber API at http://127.0.0.1:5762
Error in spec$paths$`/predict`$post$requestBody <- list(description = "New data to predict",  : 
  argument "spec" is missing, with no default

I am using the stable cran version of plumber.

> packageVersion('plumber')
[1] ‘1.0.0’

 R.Version()$version.string
[1] "R version 4.0.2 (2020-06-22)"

I appreciate any help.