Welcome to Lisbon Data Science Academy Batch 5 Students repository!
Your first step in this journey is to carefully read the steps in this tutorial. You'll learn:
- ➡️ How to set up your environment;
- ➡️ The weekly workflow to follow during the Academy
This section deals with setting up Windows Subsystem for Linux (WSL) on Windows 10.
If you are using MacOS or Linux you can skip this section.
Why do I need to install WSL?
Because of the differences in command line syntax between Windows vs Mac OS/Linux, it would be a great challenge for us to support and provide instructions for both Operating Systems. For this reason, we’d ask you to install Windows Subsystem for Linux which enables you to run Linux command lines inside Windows.
Step 1: Follow this guide to setup WSL on Windows 10.
Step 2: Open a terminal (remember this!!) and run the following command:
sudo apt update && sudo apt upgrade && sudo apt install git
Step 3: Open a terminal (remember this!!) and check if you already have python3.7
by usind the command below. If your version is Python 3.7.x
(x
= any number), you can skip to step 4, otherwise continue with step 3.1 and 3.2
python3.7 --version
Step 3.1: Run the following commands to setup Python 3.7 (if you get an error with this command, check this ):
sudo add-apt-repository ppa:deadsnakes/ppa
Step 3.2: Run the following commands to install Python 3.7
sudo apt update && sudo apt install python3.7 -y
Step 4 Run the following command to get pip
and venv
:
sudo apt update && sudo apt upgrade && sudo apt install python3-pip python3.7-venv -y
Why do we install these?
We'll be using
pip
which is the reference Python package manager. You should always use a virtual environment to install python packages. We'll usevenv
to set them up.
Some of the steps in the following sections will require Homebrew for MacOS. Homebrew will make it easier to install software that we will use later on.
Step 1: To open the terminal, choose one:
-
In Finder , open the /Applications/Utilities folder, then double-click Terminal.
-
By pressing cmd + space then type
terminal
and press enter.The terminal should now be open:
Step 2: To install Homebrew for MacOS, copy and paste the following line in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Step 2.1: Sometimes it's necessary to install xcode command line utils. To do so, do the following command before installing homebrew:
xcode-select --install
You may be prompted to install the Command Line Developers Tools. Confirm and, once it finishes, continue installing Homebrew by pressing enter again.
Step 3: open a terminal and run the following command:
brew update --verbose
Step 4: then run the following command:
brew install git
Step 5: then run the following command:
brew install [email protected]
Step 6: then run the following command:
brew link [email protected]
So you got the new M1 and you're supper happy with how fast it is.. Unfortunately dealing with apple silicon requires a little get around. But don't worry, we'll be able to get there in the end.
Step 1: To open the terminal, choose one:
-
In Finder , open the /Applications/Utilities folder, then double-click Terminal.
-
By pressing cmd + space then type
terminal
and press enter.The terminal should now be open:
Step 1.1: To use intel-based software, you'll need Rosetta2. Most of you should already have it installed for varied reasons. If you don't simply run the following line in the terminal:
softwareupdate --install-rosetta
This will launch the rosetta installer and you’ll have to agree to a license agreement.
Step 2: To install Homebrew x86 version, aka ibrew
for MacOS, copy and paste the following line in the terminal:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Step 2.1: Sometimes it's necessary to install xcode command line utils. To do so, do the following command before installing homebrew:
xcode-select --install
Step 3: Add an alias with ibrew
to your $PATH
echo 'alias ibrew="arch -x86_64 /usr/local/bin/brew"' >> ~/.zshrc
Step 4: Activate the alterations done to .zshrc
source ~/.zshrc
Step 5: Install python 3.7 with ibrew
ibrew install [email protected]
Step 6: Add python 3.7 to $PATH
export PATH="/usr/local/opt/[email protected]/bin:$PATH" >> ~/.zshrc
Step 7 Re-activate the alterations done to .zshrc
source ~/.zshrc
So you're using Ubuntu, hun? Well, kudos to you. You just need to install a couple of packages.
Step 1: Open a terminal and check what version of Python you have by using the command below. If your version is Python 3.7.x
(x
= any number), you can skip to step 2, otherwise continue with step 1.1 and 1.2
python3.7 --version
Step 1.1: Run the following commands to setup Python 3.7 (if you get an error with this command, check this ):
sudo add-apt-repository ppa:deadsnakes/ppa
Step 1.2: Run the following commands to install Python 3.7
sudo apt update && sudo apt install python3.7 -y
Step 2 Run the following command to get pip
and venv
:
sudo apt update && sudo apt upgrade && sudo apt install python3-pip python3.7-venv -y
Why do we install these?
We'll be using
pip
which is the reference Python package manager. You should always use a virtual environment to install python packages. We'll usevenv
to set them up.
Bellow are the instructions that are enough to get the setup done and get you up and running :) You can also follow this guide for a more in depth set of instructions that accomplish exactly the same thing.
To install and update packages, we'll be using pip which is the reference Python package manager.
Step 1 Start by installing ensuring pip, setuptools, and wheel are up to date:
python3.7 -m pip install --user --upgrade pip setuptools wheel
Step 2 Create a virtual environment with the name slu00
python3.7 -m venv ~/.virtualenvs/slu00
Step 3 Activate the environment
source ~/.virtualenvs/slu00/bin/activate
Note: after you activate your virtual environment you should see at the leftmost of your command line the name of your virtual environment surrounded by parenthesis, like this:
mig@my-machine % source ~/.virtualenvs/slu00/bin/activate
(slu00) mig@my-machine %
And you're able to make sure your virtual environment is active using the which
command (it outputs the location of your virtual environment's python installation):
(slu00) mig@my-machine % which python
/Users/mig/.virtualenvs/slu00/bin/python
Step 4 Now update pip.
(slu00) pip install -U pip
Having a GitHub account and knowing the basics of committing and pushing changes are mandatory for this academy.
- Sign up for a GitHub account if you don't already have one.
- Checking for existing SSH keys
- Generating a new SSH key and adding it to the ssh-agent
- Adding a new SSH key to your GitHub account
- Testing your SSH connection
The workspace directory/repository is where you will place everything you are working on, solve exercises, make changes to files, etc. In this academy that is a requirement as it is how you will make your work available to us.
- Log into GitHub
- Create a new private GitHub repository called batch5-workspace, see
Creating a new repository.
IMPORTANT The repo MUST be named batch5-workspace!
If you name it anything else, you will be unable to submit any of your work!
- You need to explicitly select Private - This is your work and nobody else's. You will be graded based upon the merits of what you are able to do here so this should not be open to the world while you are working on it. Maybe after the course is completed, you can open-source it but not this time.
- Initialize with a README. This is mostly just so that you don't initialize an empty repo.
- Add a Python
.gitignore
. This step is insanely important. If you don't do this, you may end up checking things into the repo that make it un-gradeable by our grading system. ADD THE.gitignore
PLEASE!!!! <--- 4 *!
isn't enough
Since the repository is private you will have to explicitly give access so that our grading system can fetch the repository. To do this you will be adding a deploy key to the repository, which we provide to you in our Portal.
- Head on to the Portal
- Log in with your GitHub account
- Go to your profile and
copy the deploy key (including the
ssh-rsa
part) - Go back to the repository you have just created
- Go to
Settings > Deploy Keys
- Click "Add deploy key" (no need to grant Write Access)
- Give it a recognizable name like "grader" and paste the key from the Portal
-
Open a Terminal or Git Bash, the next steps are on this terminal
-
Clone your
<username>/batch5-workspace
repositoryIf you're not sure where to clone the repository in, you can create a
~/projects
folder, and clone it there -
Clone the students repository If you have your ssh keys set up as instructed:
git clone [email protected]:<username>/batch5-workspace.git
else
git clone https://github.com/<username>/batch5-workspace.git
You will be cloning the batch5-students repository. All of the learning material you need will be made available on this repo as the academy progresses.
- Open a Terminal or Git Bash, the next steps are on this terminal
- Clone the students repository batch5-students
git clone https://github.com/LDSSA/batch5-students.git
Or if you have your ssh keys set up:
git clone [email protected]:LDSSA/batch5-students.git
In the batch5-students
repository that you just cloned there is a sample
learning unit.
It's used to give instructors guidelines to produce the learning units.
We are also using it to ensure that you are able to run and submit a learning
unit.
So go ahead and copy the sample directory sample/SLU00 - LU Tutorial
from the batch5-students
repository to your repository (named batch5-workspace
).
The grader only requires you to have the contents in a directory starting with the learning unit's ID, but we highly advise to keep the same directory structure as the students repository. All learning units are organized as:
<specialization ID> - <specialization name>/<learning unit ID> - <learnin unit name>
Doing so will help you keep organized and ease copying data from the students repository to yours.
All learning units come as a set of Jupyter Notebooks (and some links to presentations). Notebooks are documents that can contain text, images and live code that you can run interactively.
In this section we will launch the Jupyter Notebook application. The application is accessed through the web browser.
Once you have the application open feel free to explore the sample learning unit structure. It will give you a handle on what to expect and what rules the instructors follow (and the effort they put) when creating a learning unit.
So let's start the Jupyter Notebook app:
-
Activate your virtual environment
source ~/.virtualenvs/slu00/bin/activate
-
Enter the Learning unit directory in your workspace directory (
batch5-workspace
).Note: It is VERY IMPORTANT that you ALWAYS work on the files on your
batch5-workspace
repository, and NEVER work on files that are in yourbatch5-students
repository!cd ~/projects/batch5-workspace/sample/"SLU00 - LU Tutorial"
-
Installing the necessary packages
pip install -r requirements.txt
-
Run the jupyter notebook If you are running WLS on Windows 10 run the following:
jupyter notebook --NotebookApp.use_redirect_file=False
else:
```bash
jupyter notebook
```
When you run the jupyter notebook
command, you should see something similar to this in your terminal:
Your browser should pop up with Jupyter open, however, if this does not happen, you can simply copy the link you see on your terminal (the one that contains localhost
) and past it in your browser's address bar:
Note: If you see these scarry looking error messages, don't worry, you can just ignore them.
Make sure you open and go through the Learning Notebook first.
Every learning unit contains an exercise notebook with exercises you will work on. So let's have a look at the sample Learning Unit.
- On the Jupyter Notebook UI in the browser open the exercise notebook
- Follow the instructions provided in the notebook
Besides the exercises and the cells for you to write solutions you will see
other cells with a series of assert
statements.
This is how we (and you) will determine if a solution is correct.
If all assert
statements pass, meaning you dont get an AssertionError
or
any other kind of exception, the solution is correct.
Once you've solved all of the notebook we recommend the following this simple checklist to avoid unexpected surprises.
- Save the notebook (again)
- Run "Restart & Run All"
- At this point the notebook should have run without any failing assertions
If you want to submit your notebook before it is all the way done to check intermediate progress, feel free to.
If you are able to go through the entire process and get a passing grade on the sample LU you'll have a good understanding of the same flow that you'll use for all LUs throughout the academy.
Now you have worked on the sample learning unit and you have some uncommitted
changes.
It's time to commit the changes, which just means adding them to your batch5-workspace
repository history, and pushing this history to you remote on GitHub.
- Using the terminal commit and push the changes
git add .
git commit -m 'Testing the sample notebook'
git push
- Go to the Portal and select the learning unit
- Select "Grade"
- After grading is complete you should have 20/20
- If everything passes locally but the grader doesn't give you the excepted output head to out troubleshooting
You will need to follow this workflow whenever new learning materials are released.
Learning units will be announced in the academy's #announcements channel. At this point they are available in the batch5-students repository. A new Learning Unit is released every Monday, and its solutions are then released the next Monday.
The steps you followed during the initial setup are exactly what you are going to be doing for each new Learning Unit. Here's a quick recap:
-
If you haven't, activate your virtual environment
source ~/.virtualenvs/slu00/bin/activate
-
Once a new Learning Unit is available, pull the changes from the batch5-students repo:
- enter the
~/projects/batch5-students/
using thecd
command, then use thegit pull
command:
cd ~/projects/batch5-students/ git pull
- enter the
-
Copy the Learning Unit to your
batch5-workspace
repocp -r ~/projects/batch5-students/"<specialization ID> - <specialization name>"/"<learning unit ID> - <learnin unit name>" ~/projects/batch5-workspace/"<specialization ID> - <specialization name>"
For example, for the
S01 - Bootcamp and Binary Classification
andSLU01 - Pandas 101
, it would look like this:cp -r ~/projects/batch5-students/"S01 - Bootcamp and Binary Classification"/"SLU01 - Pandas 101" ~/projects/batch5-workspace/"S01 - Bootcamp and Binary Classification"
-
Create a new virtual environment for the Learning Unit you'll be working on.
- To do this you will run the following command:
python3.7 -m venv ~/.virtualenvs/<learning unit ID>
- and you would replace the
<learning unit ID>
with the learning unit ID, such that for SLU01, for example, the command would be:
python3.7 -m venv ~/.virtualenvs/slu01
-
Activate your virtual environment
source ~/.virtualenvs/slu01/bin/activate
-
Install the python packages from requirements.txt for the specific Learning Unit (you must do this for each Learning Unit, and there are multiple Learning Units in a Specialization)
pip install -r ~/projects/batch5-workspace/"<specialization ID> - <specialization name>"/"<learning unit ID> - <learnin unit name>"/requirements.txt
For example, for the
S01 - Bootcamp and Binary Classification
andSLU01 - Pandas 101
, it would look like this:pip install -r ~/projects/batch5-workspace/"S01 - Bootcamp and Binary Classification"/requirements.txt
-
Change to the
batch5-workspace
dircd ~/projects/batch5-workspace
-
Open Jupyter Notebook
jupyter notebook
-
Work
-
Once all tests pass or once you're happy, save your work, close the browser tab with the Jupyter Notebook, close the terminal and open a new terminal
-
Then commit the changes and push
cd ~/projects/batch5-workspace git add . git commit -m "Worked on SLU01 exercises" git push
-
Profit
As much as we try and have processes in place to prevent errors and bugs in the learning units some make it through to you. If the problem is not in the exercise notebook you can just pull the new version from the students repo and replace the file. The problem is if the correction is in the exercise notebook, you can't just replace the file your work is there and you'll lose it!
When a new version of the exercise notebook is released (and announced) two things will happen. If you submit an old version of the notebook it will be flagged as out of date and not graded. You will have to merge the work you've already done into the new version of the notebook.
At the moment our suggestion to merge the changes is:
- Rename the old version
- Copy the new exercise notebook over
- Open both and copy paste your solutions to the new notebook
We understand it's not ideal and are working on improving this workflow using nbdime. If you are comfortable installing Python packages you can try it out, but we offer no support for this at the moment.
In your Profile in the Portal, besides your GitHub Handle, you should add your SlackID. You can find information on how to find it following this link
During the academy you will surely run into problems and have doubts about the material. We provide you with some different channels to ask for help.
If you feel something is not clear enough or there is a bug in the learning material please follow these steps. Remember, there is no such thing as a dumb question, and by asking questions publicly you will help others!
If you have more conceptual questions about the materials or how to approach a problem you can also reach out to the instructors on slack. You can find the main contact for the learning unit in the Portal this instructor can help you out or redirect you to someone that is available at the moment.
Are you getting different results locally than what you are getting in the Portal? If so we will first ask to do a bit of troubleshooting.
- Ensure that you have saved the changes in the notebook
- Ensure that you have committed and pushed the changes
- Ensure that you are not using packages that are not present in the original
requirements.txt
file (changes to this file or your local environment have no effect) - In the learning unit page in the Portal you are able to download the exercise notebook with the results of the grader by clicking your grade, have a look to figure out what went wrong. If none of these steps helped go ahead and open a support ticket for the portal here.
Is the Portal down or acting out in some unexpected way? Then please open a support ticket for the portal here.
- When I open Windows Explorer through Ubuntu it goes to a different folder than in the guide
- Ubuntu on Windows 10 high CPU usage crashes
- When I pull from the
batch5-students
repository I get an error - When I try to open
jupyter notebook
I get an error - When I use the
cp
command the>
sign appears and the command does not execute - When setting up python 3.7 I get an error
- Nothing happens when I type my password
- I still have a NotImplemented error
- I get an error when creating the virtual environment
- Checksum verification failed
- My problem is not listed here what should I do?
- Tutorial videos from Prep Course 2020
Please make sure:
- you are running the command
explorer.exe .
including the dot at the end. - you are running Windows 10 version
1909
or newer.
- First please make sure you are running Windows 10 version
1909
or newer. - Then, try following these steps
error: Your local changes to the following files would be overwritten by merge:
<some files>
Please commit your changes or stash them before you merge.
Aborting
git is telling us that changes were made by you to the files on the ~/projects/batch5-students
folder, and is not pulling the changes made by the instructors because they would override the changes that you made there. To fix this do the following:
-
make sure that any change you made to the files on
~/projects/batch5-students
(that you want to not lose) is saved in your~/projects/batch5-workspace
repository (seehttps://github.com/LDSSA/batch5-students#updates-to-learning-units
for how to do this), and if you don't want to keep the changes you made to these files, just continue on to the next step -
go to the
~/projects/batch5-students
folder and run:cd ~/projects/batch5-students git stash
-
now you can pull from the
batch5-students
repository:git pull
migs-MBP% jupyter notebook
zsh: command not found: jupyter
Before opening jupyter notebook
activate your virtual environment:
source ~/.virtualenvs/slu00/bin/activate
cp -r ~/projects/batch5-students/"S01 - Bootcamp and Binary Classification"/"SLU01 - Pandas 101" ~/projects/batch5-workspace/"S01 - Bootcamp and Binary Classification"
>
Make sure to use this type of quotes "
and not these ones “
.
When I run this command:
sudo add-apt-repository ppa:deadsnakes/ppa
I get this error:
W: GPG error: http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7FCC7D46ACCC4CF8
Solution: Take the id in front of NO_PUBKEY
(in my case its 7FCC7D46ACCC4CF8
) and run the following command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FCC7D46ACCC4CF8
In step two it asks me for the computer password. However, I am not being able to write anything
Solution: When you write your password you might not get any visual feedback and that's okay! Write it as normal and hit enter when you're done!
I've completed the exercise in the Exercise Notebook but when I run the cell I get a NotImplementedError.
Solution:
The raise NotImplementedError()
are added to the exercise cell as a placeholder for where you're supposed to add your solution/code. It is meant to be removed!
I ran python3.7 -m venv ~/.virtualenvs/slu00
, but got the following error:
The virtual environment was not created successfully because ensurepip is not available.
This can happen if either you skipped the installation of python-pip, or the version of the python you're calling doesn't have python pip installed.
As we're using python3.7 for this academy, and if you've followed all the steps in this README correctly, you should be able to create the virtual environment with:
python3.7 -m venv ~/.virtualenvs/slu00
I'm getting "checksum verification failed" on a portal submission.
Some metadata can change when you open your jupyter notebook using vscode. Try running the notebooks from start to end in Jupyter and resubmit.
If the above steps didn't solve the problem for you, please contact us on Slack or open an issue in this repo.
If you want a visual guide, you can look at the tutorial videos from the Prep Course of year 2020.
- Setup guide for Windows - Part 1
- Setup guide for Windows - Part 2
- Setup guide for Mac
- Updates to Learning Units guide for Windows 10
- Updates to Learning Units guide for Mac
If your problem doesn't fit in any of the previous categories head over to slack and ask. Someone will surely point you in the right direction.
If you're looking for some specific part of our organization head over to the Member Directory and search for the area of responsibility you're looking for.