To get credit for the lab, please show the completed work to a lab TA. They will check you off.
Goals:
- Setup Python, Jupyter Notebook and Github.
- Practice basic git commands.
- Practice basic software design workflow: pull request, code review, and test-driven development.
- Practice basic linear algebra with Numpy.
Working in pairs is recommended.
- Install Python 3.8 or 3.10 here: link.
- Install Jupyter Notebook here: link.
- (Optional) Install Github desktop link.
- Github Desktop is a nice GUI if you don't want to use command line instructions.
- On Windows, you will need a terminal emulator to use
git
command line instructions (I like MobaXterm: link).
- Download Python libraries:
pip install numpy pytest
. - Follow instructions here to create a Github Authentication token: link.
- One of you should create a new Github repo called
CS506-Lab0
. Uploadtest_utils.py
andutils.py
to the repo using the "Add file" button. Add your partner as a collaborator under Settings -> Collaborators. - Both of you should navigate to the newly created repo in a browser and create a branch off of main.
- Both of you should clone your own branch locally (use either the command line or Github Desktop depending on your setup).
- Command line:
git clone -b <your_branch> <remote_repo_url>
- Github Desktop: File -> Clone repository -> type in repo name -> Clone; then, switch the current branch to your own branch on the top navigation bar.
- Command line:
test_utils.py
andutils.py
contain missing code for you to fill out with instructions. One of you should fill in the missing code inutils.py
, and the other should fill intest_utils.py
.- Once you finish making the changes, follow these steps to commit (use either the command line or Github Desktop depending on your setup):
- Command line:
- Use
git status
to list the files you modified. - Use
git add <filename>
to stage a file for the commit. For example:git add test_utils.py
. - Use
git commit -m "commit message here"
to commit locally. - Use
git push
to push changes to Github. You will need to use your Github username and the authentication token generated in Part 0 (starts withghp_
).
- Use
- GitHub Desktop:
- Once you make your changes locally, you should see the changes in the Github Desktop app.
- Type your commit message into the text box and click "Commit to <branch_name>".
- Click the button that says "Push origin".
- Command line:
- Once you have pushed changes to your branch on Github, a message should pop up in Github saying that your branch has recent changes. Click the green button that says "Compare and Pull Request".
- Ensure that the pull request says
base:main <- compare:<branch_name>
. This means that you are requesting your changes to be merged intomain
. - Click "Create Pull request".
- Ask your partner to look at the pull request you created (they can see the new pull request under the "Pull request" tab in Github). Once your partner is satisfied with the code you wrote, they should click "Merge Pull request".
- Ensure that the pull request says
When working on a software project with many contributors, it becomes increasingly difficult to track down bugs. This is why we need automated testing after every commit. A common practice is to perform fast and simple checks after every change on the main branch and more comprehensive integration tests nightly.
For this lab, we will setup a simple automated testing workflow on Github. The workflow will check your Python syntax and run the three tests in test_utils.py
.
- Follow instructions here: link
- Edit your newly created
.github/workflows/python-app.yml
file on Github to importnumpy
when testing, i.e. changepip install flake8 pytest
topip install flake8 pytest numpy
. - The test should take a few seconds to run. You should see a green check mark next to your commit when done.
- You may need to make changes to your code if the test fails. You can edit the code files directly on Github by pressing the edit icon.
- Show the lab instructor that the test passed (green check mark appears next to latest commit).