Skip to content

Latest commit

 

History

History
1284 lines (794 loc) · 45.7 KB

macOS.md

File metadata and controls

1284 lines (794 loc) · 45.7 KB

Setup instructions

You will find below the instructions to set up you computer for Le Wagon Data Science course

Please read them carefully and execute all commands in the following order. If you get stuck, don't hesitate to ask a teacher for help 🙋

Let's start 🚀

Zoom

To be able to interact when we are not in the same physical room, we will be using Zoom, a video conferencing tool.

⚠️ If you already have Zoom installed, please make sure that the version is at least 5.6.

Go to zoom.us/download.

Under Zoom Client click the Download button.

Open the file you have just downloaded to install the app.

Open the Zoom app.

If you already have a Zoom account, sign in using your credentials.

If not, click on the Sign Up Free link:

Sign Up Free to Zoom

You will be redirected to Zoom's website to complete a form.

When it's done, go back to the Zoom app and sign in using your credentials.

You should then see a screen like this:

Zoom Home Screen

You can now close the Zoom app.

GitHub account

Have you signed up to GitHub? If not, do it right away.

👉 Upload a picture and put your name correctly on your GitHub account. This is important as we'll use an internal dashboard with your avatar. Please do this now, before you continue with this guide.

GitHub picture

👉 Enable Two-Factor Authentication (2FA). GitHub will send you text messages with a code when you try to log in. This is important for security and also will soon be required in order to contribute code on GitHub.

Apple Silicon Chips

If you bought your computer after late 2020, chances are it has a new Apple silicon chip instead of an Intel processor: let's find out.

Open a new terminal window from Applications > Utilities or search for it with Spotlight:

Open Terminal on macOS

Copy-paste the following command in the terminal and hit Enter to execute.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/setup/master/utils/macos_list_processor_type.sh)"

☝️ The result of the command should indicate whether your computer uses Apple Silicon.

If your computer uses Apple Silicon, expand the paragraph below and go through it. Otherwise ignore it.

👉  Setup for Apple Silicon 👈

You want to make sure that you are not using Rosetta, which is a way to use your Terminal as if you had an Intel computer.

Open the Finder app (or search for it with Spotlight).

Go to Applications > Utilities.

Locate the Terminal app (select it).

Press Cmd + I on the Terminal app, then verify that the box "Open using Rosetta" is unchecked. In case you don't see this box, just continue.

🚨 Keep this in mind. You will need to remember later on in the setup whether your computer uses an Apple Silicon chip or is an Apple Intel version

A note about quitting apps on a Mac

Clicking the little red cross in the top left corner of the application window on a Mac does not really quit it, it just closes an active window. To quit the application for real either press Cmd + Q when the application is active, or navigate to APP_NAME -> Quit in the menu bar.

Quit Terminal on macOS

During this setup you will be asked to quit and re-open applications multiple times, please make sure you do it properly 🙏

Command Line Tools

Open a new terminal, copy-paste the following command and hit Enter:

xcode-select --install

If you receive the following message, you can just skip this step and go to next step.

# command line tools are already installed, use "Software Update" to install updates

Otherwise, it will open a window asking you if you want to install some software: click on "Install" and wait.

Install xcode-select on macOS

✔️ If you see the message "The software was installed" then all good 👍

❌ If the command xcode-select --install fails try again: sometimes the Apple servers are overloaded.

❌ If you see the message "Xcode is not currently available from the Software Update server", you need to update the software update catalog:

sudo softwareupdate --clear-catalog

Once this is done, you can try to install again.

Homebrew

1. Install:

On Mac, you need to install Homebrew which is a Package Manager. It will be used as soon as we need to install some software. To do so, open your Terminal and run:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This will ask for your confirmation (hit Enter) and your macOS user account password (the one you use to log in when you reboot your Macbook). :warning: When typing a password in the Terminal, you will not get a visual feedback (something like *****), this is normal!! Type the password and confirm by typing Enter.

🛠 If you get a Error: Not a valid ref: refs/remotes/origin/master error

The full error would be:

Error: Not a valid ref: refs/remotes/origin/master :
fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree.

