I am trying to follow this post to deploy a "model" in Azure.
A code snipet is as follows and the model, which is simply a function adding 2 numbers, seems to register fine. I don't even use the model to isolate the problem after 1000s of attempts as this scoring code shows:
library(jsonlite)
init <- function()
{
message("hello world")
function(data)
{
vars <- as.data.frame(fromJSON(data))
prediction <- 2
toJSON(prediction)
}
}
Should be fine shouldn't it? Any way I run this code snippet:
r_env <- r_environment(name = "basic_env")
inference_config <- inference_config(
entry_script = "score.R",
source_directory = ".",
environment = r_env)
aci_config <- aci_webservice_deployment_config(cpu_cores = 1, memory_gb = 0.5)
aci_service <- deploy_model(ws,
'xxxxx',
list(model),
inference_config,
aci_config)
wait_for_deployment(aci_service, show_output = TRUE)
Which produces this (after a looooong time):
Running.....................................................................
Failed
Service deployment polling reached non-successful terminal state, current service state: Failed
Operation ID: 14c35064-7ff4-46aa-9bfa-ab8a63218a2c
More information can be found using '.get_logs()'
Error:
{
"code": "AciDeploymentFailed",
"statusCode": 400,
"message": "Aci Deployment failed with exception: Error in entry script, RuntimeError: Error in file(filename, \"r\", encoding = encoding) : , please run print(service.get_logs()) to get details.",
"details": [
{
"code": "CrashLoopBackOff",
"message": "Error in entry script, RuntimeError: Error in file(filename, \"r\", encoding = encoding) : , please run print(service.get_logs()) to get details."
}
]
}
It does not tell me much. Not sure how to debug this further? How can I run this:
print(service.get_logs())
and where please? Guess this is a Python artifact? Any other input very much welcome.
PS:
At this point in time, I have my suspicion that the above R entry file definition is not what is expected these days. Looking at the Python equivalent taken from here:
import json
def init():
print("This is init")
def run(data):
test = json.loads(data)
print(f"received data {test}")
return f"test is {test}"
Would something like this not be more suitable (tried it without success).
library(jsonlite)
init <- function()
{
message("hello world")
}
init <- function()
{
return(42)
}
Great to see people putting the R SDK through it's paces!
The vignette you're using is obviously a great way to get started. It seems you're almost all the way through without a hitch.
Deployment is always tricky, and I'm not expert myself. I'd point you to this guide on troubleshooting deployment locally. Similar functionality exists for the R SDK, namely:
local_webservice_deployment_config()
.So I think you change your example to this:
Once you know the service is working locally, the issue you're having with the ACI webservice becomes a lot easier to narrow down.