This document is a guide for setting up your work environment, you will find here the software I personally use on a day-to-day basis.
VS Code is an IDE where you can write and test code at the same time.
I personally prefer VS Code over PyCharm as it has better performance and VS Code has an extension for almost everything. Also VSCode is entirely open-source whilst you would need PyCharm Professional(~$200/year) to debug your code in a Docker container for instance.
- Python
- CodeMap
- Docker
- Makefile tools
- Remote - Containers
- Remote - WSL
- markdownlint
- Markdown Preview Mermaid Support
- Pytest IntelliSense
- Thunderclient
- YAML
Then select Python > Module and enter your test name (generally the name of the function you want to test) or module name if you want to run an entire file.
This step creates a launch.json
file under the .vscode
directory in your current folder.
{
"version": "0.2.0",
"configurations": [
{
"name": "test_hello_world",
"type": "python",
"request": "launch",
"module": "unittest",
"args": ["path_to_your_module.class_name.test_name"],
"python": "/path/to/your/python/interpreter",
"justMyCode": false, // Debug only user-written code
"env": {"ENVIRONMENT_VARIABLE": ""}
}
]
}
Alternatively you could use the Pytest IntelliSense extension that gives you a much more user friendly interface.
When running the remote container as root user, pytest might crash because the default python interpreter has changed. In this case you may have to specify the python interpreter path in .vscode/settings.json
such as:
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.defaultInterpreterPath": "/path/to/your/python/interpreter"
}
First you will need to install the Remote - Containers extension. Then click on the double arrows at the bottom left of the window.
and select Reopen in Container
. This step will generate a devcontainer.json
file in a .devcontainer
directory.
You might as well set the following key/value pair in the .devcontainer.json
to resolve permission issues.
"remoteUser": "root"
By default the extensions you install in a remote container will be lost after you rebuild it. To avoid having to reinstall everything you can specify your extensions in .devcontainer
"customizations": {
"vscode": {
"extensions": [
"Cameron.vscode-pytest",
"ms-python.python",
"oleg-shilo.codemap"
]
}
}
That task is done using the Add to devcontainer.json
option.
$ python -m venv venv # This command creates a new environment
$ . ./venv/bin/activate # To use the python virtual env
Pro tip: Don't forget to upgrade pip in your virtual environment with
pip install -U pip
An extremely fast Python linter and code formatter
Create a precommit-config.yaml
with the following content:
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.14
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
Top set up the pre-commit hook:
# Install the libraries
pip install ruff pre-commit
# Configure pre-commit hook for the given repo
pre-commit install
# Run code against hooks
pre-commit run
Whether you deploy to containers or not, containers make a great development environment because you can:
Develop with a consistent, easily reproducible toolchain on the same operating system you deploy to. Quickly swap between different, separate development environments and safely make updates without worrying about impacting your local machine. Make it easy for new team members / contributors to get up and running in a consistent development environment. Try out new technologies or clone a copy of a code base without impacting your local setup.
"Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration." (https://docs.docker.com/compose/)
Windows Subsystem for Linux is a compatibility layer for running Linux binary executables natively on Windows.
You will also need to install Ubuntu(or any other Linux distributions) from the Microsoft app store in order to access the Linux terminal on Windows.
Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes.
To install oh-my-zsh you will need to install ZSH first:
sudo apt update && sudo apt install zsh
Type 3x faster in your terminal thanks to auto-suggestion based on your history
https://www.freecodecamp.org/news/git-ssh-how-to/
- Run Github Actions with act
- Run Gitlab CICD with GitLab Runner
https://www.cybertec-postgresql.com/en/postgresql-on-wsl2-for-windows-install-and-setup/
Pro tip: Also consider storing your passwords in ~/.pgpass
Mermaid is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically. I find it very useful for explaining convoluted workflows to colleagues.
An example of sequence diagram:
sequenceDiagram
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts <br/>prevail!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
k9s: For quick k8s cluster interaction (you can stop typing the time-consuming kubectl commands 😃)
popeye: Scans live Kubernetes cluster and reports potential issues with deployed resources and configurations