I am developing a natural language processing function with visual studio code and Microsoft Azure. The function triggers on an http request, and works perfectly on my local host during testing. However, as soon as I publish the function to Azure, the function becomes unresponsive, citing a "500 internal error." I believe the problem might have something to do with a specific dependency not being installed upon publishing.
My "requirements.txt" file looks like this
azure-functions
nltk
numpy
pyodbc
pandas
sklearn
spacy
And lastly, in order to run the function on my local machine, I download the "en_core_web_sm" package. I am able to quickly do this by running "python -m spacy download en_core_web_sm" in my virtual environment. If I do not use the nlp = spacy.load('en_core_web_sm') line in my code, the function will publish successfully.
My worry is that this dependency is not included in the function once published. I have tried to solve this problem by adding the github download string - https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.0/en_core_web_sm-2.3.0.tar.gz - in my requirements.txt folder, as I am able to download this using pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.3.0.tar.gz. After the addition, the requirements.txt folder looks like this:
azure-functions
nltk
numpy
pyodbc
pandas
sklearn
spacy
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.3.0.tar.gz
I have also attempted to configure the necessary command in my "tasks.json" folder, changing it to include the command as such:
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-watch",
"isBackground": true,
"dependsOn": "pipInstall"
},
{
"label": "pipInstall",
"type": "shell",
"osx": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m spacy download en_core_web_sm && python -m pip install -r requirements.txt"
},
"windows": {
"command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m spacy download en_core_web_sm && python -m pip install -r requirements.txt"
},
"linux": {
"command": "${config:azureFunctions.pythonVenv}/bin/python -m spacy download en_core_web_sm && python -m pip install -r requirements.txt"
},
"problemMatcher": []
}
]
}
I would appreciate any help as this is a time sensitive issue. Thank you so much!