Author: Carmen Alia Arias -- Class of 2024 (with help of ChatGPT)
Welcome to our project! This document will guide you through setting up your development environment, understanding our codebase, and getting started with Python programming. Whether you're new to Python or just new to our project, this guide will help you get up to speed.
-
- 1.1. Prerequisites
- 1.2. Setting Up Git & GitHub
- 1.3. Installing Python & PyCharm
- 1.4. Cloning the Repositoy
- 1.4.1. Using the Command Line
- 1.4.2. Using the PyCharm
- 1.5. Setting Up a Virtual Environment
- 1.5.1. Using the Command Line
- 1.5.2.Using PyCharm
-
- 2.1. Branching Strategy
- 2.2. Creating a Branch and Saving Changes *2.2.1. Using the Command Line *2.1.2. Using PyCharm
- 2.3. Your First Pull Request
Before you start, ensure you meet the following prerequisites:
-
A computer running Windows, macOS, or Linux.
-
An internet connection.
-
A GitHub account (GitHub Sign-up).
-
Have access to the VSVS repository
If you don't have acces right now, then request to be added to the VSVS Organization and repo
Recommendation : If you are creating a new GitHub account use your personal email, because you will probably be using this after you leave Vanderbilt.
Optional but recommended: Sign up for the GitHub student developer pack here. This includes cool perks like free access to GitHub CoPilot!!!
If you're new to Git and GitHub, follow these steps to set up your Git environment and link it to your GitHub account:
-
Install Git: Download and install Git from Git Downloads. For complete instructions refer to this.
-
Configure Git: Open a terminal or command prompt and set your name and email using the following commands:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com" ``
We use Python for our project. Download and install Python by visiting Python Downloads. Ensure you select the option to add Python to your system's PATH during installation.
You are free to use any Python development environment or text editor. However, if you're new to Python we recommend using PyCharm.
You can download PyCharm Community Edition (FREE) from the official website here.
If you are struggling this guide is worth looking at.
-
Before you clone the repository, navigate to the directory where you want to store the local copy of the repository.
Use
cd
command.For example, if you want to create a new folder named "VSVS_project" on your desktop and navigate into it:cd Desktop mkdir VSVS_project cd VSVS_project
-
Clone our project repository from GitHub using the following command:
git clone https://github.com/Vanderbilt-Student-Volunteers-Science/New_VSVS_Scheduler.git
Alternatively, you can use PyCharm's GUI to clone the repository:
- Open PyCharm.
- Click on "File" in the top menu.
- Select "New" and then "Project from Version Control."
- Choose "Git."
- In the "URL" field, enter
https://github.com/Vanderbilt-Student-Volunteers-Science/New_VSVS_Scheduler.git
- Choose the directory where you want to save the repository in the "Directory" field.
- Click the "Clone" button.
To manage project dependencies and isolate your development environment, create a virtual environment. For further reading/help on the virtual environment this blogpost is really helpful!
-
Open a terminal/command prompt in your project directory and run:
python -m venv .venv
-
Activate the virtual environment
-
On Windows:
venv\Scripts\activate
-
On macOS:
source venv/bin/activate
-
-
Install Dependencies:
-
Install project dependencies from the
requirements.txt
file that can be found under thedocs
folder.pip install -r docs/requirements.txt
-
-
Create a .gitignore file.
-
This file tells Git what contents from the folder should not be tracked. This is important so you don't push these files to the repository.
touch .gitignore
-
Add the following to your .gitignore file (you can simply open it as a text file):
.venv data/ results/
-
Remember to save and close the file
IT IS IMPERATIVE THAT YOU INCLUDE THE
/data
&results/
!!!! OTHERWISE PRIVATE INFORMATION ABOUT VOLUNTEERS WILL BE MADE PUBLICLY AVAILABLE ON THE INTERNET -
Installing Dependencies
- Open PyCharm.
- Open your project.
- Go to "File" > "Settings" (Windows/Linux) or "PyCharm" > "Preferences" (macOS).
- In the settings/preferences window, navigate to "Project" > "Python Interpreter."
- Click the "Install Requirements" button, represented by a + sign.
- In the "Install Packages" dialog, locate and select the docs/requirements.txt file from your project directory.
- Click "Install" to install the project's dependencies.
Adding files to .gitignore
- Go "File" > "Settings" (Windows/Linux) or "PyCharm" > "Preferences" (macOS).
- In the settings/preferences window, navigate to "Version Control" > "Ignored Files."
- Click the "+ Add" button.
- In the dialog that appears, enter .venv/ and click "OK."
- Click "Apply" or "OK" to save your changes.
Do this again for the following files too:
data/
results/
IT IS IMPERATIVE THAT YOU INCLUDE THE /data
& results/
!!!! OTHERWISE PRIVATE INFORMATION ABOUT VOLUNTEERS WILL BE MADE PUBLICLY AVAILABLE ON THE INTERNET
The single most important thing to remember: NEVER push your changes directly to the main
branch
Our Philosophy: The goal is to have an always working version of our code on the main
branch.
- You always want to make your own branch that is based on
main
and make your changes there. - Once you are satisfied you create a pull request (PR) that merges your branch with the
main
branch. - Everyone will have a chance to review your code, make suggestions, and approve the PR.
- Once approved your changes will officially be part of
main
!
Naming Convention of Branches: To keep everyone on the same page, we should all be naming our branches based on the feature/issue that we are working on and with our initials so that people know who's branch it is. (i.e. If John Doe is working on fixing the travel time his branch might be called Travel_Time_Fix_JD
)
This is a great overview of our workflow:
Open a terminal/command prompt within the project folder/directory.
-
Create a new branch using naming conventions (here we'll just use 'new-feature' for demonstration purposes):
git checkout -b feature/new-feature
-
After making changes to your code, use the following command to stage your changes for commit:
git add .
You can also stage individual files by replacing . with the file names.
-
Once your changes are staged, commit them with a meaningful message:
git commit -m "Describe your changes here"
-
To push your changes to the remote repository, use the following command (replace 'new-feature' with your branch name):
git push origin new-feature
Note: You only need to include the word origin when you are pushing your branch to remote for the first time. After that you can simply type:
git push
- Open PyCharm.
- Make sure your project is open and active.
- In the top menu, go to "VCS" > "Git" > "Branches."
- In the "Branches" dialog, click the "+ New Branch" button.
- Enter a descriptive name for your new branch (e.g., new-feature). Optionally, you can choose to check out the new branch immediately by selecting the "Check out" option.
- Click the "Create" button.
After making changes to your code, PyCharm will detect the modifications.
-
In the left-hand sidebar, you'll see a list of changed files. Check the box next to each file you want to stage.
-
Alternatively, you can right-click on a file and select "Git" > "Add" to stage it.
With your changes staged, go to "VCS" > "Commit" in the top menu.In the Commit dialog, enter a commit message describing your changes.Click the "Commit" button.
After committing your changes, go to "VCS" > "Git" > "Push" in the top menu.In the Push dialog, ensure your branch is selected, and click the "Push" button.
If you've never created a pull request before or made a branch or anything like that, then I recommend that you go through this tutorial from GitHub.
- Make a new branch based off
main
on your local computer. Name it according to convention. - Go to the file
docs/authors.txt
and add your name on a new line. - Commit the changes.
- Create a PR.
- Wait for your PR to be approved by others and then you can complete the PR and merge your changes to
main
.
Congrats! Your officially part of VSVS IT committee.
-
If you're new to git and/or github please read the following blogpost from freecodecamp.
By the end you should understand:
- What is a repository/repo?
- What does it mean to modify, commit, or stage a change?
- What is a remote repo vs a local repo?
-
Follow this hands-on mini-tutorial for an introduction to github including how to make a repo, commit, and push changes.