Run the following commands to solve it:

rm -fr $(brew --repo homebrew/core)  # because you can't `brew untap homebrew/core`
brew tap homebrew/core

If you already have Homebrew, it will tell you so, that's fine, go on.

2. Make sure you are on the latest version:

brew update
🛠 If you get a /usr/local must be writable error

Just run this:

sudo chown -R $USER:admin /usr/local
brew update

3. Then install some useful software:

Proceed running the following in the terminal (you can copy / paste all the lines at once).

brew upgrade git         || brew install git
brew upgrade gh          || brew install gh
brew upgrade wget        || brew install wget
brew upgrade imagemagick || brew install imagemagick
brew upgrade jq          || brew install jq
brew upgrade openssl     || brew install openssl
brew upgrade tree        || brew install tree
brew upgrade ncdu        || brew install ncdu
brew upgrade xz          || brew install xz
brew upgrade readline    || brew install readline

Chrome - your browser

Install the Google Chrome browser if you haven't got it already and set it as a default browser.

Follow the steps for your system from this link 👉 Install Google Chrome

Why Chrome?

We recommend to use it as your default browser as it's most compatible with testing or running your code, as well as working with Google Cloud Platform. Another alternative is Firefox, however we don't recommend using other tools like Opera, Internet Explorer or Safari.

Visual Studio Code

Installation

Let's install Visual Studio Code text editor.

Copy (Cmd + C) the command below then paste it in your terminal (Cmd + V):

brew install --cask visual-studio-code

Then launch VS Code by running the following command in your terminal:

code

✔️ If a VS Code window has just opened, you're good to go 👍

❌ Otherwise, please contact a teacher

VS Code Extensions

Installation

Let's install some useful extensions to VS Code.

code --install-extension ms-vscode.sublime-keybindings
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension MS-vsliveshare.vsliveshare
code --install-extension ms-python.python
code --install-extension KevinRose.vsc-python-indent
code --install-extension ms-python.vscode-pylance
code --install-extension ms-toolsai.jupyter

Here is a list of the extensions you are installing:

Live Share configuration

Visual Studio Live Share is a VS Code extension which allows you to share the code in your text editor for debugging and pair-programming: let's set it up!

Launch VS Code from your terminal by typing code and pressing Enter.

Click on the little arrow at the bottom of the left bar 👇

VS Code Live Share

  • Click on the "Share" button, then on "GitHub (Sign in using GitHub account)".
  • A popup appears asking you to sign in with GitHub: click on "Allow".
  • You are redirected to a GitHub page in you browser asking you to authorize Visual Studio Code: click on "Continue" then "Authorize github".
  • VS Code may display additional pop-ups: close them by clicking "OK".

That's it, you're good to go!

Oh-my-zsh

Let's install the zsh plugin Oh My Zsh.

In a terminal execute the following command:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

If asked "Do you want to change your default shell to zsh?", press Y

At the end your terminal should look like this:

Ubuntu terminal with OhMyZsh

✔️ If it does, you can continue 👍

❌ Otherwise, please ask for a teacher

direnv

direnv is a shell extension. It makes it easy to deal with per project environment variables. This will be useful in order to customize the behavior of your code.

brew install direnv
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc

GitHub CLI

CLI is the acronym of Command-line Interface.

In this section, we will use GitHub CLI to interact with GitHub directly from the terminal.

It should already be installed on your computer from the previous commands.

First in order to login, copy-paste the following command in your terminal:

⚠️ DO NOT edit the email

gh auth login -s 'user:email' -w

gh will ask you few questions:

What is your preferred protocol for Git operations? With the arrows, choose SSH and press Enter. SSH is a protocol to log in using SSH keys instead of the well known username/password pair.

Generate a new SSH key to add to your GitHub account? Press Enter to ask gh to generate the SSH keys for you.

If you already have SSH keys, you will see instead Upload your SSH public key to your GitHub account? With the arrows, select your public key file path and press Enter.

Enter a passphrase for your new SSH key (Optional). Type something you want and that you'll remember. It's a password to protect your private key stored on your hard drive. Then press Enter.

