1. Getting started

  1. Read the Requirements section.
  2. Install, configure and test your development environment (Development environment).
  3. Create a Git repository for your team/project (Creating a team development repository) from the provided template.
  4. Read Using Git.
  5. Read the Deliverables section, and with your team consider dependencies between ‘tasks’ in the deliverables and allocate independent tasks to a team member (Project planning).
  6. Start implementing your tasks (Editing and executing Python code).

Tip

Start simple and work in small steps. It is much easier to add functionality to a working program than to fix a complicated non-working program.

Note

When developing your programs, you may need to review the activity notebooks from Michaelmas Term.

1.1. Development environment

Note

Experienced developers have their preferred tools and development environments. If you are experienced with Git, Python and using editors, you are free to use your preferred tools.

The following procedures and tools are suggested.

1.1.1. Software installation

  1. Install Visual Studio Code (https://code.visualstudio.com/).
  2. Install Anaconda (https://www.anaconda.com/download/).

1.1.2. Terminal (command line)

Some of the following steps require a command line terminal. To open a command line terminal:

  • Linux and macOS: Open a ‘Terminal’.
  • Windows: Launch ‘Anaconda Prompt’.

1.1.3. Install and configure Git

Open a terminal/command prompt.

  1. Install Git

    conda install git
    
  2. Configure Git with your name and email address

    git config --global user.name "John Doe"
    git config --global user.email johndoe@example.com
    
  3. Configure Git to use VS Code

    git config --global core.editor "code --wait"
    

You will need to configure Git on each computer that you use.

1.1.4. Testing your Python installation

  1. Open the ‘Anaconda Navigator’ program.

  2. From Anaconda Navigator, launch VS Code.

  3. Create a new file in VS Code with the extension .py and enter some simple Python code, e.g.:

    print("Testing Python install")
    
  4. Right-click from VS Code on the file and select Run Python File in Terminal. The output of your program should appear in a terminal window inside VS Code.

1.2. Creating a team development repository

  1. Cambridge students Follow the instructions on the course Moodle page to create your team repository.

    Others Template start code is at https://github.com/CambridgeEngineering/PartIA-Flood-Warning-System.

  2. Fetch a local copy of your repository by cloning it. The ‘Code -> Clone’ button on the GitHub page for your repository gives the address of your Git repository. From a terminal:

    git clone <address of my repository>
    

    You should now have a local (on your computer) copy of the code.

  3. From the terminal, enter the code directory attempt to execute file Task1A.py:

    python Task1A.py
    

    (If you are not using Anaconda, on some systems you may need to use python3 Task1A.py).

    You should see some output on river level monitoring stations.

Note

The Python code from which you will start uses some modules (requests and dateutil) that are not part of the Python standard library, but which are distributed as part of Anaconda. If you see an error that a module is missing, you can install the module using pip. Use:

pip install requests
pip install python-dateutil

1.3. Editing and executing Python code

  1. From Anaconda Navigator launch ‘VS Code’ and from VS Code open your local code repository directory.
  2. Open/create the files you wish to edit. ‘Module’ files should go in the directory floodsystem/. The Task*.py files should go in the root directory of the repository.
  3. Use right-click -> ‘Run Python File in Terminal’ on the program text in VS Code to run the Python code.

Python code can be run directly from a terminal. In a directory containing Python code in a file named test.py, it can be be executed from the terminal using:

python test.py

As you develop you programs, commit your changes (using Git) and push these to your shared online repository. If you are unsure how often to commit and push changes, err on the side of committing and pushing frequently. Commit at least upon the completion of each task.

1.4. Automated testing

The starter template repository includes the file .github/workflows/pythonapp.yml which configures automated testing, known as continuous integration (CI), on GitHub. Against each commit you will see on the GitHub repository page whether or not the tests are passing.

Edit .github/workflows/pythonapp.yml to run your deliverables in the test system and to add code tests to your test suite.

1.5. Project planning

  1. Examine the first few project deliverables, and divide independent tasks amongst team members. Each team member can then work on tasks independently.
  2. Communicate frequently with team members to update them on your progress, and seek help from a team member if required.
  3. As tasks are completed review each others work and provide feedback.
  4. As you progress through the tasks, periodically assess which tasks are independent and allocate these to a team member.