Lecture 23: Editors and version control#

  1. Open this web page

    • There are links and commands you’ll need

  2. Start VSCode download/install

  • Largely live demo and installation

    • If everything works, it will be a miracle

    • Thanks for your patience

  • Showing the recommended+supported path

    • If you’re comfortable with alternatives, can use those

  • May feel like a whirlwind, just skimming the surface of these tools

  • Keeping the information in the slides minimal

    • There are links to more info

Note to self: can demo with virtual machine (VM): Mac in Orka Desktop and Windows in UTM.

Collaboration#

What might come up if working with other people on code/notebooks?

Hosted notebooks#

Jupyter can run on “on your computer (“local”), or in the cloud somewhere.”

Google Colab#

Integrated development environments (IDEs)#

  • Like Notepad/TextEdit/Notes vs. Word

    • Pros/cons?

    • Jupyter is kinda halfway

  • Getting even more powerful with generative AI integrations

Visual Studio Code (VSCode)#

Note to self: Switch to Computing in Context demo Profile.

Set up project#

  1. Go to open a folder/workspace

  2. Navigate to where you want it

  3. Click New Folder

  4. Name it something like computing-in-context

Create Python file#

  1. Create test.py

  2. Install Python extension, if necessary

  3. Add code

    • print() something

  4. Confirm it’s using Python installed via Anaconda

    • Can have multiple Pythons

  5. Run script

  6. Show:

    1. Syntax issue

    2. Unused import

    3. Auto import

Version control#

When you’re editing a file and make a mistake, what do you do?

Changes over time (history)

Undo/redo are useful

How would you try out a change that touches multiple files?

Branching

Git#

  1. In sidebar, click Source Control

  2. Install Git, if necessary

    • Many ways to install

    • Mac: Use Anaconda

    • Windows: Use Git for Windows

      • There are a lot of options in the installer - safe to stick to the defaults

  3. Initialize repo

  4. Go to Explorer

  5. Open integrated terminal

  6. Set global name and email in Git

    • Your name and email can be set to whatever

  7. Commit

    • “There are no staged changes” -> “Always”

Command line#

Create notebook#

  1. Create file project_3.ipynb

  2. Select kernel

    1. Click Install suggested extensions, if it asks.

    2. Click Python Environments…

    3. Select Python installed via Anaconda

  3. Add a Markdown cell at the top, giving the notebook a title as a heading (level 1).

    # Project 3
    
  4. Add a couple code cells, doing some simple math.

  5. Commit

  6. Your Source Control Graph (a.k.a. your Git history) should then look something like this:

    Git history

Hold onto this repository; you’ll use it through the end of the course.

Will get more into some of these things in more detail in Advanced Computing for Policy