Title for your SSH key. You can leave it at the proposed "GitHub CLI", press Enter.

You will then get the following output:

! First copy your one-time code: 0EF9-D015
- Press Enter to open github.com in your browser...

Select and copy the code (0EF9-D015 in the example), then press Enter.

Your browser will open and ask you to authorize GitHub CLI to use your GitHub account. Accept and wait a bit.

Come back to the terminal, press Enter again, and that's it.

To check that you are properly connected, type:

gh auth status

✔️ If you get Logged in to github.com as <YOUR USERNAME> , then all good 👍

❌ If not, contact a teacher.

Dotfiles

There are three options, choose one:

I already attended Web Development (FullStack) bootcamp at Le Wagon on the same laptop

This means that you already forked the GitHub repo lewagon/dotfiles, but at that time the configuration was maybe not ready for the new Data Science bootcamp.

Open your terminal and go to your dotfiles project:

cd ~/code/<YOUR_GITHUB_NICKNAME>/dotfiles
code . # Open it in VS Code

In VS Code, open the zshrc file. Replace its content with the newest version of that file that we provide. Save to disk.

Back to the terminal, run a git diff and ask a TA to come and check about this configuration change. You should see stuff about Python and pyenv.

Once this is good, commit and push your changes:

git add zshrc
git commit -m "Update zshrc for Data Science bootcamp"
git push origin master

OR

I did not attend the Web Dev bootcamp at Le Wagon

Hackers love to refine and polish their shell and tools. We'll start with a great default configuration provided by Le Wagon, stored on GitHub. As your configuration is personal, you need your own repository storing it, so you first need to fork it to your GitHub account.

