-
Fork the repository
-
Clone the forked repository to create a project in your IDE
-
Create and activate a virtual environment in the project folder e.g.
- MacOS:
python3 -m venv .venvthensource .venv/bin/activate - Windows:
py -m venv .venvthen.venv\Scripts\activate
- MacOS:
-
Check
pipis the latest versions:pip install --upgrade pip -
Install the requirements. You may wish to edit requirements.txt first to remove the packages for Flask or Dash if you only want to complete the activities for one type of app.
- e.g.
pip install -r requirements.txt
- e.g.
-
Install the paralympics apps code e.g.
pip install -e .
This repository contains 4 apps used in the activities which may cause some confusion for imports.
Remember to run pip install -e .
The apps can be run from the terminal as follows, you may need to use 'py' or 'python3' instead of 'python' depending on your computer:
- Dash app:
python src/paralympics_dash/paralympics_dash.py - Dash multi-page app:
python src/paralympics_dash_multi/paralympics_app.py - Flask REST API app (coursework 1):
flask --app paralympics_rest run --debug - Flask app:
flask --app paralympics_flask run --debug - Flask ML app (Iris):
flask --app flask_iris:create(app) run --debug
There are two sets of activities. You can complete both, or just the version for the framework you intend to use for coursework 2.
The activities are designed to be completed in order, skills are introduced in an activity and specific instructions are not then repeated in subsequent activities.
| Activity | Chart type | Data access method | Chart library |
|---|---|---|---|
| Introduction | |||
| Activity 1 | Line chart | pandas / .csv | Plotly Express |
| Activity 2 | Bar chart | pandas / .csv | Plotly Express |
| Activity 3 | Scatter Mapbox, map with markers | pandas / SQLite database | Plotly Go |
| Activity 4 | Summary statistics presented in a Bootstrap card | pandas / REST API | None |
The activities are designed to be completed in order, skills are introduced in an activity and specific instructions are not then repeated in subsequent activities.
Some page activities are introduced in week 8.
| Week | Page | Data access | Route | Jinja | Form | Other |
|---|---|---|---|---|---|---|
| 7 | Event details | SQLAlchemy query | GET: Find an event by id and pass it to the template | Template with bootstrap rows and columns | ||
| 7 | Home with hyperlinked logos | SQLAlchemy query | GET: Find all events and pass to the template | Template with for loop generates logos + event year & host + hyperlink to events detail page | Access image files from /static Dynamically generate URL. |
|
| 7 | Chart | SQLAlchemy query with results to pandas DataFrame | GET: Get the HTML for the chart and pass to the template | Displays HTML. Prevents auto-escaping of the variable with the HTML. | ||
| 8 | Add event | GET: Display the add event form. POST: Use the values from the form to create a SQLAlchemy object and save to the database. |
Form to add fields for a new event. Validation. Form field macro. | |||
| 8 | Prediction | Use model.pkl to get a prediction | GET: Display the prediction form. POST: Pass the values from the form to the model to get a prediction, update the page to display the prediction result. |
Template with form and placeholder <div> for the prediction result. |
Form to enter values for prediction. Validation. Default values. | Create pickled ML model. |