luigi README

The project's README from github.com/spotify/luigi. As one markdown file: README.md.

.. figure:: https://raw.githubusercontent.com/spotify/luigi/master/doc/luigi.png :alt: Luigi Logo :align: center

.. image:: https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fspotify%2Fluigi%2Fbadge&label=build&logo=none&%3Fref%3Dmaster&style=flat :target: https://actions-badge.atrox.dev/spotify/luigi/goto?ref=master

.. image:: https://img.shields.io/codecov/c/github/spotify/luigi/master.svg?style=flat :target: https://codecov.io/gh/spotify/luigi?branch=master

.. image:: https://img.shields.io/pypi/v/luigi.svg?style=flat :target: https://pypi.python.org/pypi/luigi

.. image:: https://img.shields.io/pypi/l/luigi.svg?style=flat :target: https://pypi.python.org/pypi/luigi

.. image:: https://readthedocs.org/projects/luigi/badge/?version=stable :target: https://luigi.readthedocs.io/en/stable/?badge=stable :alt: Documentation Status

Luigi is a Python (3.10, 3.11, 3.12, 3.13, 3.14 tested) package that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization, handling failures, command line integration, and much more.

Getting Started

Run pip install luigi to install the latest stable version from PyPI <https://pypi.python.org/pypi/luigi>. Documentation for the latest release <https://luigi.readthedocs.io/en/stable/>_ is hosted on readthedocs.

Run pip install luigi[toml] to install Luigi with TOML-based configs <https://luigi.readthedocs.io/en/stable/configuration.html>__ support.

For the bleeding edge code, pip install git+https://github.com/spotify/luigi.git. Bleeding edge documentation <https://luigi.readthedocs.io/en/latest/>__ is also available.

Background

The purpose of Luigi is to address all the plumbing typically associated with long-running batch processes. You want to chain many tasks, automate them, and failures will happen. These tasks can be anything, but are typically long running things like Hadoop <http://hadoop.apache.org/>_ jobs, dumping data to/from databases, running machine learning algorithms, or anything else.

There are other software packages that focus on lower level aspects of data processing, like Hive <http://hive.apache.org/>, Pig <http://pig.apache.org/>, or Cascading <http://www.cascading.org/>. Luigi is not a framework to replace these. Instead it helps you stitch many tasks together, where each task can be a Hive query <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.hive.html>, a Hadoop job in Java <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.hadoop_jar.html>, a Spark job in Scala or Python <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.spark.html>, a Python snippet, dumping a table <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.sqla.html>_ from a database, or anything else. It's easy to build up long-running pipelines that comprise thousands of tasks and take days or weeks to complete. Luigi takes care of a lot of the workflow management so that you can focus on the tasks themselves and their dependencies.

You can build pretty much any task you want, but Luigi also comes with a toolbox of several common task templates that you use. It includes support for running Python mapreduce jobs <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.hadoop.html>_ in Hadoop, as well as Hive <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.hive.html>, and Pig <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.pig.html>, jobs. It also comes with file system abstractions for HDFS <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.hdfs.html>_, and local files that ensures all file system operations are atomic. This is important because it means your data pipeline will not crash in a state containing partial data.

Visualiser page

The Luigi server comes with a web interface too, so you can search and filter among all your tasks.

.. figure:: https://raw.githubusercontent.com/spotify/luigi/master/doc/visualiser_front_page.png :alt: Visualiser page

Dependency graph example

Just to give you an idea of what Luigi does, this is a screen shot from something we are running in production. Using Luigi's visualiser, we get a nice visual overview of the dependency graph of the workflow. Each node represents a task which has to be run. Green tasks are already completed whereas yellow tasks are yet to be run. Most of these tasks are Hadoop jobs, but there are also some things that run locally and build up data files.

.. figure:: https://raw.githubusercontent.com/spotify/luigi/master/doc/user_recs.png :alt: Dependency graph

Philosophy

Conceptually, Luigi is similar to GNU Make <http://www.gnu.org/software/make/>_ where you have certain tasks and these tasks in turn may have dependencies on other tasks. There are also some similarities to Oozie <http://oozie.apache.org/>_ and Azkaban <https://azkaban.github.io/>_. One major difference is that Luigi is not just built specifically for Hadoop, and it's easy to extend it with other kinds of tasks.

