2

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)
}
cs0815
  • 16,751
  • 45
  • 136
  • 299

1 Answers1

1

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:

deployment_config <- local_webservice_deployment_config(port = 8890)

Once you know the service is working locally, the issue you're having with the ACI webservice becomes a lot easier to narrow down.

Anders Swanson
  • 3,637
  • 1
  • 18
  • 43
  • 1
    Thanks. will try this. I have to say I am pretty disappointed how immature(?)/undocumented R support is - especially as R dropped support for R 3.5+ for sql server machine learning services we use at the moment. – cs0815 May 14 '21 at 16:05
  • Totally empathize! I used to use R exclusively before I got a job at an Azure shop, and saw that R is treated as a second class citizen within Azure ML. Learned Python pretty quick after that! – Anders Swanson May 14 '21 at 16:07
  • 1
    R is generally treated that way, which is a shame. I will have to try to get this to work as i cannot just port everything to Python ... – cs0815 May 14 '21 at 16:12
  • That being said, There's very little use for the API as most of the functionality exists to define configuration. So much so that V2 of Azure ML is going to be YAML-defined configuration. This will make working with Azure ML much easier for both Python and R users, IMHO. Less boilerplate! Given that you're just getting up to speed w/ Azure ML, you might want to start there. If you give me an email, I can get the docs to you -- it's currently in public preview https://github.com/Azure/azureml-previews – Anders Swanson May 14 '21 at 16:13
  • thanks not sure how to provide you with my email on SO? – cs0815 May 14 '21 at 16:18
  • 1
    you can reach me at first.last@avande.com – Anders Swanson May 14 '21 at 16:18
  • ta just send an email. – cs0815 May 14 '21 at 16:25
  • still haven't gotten anything yet. maybe our spam filter is slow. you did the variable substitution right? – Anders Swanson May 14 '21 at 16:33