How to access azure blob storage in score.py for scoring of deployed model
Hi,
I have found ways to access (mount,download) datastore (blob store) while training on AML and in pipelines. but i have nowhere seen any example to access the blob store datastore as mount in scoring script of deployed model. Could someone guide me to this ?
Thanks, Amardeep
Not sure, but this article might help: https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-access-data
Thanks @j-martens , But this articles tells about accessing datastores while training and training pipelines. but not about accessing them in scoring script while predicting using deployed web service
what exactly do you want to do with data from a datastore in your scoring script?
I want to access my data , which is stored on the blob storage as mounting the storage on compute for inferencing/scoring the model ?
This is a web service that runs a script in a loop every time it receives data. We don't fetch data from the datastore every time a request comes in since that would negatively impact model performance. To load it during init, you can use the extra dockerfile parameter to copy the data into the web service image as it’s being built so you don’t have to mess around with fetching data over the network at run time.
@jpe316 - Can you provide any additional guidance here?
CC: @Blackmist @j-martens
I cant copy all the data in the docker image while building as the data on which this scoring scripts will work and do inferencing, will be the user input who is using the deployed model. For example, User wants to input the name of the image which is stored on some blob storage and want to generate inferencing on this image and return the results. Or please let me know what should be the preferred way ?
@nibaccam @rongduan-zhu
@amardeepjaiman Sorry for the time it's taken to get back to you on this, and thanks for the interesting scenario.
The functionality that you are looking for is not something covered by the Azure Machine Learning service or SDK. This will require custom code, probably using the Azure Storage Python SDK.
Assuming that the images are updated outside of the model (users can upload images at any time and then ask the model to do inference on them), the pattern to solve this would look something like this:
- user passes the name of the image.
- in the score.py, the run function would parse the incoming request data (JSON) and extract the field containing the name.
- custom code would use the name to construct the path to the image in the blob, and use the Azure Storage SDK to read in the image data.
- The image data would then be sent to the model for inference. Depending on what the model expects (size, data format) you might need custom code to do transformations.
Since loading the image and applying transforms would take time, and given enough time the web request might time out, I would recommend putting whatever transforms are needed to get the image in the format that the model expects into the portion of this solution that uploads the image.
That's really about all I can recommend on this, as we are the documentation team and don't provide custom code solutions. If you need to go further on this and get working code, I would recommend Microsoft Consulting Services.
I'll also recommend that the engineering team consider doing a sample based on this scenario, though I cannot provide any guarantees that one will be created.
Closed per Blackmist
@amardeepjaiman Thanks again for bringing this up. Since this isn't currently provided by the SDK, can you post it as a feature suggestion/request at https://feedback.azure.com/forums/257792-machine-learning ? The engineering team uses the suggestions posted here to improve the product.
Thanks @Blackmist