➡️ Click here to fork the lewagon/dotfiles repository to your account (you'll need to click again on your picture to confirm where you do the fork).

Forking means that it will create a new repo in your GitHub account, identical to the original one. You'll have a new repository on your GitHub account, your_github_username/dotfiles. We need to fork because each of you will need to put specific information (e.g. your name) in those files.

Open your terminal and run the following command:

export GITHUB_USERNAME=`gh api user | jq -r '.login'`
echo $GITHUB_USERNAME

You should see your GitHub username printed. If it's not the case, stop here and ask for help. There seems to be a problem with the previous step (gh auth).

Time to fork the repo and clone it on your laptop:

mkdir -p ~/code/$GITHUB_USERNAME && cd $_
gh repo fork lewagon/dotfiles --clone

Run the dotfiles installer.

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh install.sh

Check the emails registered with your GitHub Account. You'll need to pick one at the next step:

gh api user/emails | jq -r '.[].email'

Run the git installer:

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh git_setup.sh

☝️ This will prompt you for your name (FirstName LastName) and your email. :warning: You need to put one of the emails listed above thanks to the previous gh api ... command. If you don't do that, Kitt won't be able to track your progress. 💡 Select the @users.noreply.github.com address if you don't want your email to appear in public repositories you may contribute to.

Please now quit all your opened terminal windows.

OR

I already attended Web Development (FullStack) bootcamp at Le Wagon but I have a new laptop

Open your terminal and run the following command:

export GITHUB_USERNAME=`gh api user | jq -r '.login'`
echo $GITHUB_USERNAME

You should see your GitHub username printed. If it's not the case, stop here and ask for help. There seems to be a problem with the previous step (gh auth).

Time to fork the repo and clone it on your laptop:

mkdir -p ~/code/$GITHUB_USERNAME && cd $_
gh repo fork lewagon/dotfiles --clone

Run the dotfiles installer.

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh install.sh

Check the emails registered with your GitHub Account. You'll need to pick one at the next step:

gh api user/emails | jq -r '.[].email'

Run the git installer:

cd ~/code/$GITHUB_USERNAME/dotfiles && zsh git_setup.sh

☝️ This will prompt you for your name (FirstName LastName) and your email. :warning: You need to put one of the emails listed above thanks to the previous gh api ... command. If you don't do that, Kitt won't be able to track your progress. 💡 Select the @users.noreply.github.com address if you don't want your email to appear in public repositories you may contribute to.

Please now quit all your opened terminal windows.

Installing Python (with pyenv)

Uninstall conda

As we are using pyenv to install and manage our Python version, we need to uninstall conda, another package manager you may have on your machine if you previously installed Anaconda. Thus, we are preventing any possible Python version issue later.

Check if you have conda installed on your machine:

conda list

If you have zsh: command not found: conda, you can skip the uninstall of conda and jump to the Install pre-requisites section.

conda uninstall instructions
  • Install the Anaconda-Clean package from your terminal and run the cleaning
conda install anaconda-clean
anaconda-clean --yes
  • Remove every Anaconda directories
rm -rf ~/anaconda2
rm -rf ~/anaconda3
rm -rf ~/.anaconda_backup
rm -rf ~/opt
  • Remove Anaconda path from your .bash_profile
    • Open the file with code ~/.bash_profile
    • If the file opens find the line matching the following pattern export PATH="/path/to/anaconda3/bin:$PATH" and delete the line
    • Save the file with CMD + s
  • Restart your terminal with exec zsh
  • Remove Anaconda initialization from your .zshrc:
    • Open the file with code ~/.zshrc
    • Remove the code lines starting from >>> conda initialize >>> to <<< conda initialize <<<

Install pre-requisites

Before installing Python, please check your xz version with:

brew info xz

It should be more than 5.2.0, if not you should run:

sudo rm -rf /usr/local/opt/xz
brew upgrade
brew install xz

Then run:

brew install readline

Install pyenv

macOS comes with an outdated version of Python that we don't want to use. You might already have installed Anaconda or something else to tinker with Python and Data Science packages. All of this does not really matter as we are going to do a professional setup of Python where you'll be able to switch which version you want to use whenever you type python in the terminal.

First let's install pyenv with the following Terminal command:

brew install pyenv
exec zsh

Install Python

If your computer uses Apple Silicon, expand the paragraph below and go through it. Otherwise ignore it.

👉  Setup for Apple Silicon 👈

We need to add the following environment variables in order to install python:

export LDFLAGS="-L/opt/homebrew/lib"; export CPPFLAGS="-I/opt/homebrew/include"

Let's install the latest stable version of Python supported by Le Wagon's curriculum:

pyenv install 3.10.6

This command might take a while, this is perfectly normal. Don't hesitate to help other students seated next to you!

🛠 Troubleshooting `pyenv` not found

If you encounter an error Command 'pyenv' not found: execute the following line:

source ~/.zprofile

Then try to install Python again:

pyenv install 3.10.6

If pyenv is still not found, contact a teacher.

🛠 Troubleshooting `zlib`

If you encounter an error installing Python with pyenv about zlib:

zipimport.ZipImportError: can't decompress data; zlib not available

Install zlib with:

brew install zlib
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"

Then try to install Python again:

pyenv install 3.10.6

It could raise another error about bzip2, you can ignore it and continue to the next step.


OK once this command is complete, we are going to tell the system to use this version of Python by default. This is done with:

pyenv global 3.10.6
exec zsh

To check if this worked, run python --version. If you see 3.10.6, perfect! If not, ask a TA that will help you debug the problem thanks to pyenv versions and type -a python (python should be using the .pyenv/shims version first).

Python Virtual Environment

Before we start installing relevant Python packages, we will isolate the setup for the Bootcamp into a dedicated virtual environment. We will use a pyenv plugin called pyenv-virtualenv.

First let's install this plugin:

git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
exec zsh

Let's create the virtual environment we are going to use during the whole bootcamp:

pyenv virtualenv 3.10.6 lewagon

Let's now set the virtual environment with:

pyenv global lewagon

Great! Anytime we'll install Python package, we'll do it in that environment.

Python packages

Now that we have a pristine lewagon virtual environment, it's time to install some packages in it.

First, let's upgrade pip, the tool to install Python Packages from pypi.org. In the latest terminal where the virtualenv lewagon is activated, run:

pip install --upgrade pip

Then let's install some packages for the first weeks of the program:

If your computer uses Apple Silicon, expand the paragraph below and go through it. Otherwise ignore it.

👉  Setup for Apple Silicon 👈
pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_silicon.txt

If your computer uses Apple Intel, expand the paragraph below and go through it. Otherwise ignore it.

👉  Setup for Apple Intel 👈
pip install -r https://raw.githubusercontent.com/lewagon/data-setup/master/specs/releases/apple_intel.txt

jupyter notebook extensions

Pimp your jupyter notebooks with awesome extensions:

# install nbextensions
jupyter contrib nbextension install --user
jupyter nbextension enable toc2/main
jupyter nbextension enable collapsible_headings/main
jupyter nbextension enable spellchecker/main
jupyter nbextension enable code_prettify/code_prettify

Custom CSS

Improve the display of the details disclosure elements in your notebooks.

Open custom/custom.css in the config directory:

cd $(jupyter --config-dir)
mkdir -p custom
touch custom/custom.css
code custom/custom.css

Edit custom.css with:

summary {
    cursor: pointer;
    display:list-item;
}
summary::marker {
    font-size: 1em;
}

You can close VS Code.

jupyter check up

Let's reset your terminal:

exec zsh

Now, check you can launch a notebook server on your machine:

jupyter notebook

Your web browser should open on a jupyter window:

jupyter.png

Click on New:

jupyter_new.png

A tab should open on a new notebook:

jupyter_notebook.png

nbextensions check up

Perform a sanity check for jupyter notebooks nbextensions. Click on Nbextensions:

jupyter_nbextensions.png

Untick "disable configuration for nbextensions without explicit compatibility" then check that at least all nbextensions circled in red are enabled:

nbextensions.png

You can close your web browser then terminate the jupyter server with CTRL + C.

Python setup check up

Check your Python version with the following commands:

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/python_checker.sh)" 3.10.6

