Skip to content

Commit

Permalink
Add basic Tiltfile for Python SDK local dev (#1819)
Browse files Browse the repository at this point in the history
https://tilt.dev/ is a powerful dev tool when using containers.

It can automatically restart containers and sync files between localhost
and container
  • Loading branch information
kaxil committed Mar 10, 2023
1 parent 5c56d20 commit ecf2d61
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python-sdk/.dockerignore
@@ -0,0 +1,13 @@
.coverage
.env
.git
.idea
.mypy_cache
.nox
.pytest_cache
__pycache__
docs
example_dags
mk
tests
dev/logs
6 changes: 6 additions & 0 deletions python-sdk/Makefile
Expand Up @@ -17,5 +17,11 @@ local: ## Set up local dev env
run-local-lineage-server: ## Run flask based local Lineage server
FLASK_APP=dev/local_flask_lineage_server.py flask run --host 0.0.0.0 --port 5050

tilt-up: ## Set up local dev env with Tilt
tilt up

tilt-down: ## Tear down local dev env with Tilt
tilt down

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-41s\033[0m %s\n", $$1, $$2}'
16 changes: 16 additions & 0 deletions python-sdk/Tiltfile
@@ -0,0 +1,16 @@
docker_compose('dev/docker-compose.yaml')

docker_build(
# Image name - must match the image in the docker-compose file
'astro-sdk-dev',
# Docker context
'.',
# Dockerfile
dockerfile = 'dev/Dockerfile',
live_update = [
sync('./pyproject.toml', '/usr/local/airflow/astro_sdk/pyproject.toml'),
sync('./src', '/usr/local/airflow/astro_sdk/src'),
run('cd /usr/local/airflow/astro_sdk && pip install -e ".[all,tests,doc]"', trigger='pyproject.toml'),
restart_container(),
]
)
2 changes: 2 additions & 0 deletions python-sdk/docs/development/DEVELOPMENT.md
Expand Up @@ -191,6 +191,8 @@ You can configure the Docker-based testing environment to test your DAG
* `make container target=restart` - To restart Scheduler & Triggerer containers
* `make container target=restart-all` - To restart all the containers
* `make container target=shell` - To run bash/shell within a container (Allows interactive session)
* `make tilt-up` - To run Tilt (https://tilt.dev/) for local development
* `make tilt-down` - To stop Tilt

1. Following ports are accessible from the host machine:

Expand Down

0 comments on commit ecf2d61

Please sign in to comment.