Skip to content

Commit 017ec9e

Browse files
committed
Add sample python package
1 parent 7bbdafa commit 017ec9e

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ A sample data stack running on Docker, that contains the following services:
66
- [Metabase](https://metabase.com/) (with its Postgres database)
77
- [MariaDB](https://mariadb.org/) (as main database)
88

9+
There is also a python package containing an example module, used by the
10+
example Airflow DAG.
11+
912
Run it with:
1013

1114
``` text

airflow-dags/example.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Code that goes along with the Airflow located at:
33
http://airflow.readthedocs.org/en/latest/tutorial.html
44
"""
5-
from airflow import DAG
6-
from airflow.operators.bash_operator import BashOperator
75
from datetime import datetime, timedelta
86

7+
from airflow import DAG
8+
from airflow.operators import BashOperator, PythonOperator
9+
10+
from python_package.example_module import some_function
11+
912

1013
default_args = {
1114
"owner": "airflow",
@@ -44,5 +47,12 @@
4447
dag=dag,
4548
)
4649

50+
t4 = PythonOperator(
51+
task_id="python_code",
52+
python_callable=some_function,
53+
dag=dag
54+
)
55+
4756
t2.set_upstream(t1)
4857
t3.set_upstream(t1)
58+
t4.set_upstream(t1)

docker-compose.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ services:
4444
- LOAD_EX=n
4545
- EXECUTOR=Local
4646
- POSTGRES_HOST=airflow-postgres
47+
- PYTHONPATH=${PYTHONPATH}:/opt
4748
volumes:
49+
# Airflow DAGS
4850
- ./airflow-dags:/usr/local/airflow/dags
4951
# Uncomment to include custom plugins
5052
# - ./airflow-plugins:/usr/local/airflow/plugins
53+
# Python packages
54+
- ./python_package:/opt/python_package/
5155
ports:
5256
- "8080:8080"
5357
command: webserver

python_package/__init__.py

Whitespace-only changes.

python_package/example_module.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def some_function():
2+
return "Hello, world!"

0 commit comments

Comments
 (0)