Global AI and Data Science

 View Only

Custom Python Deployment in IBM Watson studio throws error

  • 1.  Custom Python Deployment in IBM Watson studio throws error

    Posted Thu August 19, 2021 09:46 AM
    Hi!

    I need help to deploy the python function in IBM Watson Studio version 3.0.1

    While testing the function in the notebook it works fine there is no error in importing project_lib, but After deployment, it throws an error mentioning that "no module named project_lib" was found ...

    from project_lib import Project
    project = Project.access()
    

    I used this library for reading data from the database connection which is inside the function that I deployed.
    While deployment I used "default_py3.7_opence"
    as software specification (RUNTIME). and also I tried to deploy it by using RUNTIME as "ai-function_0.1-py3.6".

    Deployment was made successfully but after deployment, while scoring it using payload it throws this error "no module named project_lib" as I used it inside the function.  

    Here are the errors that I got.
     meta_props = {
         client.repository.FunctionMetaNames.NAME: "Test Function",
         client.repository.FunctionMetaNames.RUNTIME_UID: "ai-function_0.1-py3.6"
     }
    
    function_artifact = client.repository.store_function(meta_props=meta_props, 
    function = my_deployable_function)
    function_uid = client.repository.get_function_uid(function_artifact)
    deploy_meta = {
        client.deployments.ConfigurationMetaNames.NAME: "Test Function",
        client.deployments.ConfigurationMetaNames.ONLINE: {}
     }
    
    deployment_details = client.deployments.create(function_uid, meta_props=deploy_meta)
    function_deployment_id = client.deployments.get_uid(deployment_details)
    function_deployment_endpoint_url = client.deployments.get_scoring_href(deployment_details)
    
    payload =  { "input_data": [{ "fields": [ "message" ],
                                    "values": [[ "ok" ]],
                                    "DT" : [100]
                                 }]
                } 
    
    results = client.deployments.score( function_deployment_endpoint_url, payload )
    print(results)​



    Should I install the project_lib library into deployment as it is a customized function? If so how?  

    Even I tried the below code
    !pip install project_lib
    from project_lib import Project​

    But after deployment, it throws the error that get_ipython is not defined.

    Please, anyone, help me to sort it out.
    Thanks in Advance


    ------------------------------
    sundar raj
    ------------------------------

    #GlobalAIandDataScience
    #GlobalDataScience