9 Extending Airflow with custom operators and sensors
This chapter covers
- Making DAGs more modular and concise with custom components
- Designing and implementing custom hooks, operators, sensors, and deferrable sensors
- Distributing custom components as a basic Python library
As we’ve seen, one strong feature of Airflow is the ecosystem of operators that allow you to coordinate jobs across many types of systems. At some point, however, you may want to execute a task on a system that Airflow doesn’t support. Or you may have a task that you can implement using the PythonOperator, but it requires a lot of boilerplate code, which prevents others from reusing your code easily across DAGs. How should you go about it?
Fortunately, Airflow makes it easy to create new operators to implement your custom operations so you can run jobs on otherwise unsupported systems or make common operations easy to apply across DAGs. In fact, many of the operators in Airflow were implemented because someone had to run a job on a certain system and built an operator to do it.
In this chapter, we’ll show you how to build your own operators and use them in DAGs. We’ll also explore how to package your custom components into a Python package, making them easy to install and reuse across environments.