9. ● Разработан Spotify, открыт в 2012
● S3, Amazon, Hadoop, Spark, PostgreSQL…
● удобный retry механизм
● удобное определение зависимостей
● оповещения и хуки
● простой код
10.
11. class DownloadFileTask(luigi.Task):
def run(self):
url = f'https://s3.amazonaws.com/nyc-tlc/trip+data/file.csv'
self.output().makedirs() # in case path does not exist
response = requests.get(url, stream=True)
response.raise_for_status()
with self.output().open(mode='w') as f:
for chunk in response.iter_lines():
f.write('{}n'.format(chunk.decode('utf-8')))
def output(self):
return luigi.LocalTarget(os.path.join('data', self.filename))
12. class AggregateTaxiTripTask(luigi.Task):
def requires(self):
return DownloadTaxiTripTask()
def run(self):
with self.input().open() as input,
self.output().open('w') as output:
self.output().makedirs()
result = aggregate_taxi_data(input)
output.write(result)
def output(self):
return luigi.LocalTarget(os.path.join('data', f'nyc-taxi-agg.csv'))
15. Недостатки
● нет планировщика (есть координатор)
● проблемы с масштабированием
“In the future, Luigi might implement its own triggering. The dependency on crontab (or
any external triggering mechanism) is a bit awkward and it would be nice to avoid”
https://luigi.readthedocs.io/en/stable/execution_model.html#scheduler
16.
17. Apache Airflow
● Разработан AirBnB (Maxime Beauchemin)
● Мощный каркас для сложных пайплайнов
● Flask + Celery
18. Killer фичи
● Мощный Web UI с планировщиком, базой и логами
● Легко масштабируется за счет очередей (Celery/Dask)
● Хранилище конфигов (с шифрованием)
● Набор готовых операторов (Redshift, Hadoop, Bash, Python)