Decision Optimization

 View Only
Expand all | Collapse all

Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

  • 1.  Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Tue October 05, 2021 06:06 PM

    While creating a job in the IBM Cloud for the optimization model, I am getting the error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array." I am not passing the input data, as it's passed through API to the model. Could I know how to resolve this, Thank you



    ------------------------------
    Anilkumar Lingaraj Biradar
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Wed October 06, 2021 03:26 AM
    I suspect that this comes from your model not having any input table.  Each input table in the Scenario will become a 'reference to input data' in the deployed job.  If you don't have any input table, then the list of data reference inputs is indeed empty.  And the reason it's not allowed to create such a job is that it wouldn't have any way to change its input, always leading to the exact same result, which would be pretty useless.

    You mention that the input data is "passed through API to the model". But I'm not sure how this can happen on a model that's deployed from a Scenario.  To the best of my knowledge, such models only use input tables, and have no means of passing data via the REST request to run the job.  You may want to provide more details on this, in case I missed something.

    ------------------------------
    Xavier
    ------------------------------



  • 3.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Wed October 06, 2021 08:47 PM

    Thank you for the reply.

    In our scenario, Ideally, From UI when the user clicks the submit button, the model pipeline is invoked with an ID based on selection, which then makes the API call to pull the data. This pulled data will be used as input data to run the model in the pipeline.

    Thus, I need to deploy the model to the cloud and make a call to this deployed model programmatically by passing different IDs to get the different input data to the model.  Initially, to try this I am running a model with default ID and making a call to the database to get the input data and run the optimization model and get the output. Later running the model programmatically. But I am not able to create the job as mentioned above. Could you please suggest how to proceed with this?

    Also If you could provide any useful links related to this scenario for creating and running jobs through IBM Cli or through python programming would help.



    ------------------------------
    Anilkumar Lingaraj Biradar
    ------------------------------



  • 4.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Mon October 11, 2021 02:16 AM
    Edited by System Test Fri January 20, 2023 04:42 PM
    Thanks for the details.

    I understand that you have a small amount of data (an ID) that you would like to give as parameter to your job.  And that ID will change with each run of the job. As I mentioned, you will have to make this information available to the job via an input table.  There are three ways to provide data to a Decision Optimization job in WML: references to remote data, data assets, and inline data. The simplest for you seems to be to send the information as inline data. Basically, you send an inline payload in the job creation request. You can find an example using Python in the section 'Inline tabular data' at https://medium.com/@AlainChabrier/inline-data-in-do-for-wml-jobs-e5e966e0a16c.

    The example looks like this:
    "input_data": [
      {
        "id": "inline_data.csv",
        "fields" : ["name", "value"],      
        "values" : [
            ["id", "the-id-value"]
        ] 
      }
    ]​


    The example above assumes that you have tabular data, organised as key-value pairs, which seems fine for an id.  But when a table is not appropriate, you should know that you can basically send any file you want using base-64 encoding.  Here's an example:

    'decision_optimization': {
       'input_data': [{
          'id': 'one-var.lp',
          'content': 'bWluaW1pemUgeApzdAogICB4ID49IDIKZW5k'
       }]
    }


    With such a payload, a file named 'one-var.lp' will be created and the decoded content be put in. Here it is:

    $ echo "bWluaW1pemUgeApzdAogICB4ID49IDIKZW5k" | base64 -d
    minimize x
    st
    x >= 2
    end
    



    It is then up to your Python scripts to read the content of that file and act on it. At https://github.com/nodet/dowml/blob/11f44f01e37db84f09d5be87f983617504b906fe/src/dowml/dowmllib.py#L910, you will find some Python code that does this.


    The links below are not really specific to this use case, but they may still be useful to you, hopefully.

    With respect to using Python to submit WML jobs, I can suggest the following:
    - An example of code to submit existing Decision Optimization models using Python: dowml. Note that this code doesn't have inline tabular data, though.
    - The documentation for the WML Python API used in dowml: https://ibm-wml-api-pyclient.mybluemix.net/
    - The documentation for DO in WML: https://dataplatform.cloud.ibm.com/docs/content/DO/wml_cpd_home.html?context=cpdaas

    If you would rather use a command line, please refer to cpdctl:
    - Here's the documentation.
    - An example of what it looks like to use cpdctl to send DO models.

    I hope this helps.

    ------------------------------
    Xavier
    ------------------------------



  • 5.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Tue October 12, 2021 02:51 AM

    Thank you for the reply. I was able to create the job through Jupyter notebook, but I am facing issues while executing the job. The job is failing with the error "'message': "ModuleNotFoundError: No module named 'requests'"}]}," We are using "import requests" in the model but the deployed model is not able to use this module.

    The meta_props are as shown below in the screenshot. I have the following 3 questions:

    1. I tried with different SOFTWARE_SPEC_UID namely do_12.9, do_12.10 and do_20.1. Could I please know whether I need to change the SOFTWARE_SPEC_UID or any of the meta_props?
    2. Also, could I know how to install the packages in the deployed space? I tried adding .tar.gz file of the "requests" package to the asset, but that didn't work.
    3. Whether we can change the environment in the deployment space from the manage deployment section? If yes, could you please explain that?

    From the previous reply I got this link and followed this for the meta_props : https://dataplatform.cloud.ibm.com/exchange/public/entry/view/50fa9246181026cd7ae2a5bc7e4ac7bd?context=cpdaas

    Please let me know if i need to provide any information. Appreciate the help.



    ------------------------------
    Anilkumar Lingaraj Biradar
    ------------------------------



  • 6.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Tue October 12, 2021 04:05 AM
    Edited by System Test Fri January 20, 2023 04:25 PM
    While it is possible in Notebooks to use "!pip install ..." to install packages, the procedure is different when you want to deploy your Python code.  A deployed model runs in an 'environment' that is specified using 'hardware configuration' and 'software configuration'.  When you want your Python code to import a package that is not included in the default software configuration, you need to create a custom software configuration.  The detailed steps to follow are described in section "To create a custom software specification" in https://www.ibm.com/support/producthub/icpdata/docs/content/SSQNUZ_latest/wsj/wmls/wmls-deploy-python-types.html.

    The idea is that you start from a pre-defined software configuration, specify a YAML file that includes the packages that you want added, and create a new software specification from this.   This is all done using the WML Python API.

    An example of YAML file, for your case, would be the following:
    channels:
    - empty
    - nodefaults
    dependencies:
    - pip:
    - requests

    Section "Adding the right dependencies" at https://medium.com/ibm-data-ai/deploy-and-scale-pre-trained-nlp-models-in-minutes-with-watson-machine-learning-and-huggingface-bf55147997ad also describes this process. You probably want to start from the "do_20.1" software configuration, though.

    ------------------------------
    Xavier
    ------------------------------



  • 7.  RE: Error as "Invalid request entity: input_data_references in the decision_optimization field can not be an empty array."

    Posted Wed October 13, 2021 02:10 AM

    Thank you, Xavier, following your replies I was able to create a custom software specification ('do_20.1 with packages v1') using the link: https://www.ibm.com/support/producthub/icpdata/docs/content/SSQNUZ_latest/wsj/wmls/wmls-deploy-python-types.html

     Then I assigned this custom software specification in the meta_props for the WML client repository as shown below. I was able to create a job and run it. Appreciate the help.



    ------------------------------
    Anilkumar Lingaraj Biradar
    ------------------------------