The first code cell imports dependencies, defines some project-specific information, and provides some utility functions.
Project-specific information, such as asset URLs and Google Drive directories, should be updated depending on the course, the year-session, homework or project number, the name of the archive, and the compression method. A different command may be needed for zip files.
After running the first code cell, six more code cells should be added, each containing one of these commands:
# Connect to your Google Drive. A web popup will ask for the necessary permissions.
#
connect_to_drive()
# Download the project starter files from the URL and extract them into the Google Colab workspace.
#
extract_project_template()
# Copy Python source files from your Google Drive into the Google Colab workspace.
# (Warning: files will be overwritten without confirmation.)
#
restore_files()
# Copy Python source files from your Google Colab workspace into your Google Drive.
# (Warning: files will be overwritten without confirmation.)
#
backup_files()
# Change the working directory to where the homework / project files are.
#
change_runtime_dir()
# Run the main script which is provided with the project.
#
# The percent sign is used to run Jupyter "magic commands".
#
# The option "-i" causes the main script to be run in the main namespace,
# i.e. the Google Colab workbook namespace. This is necessary so that:
#
# (1) Variables can be added and inspected interactively before and
# after the main script;
# (2) Imports by the main script (such as functions defined for the
# homework or project) can be used interactively within the workbook.
#
%run -i 'main.py'