- Install Python 3.11.5
- Create a virtual environment:
python3 -m venv env - Activate the virtual environment:
source env/bin/activate - Install dependencies:
pip install -r requirements.txt - Create a
.envfile (follow the.env-template):- Update the
.envfile with your OkPy access token. You must have staff permissions for the course you want to query and you must periodically re-request your token.
- Update the
cd src/backups
# Extract student emails from Gradescope .csv roster
python3 main.py emails
# Make HTTP requests to OkPy server to create .json dump of
# student emails to the backups for all of their assignments
python3 main.py request
# Given the .json dump, store the file contents of the backups
# locally and also write the backup metadata to a sqlite database
python3 main.py storeRun --help with any of the commands for more information.
Create a configuration file to save yourself the effort of typing a bunch of CLI arguments. An example can be found in src/backups/backup_config.json. All fields are required (e.g. they must either be provided in the config or via the CLI). CLI arguments will override anything in the config.
- Create a
.sqlfile dump of the OkPy Backups database (after you have run therequestandstorecommands):
# Replace $OUTPUT_DB_NAME and $OUTPUT_DUMP_NAME with values of your choice
sqlite3 data/private/$OUTPUT_DB_NAME.db .dump > data/private/$OUTPUT_DUMP_NAME.sql- Add the dump data into your Rails (development) database:
# Replace $OUTPUT_DUMP_NAME with value from step 1
sqlite3 src/snapshots-app/storage/development.sqlite3 < data/private/$OUTPUT_DUMP_NAME.sql- Generate models for the tables:
rails generate model BackupMetadatum
rails generate model OkpyMessage- Verify that your data has been loaded properly:
# Open the rails console
$ rails c
snapshots-app(dev)> BackupMetadatum.all # view data and check it looks correct, press q to exit long list
snapshots-app(dev)> OkpyMessage.all # view data and check it looks correct
snapshots-app(dev)> exit
This repository uses GitHub Actions to run black and pylint. See .github/workflows.
This repository uses the pre-commit package to automatically run
the black Python formatter upon running git commit. Hooks can be added to .pre-commit-config.yaml.