Run the following command to check if you successfully installed the required packages:

zsh -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.sh)"

Now run the following command to check if you can load these packages:

python -c "$(curl -fsSL https://raw.githubusercontent.com/lewagon/data-setup/master/checks/pip_check.py)"

Make sure you can run Jupyter:

jupyter notebook

And open a Python 3 notebook.

Make sure that you are running the correct python version in the notebook. Open a cell and run :

import sys; sys.version

Here you have it! A complete python virtual env with all the third-party packages you'll need for the whole bootcamp.

DBeaver

Download and install DBeaver, a free and open source powerful tool to connect to any database, explore the schema and even run SQL queries.

Docker 🐋

Docker is an open platform for developing, shipping, and running applications.

if you already have Docker installed on your machine please update with the latest version

Install Docker

Go to Docker website and choose your operating system:

Then follow the setup instructions, you are going to install a desktop application.

Once done and launched, check Docker is up and running:

docker info

You should get:

gcloud CLI

Before Setting up our Google Cloud Platform account let's configure the gcloud CLI (A command line interface for Google Cloud Platform). Run the below and follow the terminal prompts to update your $PATH and enable shell command completion for the .zshrc file:

brew install --cask google-cloud-sdk

Then you can:

$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/install.sh

Google Cloud Platform setup

GCP is a cloud solution that you are going to use in order to deploy your Machine Learning-based products to production.

🚨 If you are a student of the Part-Time Bootcamp, SKIP THIS SECTION FOR NOW! GCP offers $300 worth of free credits for a duration of 3 months. You do not want to activate your GCP account too soon 🙅‍♂️

Project setup

  • Go to Google Cloud and create an account if you do not already have one
  • In the Cloud Console, on the project list, select or create a Cloud project

  • Give it a name such as Wagon Bootcamp for example
  • Notice the ID automatically created for the project, e.g. wagon-bootcamp-123456

Account language

In order to facilitate the following of the instructions during the bootcamp, open your GCP account preferences:

https://myaccount.google.com/language

If the preferred language is not:

  • English
  • United States

Then switch the language to english:

  • Click on the edit pen logo
  • Select English
  • Select United States
  • Click on Select

Billing account

