Firebase is an online database which allows communication between servers and apps. In order for the features of the app to work, it needs a firebase account to read and send data to and from. The existing code uses the database at gd-prototype.firebaseio.com but this can be substituted for another with a similar tree structure. In order to create a new database, you simply need to create an account at firebase.com and select “create new app”
For the app to run properly, your firebase tree structure must have three main branches: parameters
, training weights
, and users
. The individual user sub-trees will be added when a new user creates an account through the app's sign-in page. The training weights branch should have two sub-branches: iteration
and weights
.
In order to ensure that every interaction between the clients, the server, and Firebase happens in the correct order, a series of checkout systems have been implemented. Firstly, a unique gradIter
allows a client to check that a gradient packet has been received by Firebase before sending a second. Similarly, a gradientProcessed
boolean set to false with every gradient sent and set to true when processed by the server makes sure that a gradient has been read by the server before the client sends a second. There are two iterators which prevent any outdated gradients from being applied to the weights. The first is weightIter
which is taken by the client every time a weight it pulled, and checked by the server after sending to see if it matches the current weightIter
before applying the gradient. This value is updated every time the weight is updated. Finally the paramIter
is updated by the administrator every time the parameters are changed, and is checked in a similar manner to the weightIter
by the server to make sure the gradients being applied have used the correct and current parameters.
- Enable Email/Password: In your project console, go to Authentication > Sign-in Method > Enable Email/Password
- In Database > Rules: Paste the following settings:
{
"rules": {
".read": true,
".write": false,
"users": {
"$user_id": {
".read": "$user_id === auth.uid",
".write": "$user_id === auth.uid"
}
}
}
}
Note: To disable all read/write abilities for the database, simply change the rules false
. Beware! This doesn't prevent administrator/privileged access from modifying data (the server is a privileged user).
{
"rules": {
".read": false,
".write": false,
"users": { ... }
}
}