I want to use Azure ML Web Service for a non machine learning task with Python. The goal is the following:
I have a Pandas DF like this:
Id Value
0 111 0.1
1 222 7.3
2 333 3.1
3 444 5.0
I can query this DF successfully (what is the value of a certain row by Id?):
float(df.loc[pot['Id'] == 222, 'Value'])
Now, I want to deploy a function in Azure ML Web Service with this functionality where a function uses an uploaded data set as fix lookup table. I constructed the function which gets an Id number as argument, looks for the value in the pre-uploade dataset and gives it back as a float:
from azureml import services
import pandas as pd
@services.publish(workspace_id, workspace_token)
@services.types(id=int)
@services.returns(float)
def my_func(id):
my_df = ws.datasets["uploaded_df.csv"].to_dataframe()
return float(my_df.loc[cent['Id'] == id, 'Value'])
I can deploy it on Azure Web Services but when I try to run a test query It gets stuck (no way even to peep into the details). What is the problem here?
Let me first describe exactly what's happening here to help you better understand why it's failing.
What does the @services annotation do?
What does the Workspace object do?
It connects to the Studio API that was provided and can extract datasets as you use in "ws.datasets".
So why doesn't it work?
It doesn't work because EPS is now running in a multitenant service without network access, and your function is now being blocked by the sandbox (even if you were to reinitialize the workspace object inside your function - I don't know what actually happens when an http client is closed over and rehydrated later)
What can I do?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.