0

I am having troubles in bring in the symbol := from data.table into mlflow library.

Basically I am building a docker container to serve machine learning models.

  • the docker is based off rocker/r-ver:4.1.3
  • the ml model is created by R crate function, this model predict function is written in R and uses data.table, including operator :=
  • the docker is running to serve API request and use ml model to predict a response. during the ml model predict function, i had error: Invalid Request. could not find function ":="

I have read the references, tried all of them but none worked.

Basically I am using remotes to install mlflow locally, instead of devtools.

  • I clone the mlflow repo to local mlflow-debug
  • add data.table (>= 1.9.6), in the depends section of the DESCRIPTION file
  • turn on building dependencies by set dependencies and build to TRUE in remotes::install_local, see below dockerfile
FROM rocker/r-ver:4.1.3
blah blash

RUN pip install mlflow==1.24 protobuf==3.20.0
RUN Rscript -e 'install.packages(c("glmnet", "carrier", "data.table", "R.filesets"))'

COPY mlflow-debug mlflow-debug
RUN Rscript -e 'install.packages("remotes")'
RUN Rscript -e 'remotes::install_local(\
    path="mlflow-debug/mlflow/R/mlflow",\
    dependencies = TRUE,\
    build = TRUE,\
    upgrade="never"\
    )'


At this point, I suspect that the issue is not bringing in the := symbol into mlflow library.

Any ideas or help will be welcome, thanks a lot!

references:

FrankZhu
  • 514
  • 4
  • 10
  • Where are you actually running the problematic code? It looks like you've installed the package in your container, but did you actually load the packages with `library()` in your R session? – MrFlick Aug 30 '22 at 15:06
  • This is a bit tricky. but the short answer is yes. I have a R file to train the model. this R file has library(data.table) upfront. And it is using crate function to serialize a R predict function into a model file. At the serving/prediction time, when API request received, the crated model is called from mlflow lib and do the prediction. this is where the ':=' error happens. – FrankZhu Aug 30 '22 at 15:44
  • 1
    Well, without any details about how exactly you are running that file or what is even in that file, it's going to be difficult to guess what exactly is going on. It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Aug 30 '22 at 15:48
  • And did you define import in NAMESPACE file? – jangorecki Aug 30 '22 at 22:33
  • 1
    Also this may be if your interest https://cran.r-project.org/web/packages/data.table/vignettes/datatable-importing.html – jangorecki Aug 30 '22 at 22:36
  • @MrFlick I don't think i can provide an easy example since the docker image is quite complex, including rocker, miniconda and mflow. The image will be >4GB. – FrankZhu Aug 31 '22 at 03:36
  • @jangorecki I didn't. I thought I just need add it to depends. The NAMESPACE is autogenerated by roxygen, this is according to reference #2. – FrankZhu Aug 31 '22 at 03:38
  • 1
    You have to ensure that NAMESPACE file is correct. No matter if you write it by hand or if you use tools to generate it. – jangorecki Aug 31 '22 at 07:13
  • @jangorecki i actually append a line importFrom(data.table,":=") in NAMESPACE file. but the error still says 'could not find function ":="' . Is there any way to check the symbols in the library and see if := is there? The library I am trying to build is here https://github.com/mlflow/mlflow/tree/master/mlflow/R/mlflow – FrankZhu Aug 31 '22 at 20:44
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/247721/discussion-between-frankzhu-and-jangorecki). – FrankZhu Aug 31 '22 at 22:04

0 Answers0