noahgift / flask-ml-azure-serverless Goto Github PK
View Code? Open in Web Editor NEWDeploy Flask Machine Learning Application on Azure App Services
Deploy Flask Machine Learning Application on Azure App Services
Problems encountered while doing lab via Coursera:
Flask version 1.0.2 raises Jinja2 error.
ImportError: cannot import name 'Markup' from 'jinja2' (/home/coder/project/VENV/lib/python3.8/site-packages/jinja2/__init__.py)
Updating to version 2.2.2 resolves the issue.
Numpy installed by default is 1.24.1, which raises:
AttributeError: module 'numpy' has no attribute 'float'
on joblib.load(file_name) call.
Preinstalling numpy==1.23 resolves the issue.
prediction = list(clf.predict(scaled_payload))
on line 71 raises
raw_predictions = self.loss_.get_init_raw_predictions(
AttributeError: 'LeastSquaresError' object has no attribute 'get_init_raw_predictions'
Which can be resolved by downgrading scikit-learn to 0.20.3, but python3.8 + updated pip does not support installing it.
So, there is an open question about resolving it: use the latest versions and update the code (imports and logic would be different) or use previous Python versions.
I'm all new to python, currently attending a course on machine learning.
I've followed your instructions "by-the-letter", but when I run python app.py
I get the following error message:
$ python app.py
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask, request, jsonify
File "/home/testuser/.flask-ml-azure/lib/python3.8/site-packages/flask/__init__.py", line 19, in <module>
from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (/home/testuser/.flask-ml-azure/lib/python3.8/site-packages/jinja2/__init__.py)
Environment:
$ pip freeze
astroid==2.4.2
click==8.1.3
Flask==1.0.2
isort==5.10.1
itsdangerous==2.1.2
Jinja2==3.1.2
joblib==1.2.0
lazy-object-proxy==1.4.3
MarkupSafe==2.1.1
mccabe==0.6.1
numpy==1.23.5
pandas==1.1.5
pkg_resources==0.0.0
pylint==2.6.2
python-dateutil==2.8.2
pytz==2022.6
scikit-learn==0.22.2
scipy==1.9.3
six==1.16.0
toml==0.10.2
Werkzeug==2.2.2
wrapt==1.14.1
Can you please help me getting your sample app up-and-running?
Thanks ;)
The book & README.md asks us to run ./make_prediction.sh but I can't find it in the repo.
There is a file called make_predict.sh but running it locally (after app.py is running in another tab) results in a long html script being printed in the terminal which includes error messages such as " <title>AttributeError: 'LeastSquaresError' object has no attribute 'get_init_raw_predictions' // Werkzeug Debugger</title> ".
Just wondering if there's a missing file that got lost along the way? Thanks!
Probably it is intentionally left but pylint should be updated with W0702 otherwise build will failed during CI/CD.
pylint --disable=R,C,W1203,W0702 app.py
I had some issues getting started with this repo, a hint on which python version to use would have been helpful.
FYI: when I first got started with this repo, I was using Python v3.8, which resulted in installation errors. After downgrading to Python v3.6.15, make install
and python app.py
run smoothly.
However, when executing ./make_predict.sh
, I get the the following error message:
Traceback (most recent call last):
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/home/testuser/.py36/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/testuser/xpand/flask-ml-azure-serverless/app.py", line 68, in predict
prediction = list(clf.predict(scaled_payload))
File "/home/testuser/.py36/lib/python3.6/site-packages/sklearn/ensemble/_gb.py", line 2569, in predict
return self._raw_predict(X).ravel()
File "/home/testuser/.py36/lib/python3.6/site-packages/sklearn/ensemble/_gb.py", line 1655, in _raw_predict
raw_predictions = self._raw_predict_init(X)
File "/home/testuser/.py36/lib/python3.6/site-packages/sklearn/ensemble/_gb.py", line 1649, in _raw_predict_init
raw_predictions = self.loss_.get_init_raw_predictions(
AttributeError: 'LeastSquaresError' object has no attribute 'get_init_raw_predictions'
I assume, this is due to some version conflict between the serialized prediction model from boston_housing_prediction.joblib
and the version of scikit-learn
.
I'm using an umodified version of requirements.txt
.
Output of $ pip freeze
:
astroid==2.4.2
click==8.0.4
dataclasses==0.8
Flask==1.0.2
importlib-metadata==4.8.3
isort==5.10.1
itsdangerous==2.0.1
Jinja2==3.0.3
joblib==1.1.1
lazy-object-proxy==1.4.3
MarkupSafe==2.0.1
mccabe==0.6.1
numpy==1.19.5
pandas==1.1.5
pylint==2.6.2
python-dateutil==2.8.2
pytz==2022.6
scikit-learn==0.22.2
scipy==1.5.4
six==1.16.0
toml==0.10.2
typed-ast==1.4.3
typing_extensions==4.1.1
Werkzeug==2.0.3
wrapt==1.14.1
zipp==3.6.0
Can you please help me resolving this issue as I'm unable to continue my training without this...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.