You will now link your account to your credit card. This step is required or you will not be able to use the services provided by GCP. Do not worry, you will be able to consume most GCP services through free credits throughout the bootcamp.

  • Click on Billing
  • Click on MANAGE BILLING ACCOUNTS
  • Click on ADD BILLING ACCOUNT
  • Give a name to your billing account, e.g. My Billing Account
  • Click on "I have read..." and agree the to the terms of service
  • Click on CONTINUE
  • Select your account type: Individual
  • Fill your name and address

You should see that you have a free credit of "$300 credits over the next 90days".

  • Click on card details
  • Enter your credit card info
  • Click on START MY FREE TRIAL

Once this is done, verify that your billing account is linked to your GCP project.

  • Select your project
  • Go to Billing
  • Select LINK A BILLING ACCOUNT
  • Select My Billing Account
  • Click on SET ACCOUNT

You should now see:

Free trial status: $300 credit and 91 days remaining - with a full account, you'll get unlimited access to all of Google Cloud Platform.
👉 If you do not own a credit card 👈

If you do not own a credit card, an alternative is to setup a Revolut account. Revolut is a financial app that will allow you to create a virtual credit card linked to your mobile phone billing account.

Skip this step if you own a credit card and use your credit card for the setup.

Download the Revolut app, or go to revolut and follow the steps to download the app (enter your mobile phone number and click on Get Started).

  • Open the Revolut app
  • Enter your mobile phone number
  • Enter the verification code received by SMS
  • The app will ask for your country, address, first and last name, date of birth, email address
  • The app will also ask for a selfie and request your profession
  • The app will require a photo of your identification card or passport

Once this is done, select the standard (free) plan. No need to add the card to Apple pay, or ask for a the delivery of a physical card, or add money securely.

You now have a virtual card which we will use for the GCP setup.

In the main view of the Revolut the app

  • Click on Ready to use
  • Click on the card
  • Click on Show card details
  • Note down the references of the virtual credit card and use them in order to proceed with the GCP setup
👉 If you receive an email from Google saying "Urgent: your billing account XXXXXX-XXXXXX-XXXXXX has been suspended" 👈

This may happen especially in case you just setup a Revolut account.

  • Click on PROCEED TO VERIFICATION
  • You will be asked to send a picture of your credit card (only the last 4 digits, no other info)
  • In case you used Revolut, you can send a screenshot of your virtual credit card (do not forget to remove the validity date from the screenshot)
  • Explain that you are attending the Le Wagon bootcamp, do not own a credit card, and have just created a Revolut account in order to setup GCP for the bootcamp using a virtual credit card

You may receive a validation or requests for more information within 30 minutes.

Once the verification goes through, you should receive an email stating that "Your Google Cloud Platform billing account XXXXXX-XXXXXX-XXXXXX has been fully reinstated and is ready to use.".

Enabling GCP services

  • Make sure that billing is enabled for your Google Cloud project

ℹ️ You have a $300 credit to use for Google Cloud resources, which will be more than enough for the bootcamp.

Configure Cloud sdk

  • Authenticate the gcloud CLI with the google account you used for GCP
gcloud auth login
  • Login to your Google account on the new tab opened in your web browser
  • List your active account and check your email address you used for GCP is present
gcloud auth list
  • Set your current project (replace PROJECT_ID with the ID of your project, e.g. wagon-bootcamp-123456)
gcloud config set project PROJECT_ID
  • List your active account and current project and check your project is present
gcloud config list

Create a service account key 🔑

Now that you have created a GCP account and a project (identified by its PROJECT_ID), we are going to configure the actions (API calls) that you want to allow your code to perform.

🤔 Why do we need a service account key ?

You have created a GCP account linked to your credit card. Your account will be billed according to your usage of the resources of the Google Cloud Platform. The billing will occur if you consume anything once the free trial is over, or if you exceed the amount of spending allowed during the free trial.

In your GCP account, you have created a single GCP project, identified by its PROJECT_ID. The GCP projects allow you to organize and monitor more precisely how you consume the GCP resources. For the purpose of the bootcamp, we are only going to create a single project.

Now, we need a way to tell which resources within a GCP project our code will be allowed to consume. Our code consumes GCP resources through API calls.

