Python Lab Submission Instructions

Creating Project

Create virtual environment

Activate virtual environment

Mac/Linux

Windows

Create modules and scripts

Note the underscore vs hyphen

Install packages

For example:

Should result in this file tree:

└── example-lab
    ├── README.md
    ├── requirements.txt
    └── example_lab
        └── example_script.py

Tests

Many labs will require automated testing. If your lab requires it then install pytest or pytest-watch.

Should result in a file tree like this:

└── example-lab
    ├── README.md
    ├── requirements.txt
    ├── example_lab
    │   └── example_script.py
    └── tests
        ├── __init__.py
        └── test_example.py

README

Git

On Local System

Initialize local Git repository

On Github site

On local system (again)

git remote add origin the_url_you_copied_that_ends_with_git
git push -u origin main

Now everything is wired up between local machine and Github.

Canvas Submission

Resubmits

Github Actions

This step is optional early in course. Instructor will inform you when it is required.

Setup “Github Actions” so that your code can be properly tested in Github as you make new pushes to your branches and pull requests to master

Github will now run all of your automated tests and check formatting every time you push code to a branch or try to merge a pull request. In fact, it will block pull requests until your tests are all passing.

name: Run Python Tests
on:
  push:
    branches:
      - main
    paths:
      - 'python/**'
  pull_request:
    branches:
      - main
    paths:
      - 'python/**'

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.9
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
        working-directory: ./python
      - name: Test with pytest
        run: pytest -vv
        working-directory: ./python