Prepare ML python dev evt

Prepare git & SSH config

Following https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification#ssh-commit-signature-verification

Edit the global config to use an ssh private key as signer (the public key must be added on Github as well)

git config --global --edit

[user]
        email = your@email.com
        name = Gregoire DAYET
        signingkey = ssh-ed25519 yourpubkey
[gpg]
        format = ssh
[commit]
        gpgsign = true

Not specified in the doc (and also applicable for Linux) but the ssh key must be added in the ssh-agent (eval “$(ssh-agent -s)") :

  1. For Apple :

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

  1. For Linux :

ssh-add ~/.ssh/id_ed25519

Finally create a .ssh/config file

Host github.com
    # This is a MacOS only option that looks for passwords for the keys
    # in the keychain.  Ignore if it is an unknown option.
    IgnoreUnknown UseKeyChain
    UseKeychain yes

    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ed25519

*Although if for pure SSH the config file allow to load automatically the ssh-agent, it seems to be ignored by git when signing commits. To force loading ssh-agent at the startup add in .zprofile or bashrc (temporary fix)*
ssh-add --apple-load-keychain > /dev/null 2>&1

If you get strange errors like :

error: Load key : error in libcrypto commit

It means that the ssh-agent is not loaded.

Don’t forget to use .gitignore files in the root of your repos (add it to the commit). https://gitignore.io is very useful

Install vscode, pyenv, pylint, some ML libs

I chose to learn ML applied python without conda.

brew install pyenv romkatv/powerlevel10k/powerlevel10k
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
pyenv install 3.10.7
pyenv global 3.10.7
curl -sSL https://install.python-poetry.org | python3 -
echo "path+=($HOME/.local/bin)" >> ~/.zprofile
source ~/.zprofile
mkdir $ZSH_CUSTOM/plugins/poetry
poetry completions zsh > $ZSH_CUSTOM/plugins/poetry/_poetry
poetry config virtualenvs.in-project true
#add poetry in zshrc plugin list
python -v venv venv
source venv/bin/activate
python -m ensurepip --upgrade
pip install pandas jupyter notebook pylint -U
brew install --cask visual-studio-code
code . 

VScode should normally take directly the good venv & python interpretor.

If not, open command palette : Python: Create Terminal or use poetry shell

Other scenarios

  1. Use conda environment by installing miniconda
  2. Use poetry for more extensive development