Reputation: 63
Current Project Structure
---src
|__controllers
| |__ prediction.py
|
|__regression
|__ __init__.py
|__ deep_learning.py
The deep_learning.py contains a class where I am initializing a model.
from deep_learning import predict
future_predict = predict()
__all__.append('future_predict')
Here the predict is the name of the class that is contained inside the deep_learning.py.
from flask import Flask, render_template, request, send_from_directory
@app.route('/<filename>', methods=["POST"])
def predict(filename):
print("something: ", future_predict)
return send_from_directory(app.config['IMAGE_UPLOAD_PATH'], filename)
However, I have not been successful with using future_predict
object inside prediction.py.
The error: NameError: name 'future_predict' is not defined
Upvotes: 0
Views: 70
Reputation: 6131
There are several misunderstandings:
__all__
is a way to define what is importable__init__.py
also in your controllers
packageUsually, Python projects, which make use of a src
top level directory, have a structure like this:
❯ tree src/
src/
└── project
├── __init__.py
├── package_1
│ └── __init__.py
├── package_2
│ └── __init__.py
└── package_3
└── __init__.py
4 directories, 4 files
Upvotes: 2