01 Getting Started - Observatorio-do-Trabalho-de-Pernambuco/documentation GitHub Wiki
This page covers essential information to help new contributors set up their environment and understand our documentation approach.
With Git already installed in your machine, make sure your user and email are configured:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"One of the easiest ways to interact with GitHub is through their official CLI. Make sure you install it following the steps in the official page.
With GitHub CLI installed you can clone the team repository with:
gh repo clone Observatorio-do-Trabalho-de-Pernambuco/infraestrutura-de-dadosThis session guides contributors on how to setup a local development environment.
In order to have a reproducible development environment for the team, uv is used to manage local Python environments. uv is a fast, dependency resolver and Python environment manager written in Rust.
First, install uv:
pip install uvMake sure the right Python version is installed using the following command:
uv python install 3.12To create a new project (pyproject.toml) with uv and Python 3.12:
uv venv --python 3.12
uv init --bare --name data-infrastructureInstall the desired Python libraries using uv add [lib-name]:
uv add jupyterlab ipykernel polars tqdm boto3 pyiceberg ruffThis command will add the packages to your pyproject.toml, update the uv.lock file, and sync your environment[5].
To activate the uv environment:
source .venv/bin/activate # For Unix/Mac
# or
.venv\Scripts\activate # For WindowsAlternatively, you can run commands directly using uv run:
uv run python main.pyTo open JupyterLab:
uv run jupyter labIf you already have a pyproject.toml, you can easily create a uv environment with the following commands:
uv venv
uv syncThe uv sync command will:
- Find or download an appropriate Python version to use
- Create and set up your environment in the
.venvfolder (if it doesn't exist) - Build your complete dependency list and write to your
uv.lockfile - Sync your project dependencies into your virtual environment
| Operation | Command | Description |
|---|---|---|
| Add a package | uv add |
Adds the package to pyproject.toml, uv.lock, and syncs your environment |
| Remove a package | uv remove |
Removes the package from pyproject.toml, uv.lock, and syncs your environment |
| Upgrade a package | uv sync --upgrade-package |
Upgrades the package in your uv.lock file and syncs your environment |
| Upgrade all packages | uv lock --upgrade |
Upgrades all packages in your uv.lock file (according to constraints in pyproject.toml) |
| What | Command | Explanation |
|---|---|---|
| Create virtual environment | uv venv |
Creates a virtual environment in .venv directory |
| Create with specific Python | uv venv --python 3.11 |
Creates a virtual environment with Python 3.11 |
| Install dependencies | uv sync |
Installs dependencies from pyproject.toml to your environment |
| Run a command | uv run |
Runs a command in the virtual environment |
ruff can be used as a linter and formatter, replacing libraries like flake8, isort, and black. It's suggested that you install ruff in your local environment, separate from the uv environment created above.
pip install ruffThis way you can run it with:
ruff --helpIf you want to execute using the uv environment, use:
uv run ruff --helpYou can define the behavior for ruff by specifying configuration values in the pyproject.toml:
[tool.ruff]
line-length = 79
[tool.ruff.format]
quote-style = "single"
indent-style = "space"
docstring-code-format = true
docstring-code-line-length = 30One of the features from ruff is code formatting, replacing black with its same default rules:
ruff format [target_file.py]To check if your code follows PEP8 conventions:
ruff checkYou'll see a list of conventions your code is breaking. To automatically fix issues:
ruff check --fix