Setting up a MongoDB Atlas account.
Setting up a Weatherbit API account.
Setting up a TimeZoneDB account.
Setting up and testing the Main Service.
Setup a free MongoDB Atlas account and create a cluster using this link.
https://www.mongodb.com/basics/mongodb-atlas-tutorial
Ensure you create a cluster user so you can access it externally.
After this, go to the network access tab and allow all IP addresses so that your servers can access them later. This is important because when we use Heroku Servers, their IPs might constantly change and we have no access to this.
Your database should now be set up.
Sign up for a free Weatherbit account here
https://www.weatherbit.io/account/create/
The purpose of this API is to gather training data for our Decision Tree Model for weather prediction.
Sign up for a free TimeZoneDB account here
https://timezonedb.com/register/
This is to get accurate timestamps of the data being fed in without having to maintain them on the ESP32 or keeping track of them on the Heroku server.
Now that the backend service is completely operational there are some things to note.
We want the main service to be in weather_api mode for some time (preferably around 2 months or so) to gather enough data for the model. After this period we can switch back to the machine_learning mode.
This process might be a little lengthy but it is fairly straightforward.
Here are the steps:
Fork the following repository over to your Github account.
https://github.com/owolabioromidayo/hs1/
Clone the forked repository from your account onto your PC to edit.
Run scripts/setup_git.sh and change the REPO variable to that of your forked repo.
Create a Heroku account for the main service.
Open the cloned directory in your terminal
Set up a virtual environment for your project by using the scripts/setup_python.sh script.
Setup your Heroku app from your project by using the scripts/setup_heroku.sh script. Ensure to change the APPNAME variable to one you are comfortable with.
Notice that we set up Memcached Cloud from Heroku in the previous step. Ensure you get your username, password, and servers to be stored in your .env file later.
Login to the Heroku Website to ensure the service has been created.
Move the .env.example file to .env and fill it with all the details gathered so far. Here are some things to take note of
There should be no spacing before/after the = sign i.e. (key=value is the correct way).
Don't worry about variables that are already filled unless they have an EX in front of them (as they are just to give you an idea of the format).
ML_ENDPOINT should be left for now.
TRAINING_PASSWORD and PUBLISH_PASSWORD should be generated by you.
TIMEZONEDB_KEY, TIMEZONEDB_REGION, WEATHERBIT_API_KEY, and MONGO_CONNECTION_STRING should be provided by you and your configuration on these sites.
MEMCACHEDCLOUD* keys should be filled in from the previous step.
LATITUDE and LONGITUDE are necessary and should be provided.
Leave SERVER_ENDPOINT for now.
Run scripts/update_conf.sh to update changes in your .env file to the Heroku service.
Run the server using wsgi.py in another window and run the python scripts in tests/ in the following order
test_db.py
test_cache.py
hydrate.py
test_publish.py
test_db.py
test_endpoints.py
Hopefully, these should all be working at this stage. If not, ensure your environment variables are correct. For the test_endpoints.py execution, all responses should contain 200 which means the requests were successful.
Set debug=False in the wsgi.py file.
When you are sure it works locally, run git push heroku master to upload the code to your Heroku service. Then change the SERVER_ENDPOINT variable in your .env file and re-run the tests in the same order as before.
Provide your credit card info on the Heroku Website to increase server uptime from 550 to 1000 hours for FREE.
Done for now! Setup the ML service on the next page.