none
Failed to install R package on Azure ML Service RRS feed

  • Question

  • I'm trying to install a custom R package on ML service and getting an error. 

    This is the relevant documentation, others are outdated:

    https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/machine-learning/algorithm-module-reference/execute-r-script.md

    I have set up the package as a zip file within a zip file, uploaded as a dataset, and connected to the zip input of the execute r script module.

    My "Execute R Script" code looks like this:

    azureml_main <- function(dataframe1, dataframe2) {
      # packages for installation
      if(!require(tsibble)) install.packages('tsibble', repos='http://cran.us.r-project.org')
      if(!require(furrr)) install.packages('furrr', repos='http://cran.us.r-project.org')
      if(!require(dplyr)) install.package('dplyr', repos='http://cran.us.r-project.org')
      print("dirs:")
      print(list.dirs())
      print("files:")
      print(list.files())
      print("files in script bundle:")
      print(list.files("Script Bundle"))  
      install.packages("Script Bundle/hcforecast.zip", lib = ".", repos = NULL, verbose=TRUE)
      library(hcforecast, lib.loc = ".")
      out_dataframe <- head(mtcars)
      # out_dataframe <- head(hcfc_census_daily)
      return(list(dataset1=out_dataframe, dataset2=dataframe2))
    }

    The output that I'm getting looks like this:

    [1] "dirs:"
    [1] "."                   "./Script Bundle"     "./Script Bundle/dud"
    [1] "files:"
    [1] "4a5be61f03b84a18b346a9b6329d269a.R"      
    [2] "825419a7286745a48aca59c9b8e6d5d3.parquet"
    [3] "f1cb5b7d6f3d4c8f913084c2fea1f571.R"      
    [4] "Script Bundle"                           
    [1] "files in script bundle:"
    [1] "dud"            "hcforecast.zip"
    system (cmd0): /azureml-envs/azureml_39b73164d5ea27781515ad6b38bbb7c8/lib/R/bin/R CMD INSTALL
    Error in rawToChar(block[seq_len(ns)]) : 
      embedded nul in string: 'PK\003\004\024\0\0\0\0\0zFWO\0\0\0\0\0\0\0\0\0\0\0\0\v\0\0\0hcforecast/PK\003\004\024\0\0\0\0\0xFWO\0\0\0\0\0\0\0\0\0\0\0\0\020\0\0\0hcforecast/data/PK\003\004\024\0\0\0\b\0xFW'
    Error in library(hcforecast, lib.loc = ".") : 
      there is no package called ‘hcforecast’

    Additionally, will this package install every time I call the predictive service? Or will it already be in the env?

    Thank you!!!

    Wednesday, October 23, 2019 4:10 PM

All replies

  • Hi,

    Can you please share the hcforecast.zip file to check.

    Thanks

    Thursday, October 24, 2019 11:46 AM
    Moderator
  • Hello,

    Looking at the error of your run it looks like the package that is uploaded as a dataset is not properly zipped. While using a custom package that needs to be installed using R script select the package and all its dependencies which are also in a zip format and created a zip file of all the zip files and then upload the same to studio as a dataset.

    For example, I wanted to install MLR package with all its dependencies. I have downloaded all the packages from R repository as zip files and then selected them to create a new zip of zips and uploaded the same to studio.

    If you try to zip a folder of zip files and upload the zip file to studio as dataset it would fail. Please try to create a zip file with this step and re-upload the dataset before trying to run the execute R script. 

    Also, if you deploy a web service after successfully installing the package it need not be installed everytime there is a call to the service.

    -Rohit

    Thursday, October 24, 2019 12:02 PM
    Moderator