1 | from flask_restful import Resource, reqparse |
||
0 ignored issues
–
show
|
|||
2 | from flask import url_for |
||
3 | import cf_predict |
||
4 | |||
5 | |||
6 | class Catalogue(Resource): |
||
7 | def get(self): |
||
8 | """Show a catalogue of available endpoints.""" |
||
9 | return { |
||
10 | "predict_url": url_for("api.predict", |
||
11 | _external=True), |
||
12 | "model_version_url": url_for("api.model", |
||
13 | _external=True), |
||
14 | "api_version": cf_predict.__version__ |
||
15 | } |
||
16 | |||
17 | |||
18 | class Model(Resource): |
||
0 ignored issues
–
show
|
|||
19 | def get(self): |
||
20 | """Get current model version.""" |
||
21 | return {"Version": "1.0"} |
||
22 | |||
23 | def put(self): |
||
24 | """Load a specific model version into memory from Redis. |
||
25 | |||
26 | Either specifiy the model version or 'latest'. |
||
27 | """ |
||
28 | parser = reqparse.RequestParser() |
||
29 | parser.add_argument("version", type=str, required=True) |
||
30 | args = parser.parse_args() |
||
31 | return args["version"] |
||
32 | |||
33 | |||
34 | class Predict(Resource): |
||
35 | def get(self): |
||
36 | """Get prediction from model. |
||
37 | |||
38 | Input: Feature array |
||
39 | """ |
||
40 | parser = reqparse.RequestParser() |
||
41 | parser.add_argument("features", type=str, required=True) |
||
42 | args = parser.parse_args() |
||
43 | return args |
||
44 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.