-
Notifications
You must be signed in to change notification settings - Fork 8
Backend Documentation (backend)
This page contains documentation for the files in the /backend
directory of the Github repo. This page is regularly updated when new changes are added to these files.
/aws_helpers/dynamo_db_utils
/common
/dl
/ml
This file is a very important file in the backend. It essentially acts as the point of entry into the backend
-
ml_drive()
: Endpoint that trains classical ML model based on user specifications -
dl_drive()
: Endpoint that trains classical DL model based on user specifications -
root()
: Flask Route to send files from one directory to another -
train_and_output()
: Flask Route that right now trains DL model (frontend will hit this endpoint to rundl_drive()
and JSONified output is sent back) -
send_email_route()
: Endpoint to send email notification to user about their model + training result attachments. This function acts as a wrapper to an AWS API Gateway endpoint that invokes a lambda to send email notification (via AWS SES) through thesend_email()
function. TLDR, the flow issend_email_route()
->send_email()
-> API Gateway -> AWS Lambda -> AWS SES
This file uses socket.io
, which is event-based, so it's completely asynchronous. This helps prevent any block in execution in the frontend when passing data to the backend for training/processing and allows for asynchronous communication from backend to frontend. Thus the way people can send and receive data is as follows:
In any React Component:
import { socket } from '<someRelativePath>/helper_functions/TalkWithBackend'
const MyComponent = () => {
socket.emit('eventName', data1, data2, ...)
}
In driver.py:
@socket.on('eventName')
def any_name(param1, param2, ...):
<perform_function>
The eventName needs to be the same, and you do not have to jsonify so you can directly send dictionaries as well.
You can create a function in driver.py that interacts with socket as shown below, and then pass that function as arguments for use in other backend files
def any_name(param1):
socket.emit('eventName', f'param1 is {param1}') # as an example
In a React Component that needs to intercept the data:
import { socket } from '<someRelativePath>/helper_functions/TalkWithBackend'
const MyComponent = () => {
const [data, setData] = useState(null)
useEffect(() => {
socket.on('eventName', (resultData) => {
setData(resultData)
})
}, [socket])
}
Check out the changes in driver.py and TrainButton.js for an example of its usage (on this status-bar branch).
Running the backend: Make sure that your terminal is at ~/Deep-Learning-Playground
and run python -m backend.driver
. The -m
is a tag to "run as module"
Note that we run the app on host 0.0.0.0 to allow for backend and frontend to be served on the same port. It's crucial for our app to work properly in production.
- Home
- Terraform
- Bearer-Token-Gen-Script
- Frontend-Backend Communication Documentation
- Backend Documentation (backend)
-
driver.py
- AWS Helper Files (backend.aws_helpers)
- Dynamo DB Utility Files (aws_helpers.dynamo_db_utils)
- AWS Secrets Utility Files (aws_secrets_utils)
- AWS Batch Utility Files (aws_batch_utils)
- Firebase Helper Files (backend.firebase_helpers)
- Common Files (backend.common)
-
constants.py
-
dataset.py
-
default_datasets.py
-
email_notifier.py
-
loss_functions.py
-
optimizer.py
-
utils.py
- Deep Learning Files (backend.dl)
- Machine Learning Files (backend.ml)
- Frontend Documentation
- Bug Manual
- Developer Runbook
- Examples to locally test DLP
- Knowledge Share