Everything in Luigi is in Python. Instead of XML configuration or similar external data files, the dependency graph is specified within Python. This makes it easy to build up complex dependency graphs of tasks, where the dependencies can involve date algebra or recursive references to other versions of the same task. However, the workflow can trigger things not in Python, such as running Pig scripts <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.pig.html>_ or scp'ing files <https://luigi.readthedocs.io/en/latest/api/luigi.contrib.ssh.html>_.

Who uses Luigi?

We use Luigi internally at Spotify <https://www.spotify.com>_ to run thousands of tasks every day, organized in complex dependency graphs. Most of these tasks are Hadoop jobs. Luigi provides an infrastructure that powers all kinds of stuff including recommendations, toplists, A/B test analysis, external reports, internal dashboards, etc.

Since Luigi is open source and without any registration walls, the exact number of Luigi users is unknown. But based on the number of unique contributors, we expect hundreds of enterprises to use it. Some users have written blog posts or held presentations about Luigi:

Some more companies are using Luigi but haven't had a chance yet to write about it:

We're more than happy to have your company added here. Just send a PR on GitHub.

Authors

Luigi was built at Spotify <https://www.spotify.com>, mainly by Erik Bernhardsson <https://github.com/erikbern> and Elias Freider <https://github.com/freider>. Many other people <https://github.com/spotify/luigi/graphs/contributors> have contributed since open sourcing in late 2012. Arash Rouhani <https://github.com/tarrasch>_ was the chief maintainer from 2015 to 2019, and now Spotify's Data Team maintains Luigi.

luigi (spotify/luigi)

Searching Database…

18.8K ·GitHub
这是干什么的?Luigi 是一个 Python 包,用来搭建复杂的批处理任务流水线。它负责依赖解析、工作流管理、可视化、失败处理以及命令行集成。
它是一个我要写代码调用的库,还是一个要部署的服务?它是一个用代码搭建流水线的 Python 包:你直接用 Python 编写任务及其依赖关系,所以依赖图就存在于你的代码里,而不是 XML 或外部配置文件中。
我需要有 Hadoop 集群才能用吗?不需要——它内置了 Hadoop 支持,但 Luigi 并不只针对 Hadoop。任务可以是任何东西:Hive 查询、Spark 作业、Python 脚本、数据库导出,而且很容易扩展出其他任务类型。
如果一个长时间运行的流水线中途有任务失败了会怎样?失败是被预期并妥善处理的:通过 Luigi 对 HDFS 和本地文件的抽象层进行的文件系统操作都是原子性的,所以流水线崩溃后不会留下含部分数据的中间状态。
它是久经验证的产品,还是实验性的东西?久经验证:Spotify 自己每天运行数千个 Luigi 任务,用于驱动推荐、排行榜、A/B 测试分析和内部仪表盘,维护者预计有数百家企业在使用它。
Luigi 和 Oozie 或 Azkaban 有什么区别?从概念上讲它类似 GNU Make:任务依赖于其他任务。与 Oozie 和 Azkaban 不同的是,它不是专门为 Hadoop 打造的,而且整个依赖图都写在 Python 代码里,而不是 XML 配置——包括日期运算和任务版本之间的递归引用。
它能运行不是 Python 写的作业吗?可以。任务可以是 Java 写的 Hadoop 作业、Scala 或 Python 写的 Spark 作业、Hive 或 Pig 查询,工作流还能触发 Python 之外的事情,比如运行 Pig 脚本或用 scp 传文件。
我怎么了解我的流水线正在做什么?Luigi 服务器自带一个网页界面,你可以在里面搜索和筛选所有任务,并查看依赖图——绿色节点表示已完成,黄色节点表示还没运行。
一个流水线最大能有多大?Luigi 面向的是包含数千个任务、需要数天或数周才能跑完的长流水线,并附带一套现成的任务模板工具箱,包括面向 Hadoop 的 Python mapreduce、Hive 和 Pig 作业。
What are similar projects?kestra, airflow, flink, DataX, taipy, dagster, hadoop, dolphinscheduler
Creator
spotify
Size
11.3 MB
Stars
18.8K
Age
14y
Commits · 90 Days