Since API calls are not free, it is important to define with caution how our code will be allowed to use them. During the bootcamp this will not be an issue and we are going to allow our code to use all the API of GCP without any restrictions.

In the same way that there may be several projects associated with a GCP account, a project may be composed of several services (any bundle of code, whatever its form factor, that requires the usage of GCP API calls in order to fulfill its purpose).

GCP requires that the services of the projects using API calls are registered on the platform and their credentials configured through the access granted to a service account.

For the moment we will only need to use a single service and will create the corresponding service account.

Since the service account is what identifies your application (and therefore your GCP billing account and ultimately your credit card), you are going to want to be cautious with the next steps.

⚠️ Do not share you service account json file 🔑 ⚠️ Do not store it on your desktop, do not store it in your git codebase (even if your git repository is private), do not let it by the coffee machine, do not send it as a tweet.

Go to the Service Accounts page

Navigate to the GCP service accounts page at this link.

  • Select your project in the list of recent projects if asked to.
  • If not asked, make sure the right project is selected in the Project selecter list at the top of the page.

An alternate way to navigate to the Service Accounts page is from the following:

01 Go to Service Accounts

Create a service account

  • Click on CREATE SERVICE ACCOUNT.

    02 Create Service Account
  • Give your service account a name, an id and a description, and click on CREATE AND CONTINUE.

    03 Name the service account
  • Click on Select a role and choose Basic then Owner, which gives the service account full access to all resources of your GCP project.

    04 Add BigQuery Job User
  • Click on the blue DONE button at the bottom of this window. We don't need to worry about the section Grant your users access to this service account.

    04 Done

Create a json key 🔑 for this service account

  • On the service accounts page, click on the email address of the newly created service account.

    05 Select the service account
  • Click on the KEYS tab at the top of the page.

    06 Go to Keys
  • Click on ADD KEY then Create new key.

    07 Add Key
  • Select JSON and click on CREATE.

    08 Choose JSON and Create
  • The browser has now saved the service account json file 🔑 in your downloads directory (it is named according to your service account name, something like le-wagon-data-123456789abc.json).

  • Store the service account json file somewhere you'll remember, for example:

/Users/MACOS_USERNAME/code/GITHUB_NICKNAME/gcp/SERVICE_ACCOUNT_JSON_FILE_CONTAINING_YOUR_SECRET_KEY.json
  • Store the absolute path to the JSON file as an environment variable:
echo 'export GOOGLE_APPLICATION_CREDENTIALS=/path/to/the/SERVICE_ACCOUNT_JSON_FILE_CONTAINING_YOUR_SECRET_KEY.json' >> ~/.zshrc

Note: every time you run this command, it will add this line to your zshrc file regardless of whether you already have it. If you made a mistake and need to fix it, preferably open the file and edit the line!

You can do so by running

code ~/.zshrc

in the Terminal! 😄

ℹ️ How to find the absolute path of a file? You can drag and drop the file in your terminal.

Restart your terminal and run:

echo $GOOGLE_APPLICATION_CREDENTIALS

The ouptut should be the following:

/some/absolute/path/to/your/gcp/SERVICE_ACCOUNT_JSON_FILE_CONTAINING_YOUR_SECRET_KEY.json

Now let's verify that the path to your service account json file is correct:

cat $(echo $GOOGLE_APPLICATION_CREDENTIALS)

👉 This command should display the content of your service account json file. If it does not, ask for a TA 🙏

Your code and utilities are now able to access the resources of your GCP account.

Let's proceed with the final steps of configuration...

  • List the service accounts associated to your active account and current project
gcloud iam service-accounts list
  • Retrieve the service account email address, e.g. SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
  • List the roles of the service account from the cli (replace PROJECT_ID and SERVICE_ACCOUNT_EMAIL)
gcloud projects get-iam-policy PROJECT_ID \
--flatten="bindings[].members" \
--format='table(bindings.role)' \
--filter="bindings.members:SERVICE_ACCOUNT_EMAIL"
  • You should see that your service account has a role of roles/owner
Troubleshooting

🏁 You are done with the GCP setup!

Kitt

