none
Pre-load R packages RRS feed

  • Question

  • I am trying Microsoft Machine Learning Server (Developer Edition) to publish R code, I wounder is there a way to pre load some packages by default to save package loading time.

    I found this option in OpenCPU where I can define the packages to be pre-loaded in the OpenCPU configuration file.

    is there a similar feature in MS Machine Learning Server

    Many Thanks.

    Thursday, July 26, 2018 2:46 PM

All replies

  • Hi,

    Here is how you can do it. This refer to the latest 9.3 version of Machine learning server:

    1. Add an initcode when you publish a service. The init code is supported by our Py API and in our REST APIs:

    https://microsoft.github.io/deployr-api-docs/#publishwebservicerequest

    https://docs.microsoft.com/en-us/machine-learning-server/python-reference/azureml-model-management-sdk/service-definition#code_str

    The initCode will load the needed packages.

    2. You can use the dedicated pool together with the initCode so that the packages will be loaded when we create the shell in the pool and not on service consumption:

    https://docs.microsoft.com/en-us/machine-learning-server/operationalize/how-to-create-manage-session-pools

    https://docs.microsoft.com/en-us/machine-learning-server/operationalize/python/how-to-create-manage-session-pools

    Thursday, July 26, 2018 7:38 PM
  • Thanks @Efart

    is the initCode supported for R code as well?

    Thanks again.

    Sunday, July 29, 2018 12:58 PM
  • Hi Efrat,

    I have the same question but with Python. I deployed a web service which uses the nlp package spacy. In my deployed function I have the following 2 lines

    import spacy

    nlp=spacy.load('en')

    I would like to have these 2 lines preloaded and not have to load them every time my api gets called. I followed the steps described in the link below to create a session pool

    https://docs.microsoft.com/en-us/machine-learning-server/operationalize/python/how-to-create-manage-session-pools

    However I get the following error

    AttributeError: 'DeployClientComposedMLServer' object has no attribute 'create_or_update_service_pool'

    Can you help with this? Thanks!

    Tuesday, January 15, 2019 3:31 AM
  • Hi MagohA,

    I was unable to reproduce the error using the steps on the page you mentioned, it worked fine for me.

    Can you share your code?

    Wednesday, January 16, 2019 12:52 AM
    Owner