S3 (MinIO)
This guide shows you how to work with AWS S3 locally using MinIO and Python. This lab demonstrates how to integrate S3 libraries (Boto3, PyArrow, and Deltalake) for local data pipelines and object storage emulation.
Prerequisites
Section titled “Prerequisites”- Docker installed and running.
- Dev Containers extension installed (optional).
How to execute
Section titled “How to execute”-
Setup Environment:
Open VS Code in the project folder and execute this command in the Command Palette:
Terminal window > Dev Containers: Reopen in Container- Run the setup script to install tools and dependencies.
Terminal window scripts/setup.sh - Start Infrastructure: Launch the required containers.
Terminal window docker compose up -d
- Run the setup script to install tools and dependencies.
-
Run the Example:
Terminal window python main.pyUpload the README file to the bronze bucket:
Terminal window aws s3 cp README.md s3://bronze --profile minio
How to debug
Section titled “How to debug”-
main.py:
- Open: Open
main.py. - Breakpoints: Set breakpoints in the code.
- Run: Press
F5to start debugging.
- Open: Open
-
Tests:
- Open: Open a test file (e.g.,
tests/components/test_s3_boto.py). - Breakpoints: Set breakpoints in the test code.
- Run: Use the VS Code Testing tab and click the Debug Test icon next to the test you want to debug.
- Open: Open a test file (e.g.,
How to test
Section titled “How to test”- Individually: Run tests individually from the VS Code Testing tab.
- All tests: Run the automated script:
Terminal window scripts/run_tests.sh
Validate results
Section titled “Validate results”- Open:
Terminal window http://localhost:9001 - Credentials: Use the
MINIO_ROOT_USERandMINIO_ROOT_PASSWORDdefined in your.env. - Verify: Check the
bronzeandsilverbuckets to see the uploaded files.
- Run: List the contents of the bronze bucket:
Terminal window aws s3 ls s3://bronze --recursive
- Enter Shell:
Terminal window scripts/minio_cli.sh - Verify:
Terminal window mc ls data/bronze/ --recursive
Clean Up
Section titled “Clean Up”docker compose down -v