⚠️ If you have received an email from Le Wagon inviting you to sign up on Kitt (our learning platform), you can safely skip this step. Instead, please follow the instructions in the email you received if you haven't done so already.

If you are unsure about what to do, you can follow this link. If you are already logged in, you can safely skip this section. If you are not logged in, click on Enter Kitt as a Student. If you manage to login, you can safely skip this step. Otherwise ask a teacher whether you should have received an email or follow the instructions below.

Register as a Wagon alumni by going to kitt.lewagon.com/onboarding. Select your batch, sign in with GitHub and enter all your information.

Your teacher will then validate that you are indeed part of the batch. You can ask them to do it as soon as you completed the registration form.

Once the teacher has approved your profile, go to your email inbox. You should have 2 emails:

  • One from Slack, inviting you to the Le Wagon Alumni slack community (where you'll chat with your buddies and all the previous alumni). Click on Join and fill the information.
  • One from GitHub, inviting you to lewagon team. Accept it otherwise you won't be able to access the lecture slides.

Slack

Slack is a communication platform pretty popular in the tech industry.

Installation

Download the Slack app and install it.

⚠️ If you are already using Slack in your browser, please download and install the desktop app which is fully featured.

Settings

Launch the app and sign in to lewagon-alumni organization.

Make sure you upload a profile picture 👇

How to upload a profile picture on Slack

The idea is that you'll have Slack open all day, so that you can share useful links / ask for help / decide where to go to lunch / etc.

To ensure that everything is working fine for video calls, let's test your camera and microphone:

  • Open the Slack app
  • Click your profile picture in the top right.
  • Select Preferences from the menu.
  • Click Audio & video in the left-side column.
  • Below Troubleshooting, click Run an audio, video and screensharing test. The test will open in a new window.
  • Check that your preferred speaker, microphone and camera devices appear in the drop-down menus, then click Start test.

Check microphone and webcam with Slack

✔️ When the test is finished, you should see green "Succeed" messages at least for your microphone and camera. 👍

❌ If not, contact a teacher.

You can also install Slack app on your phone and sign in lewagon-alumni!

macOS settings

Security

It is mandatory that you protect your session behind a password. If it is not already the case, go to  > System Settings... > Users & Groups and change your account password. You should also go to  > System Settings... > Lock Screen. You should require a password 5 seconds after screen saver begins or display is turned off.

You can also go to  > System Settings... > Desktop & Dock and click on the Hot Corners... button at the bottom left. Choose for the bottom right corner to start the screen saver. That way, when you leave your desk, you can quickly lock you screen by putting your mouse in the bottom right corner. 5 seconds after, your MacBook will be locked and will ask for a password to get back on the session.

Keyboard

As you become a programmer, you'll understand that leaving the keyboard takes a lot of time, so you'll want to minimize using the trackpad or the mouse. Here are a few tricks on macOS to help you do that.

Keyboard speed

Go to  > System Settings... > Keyboard. Set Key repeat rate to the fastest position (to the right) and Delay until repeat to the shortest position (also to the right).

macOS For hackers

Read this script and cherry-pick some stuff you think will suit you. For instance, you can type in the terminal this one:

# Expanding the save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true

# Save screenshots to the Desktop (or elsewhere)
defaults write com.apple.screencapture location "${HOME}/Desktop"

# etc..

Pin apps to your dock

You are going to use most of the apps you've installed today really often. Let's pin them to your dock so that they are just one click away!

To pin an app to your dock, launch the app, right-click on the icon in the taskbar to bring up the context menu and choose "Options" then "Keep in Dock".

How to pin an app to the taskbar in macOS

You must pin:

  • Your terminal
  • Your file explorer
  • VS Code
  • Your Internet browser
  • Slack
  • Zoom

(Bonus) Kata

If you are done with your setup, please ask around if some classmates need some help with theirs (macOS, Linux, Windows). We will have our first lectures at 2pm and will talk about the Setup you just did + onboard you on Kitt.

If you don't have a lot of experience with git and GitHub, please (re-)watch this workshop (1.25 playback speed is fine).

If you do, then you can wait for the first lecture working on this Tic-Tac-Toe Kata