educative.io

Creating an airflow operator

If the operator is defined with only one parameter being passed into the execute function, how is it overloaded at runtime? Could I have passed an endless amount of parameters in?

import logging

from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults

log = logging.getLogger(name)

class HelloWorldOperator(BaseOperator):

@apply_defaults
def __init__(self, param1, param2, *args, **kwargs):
    self.param1 = param1
    self.param2 = param2
    super(HelloWorldOperator, self).__init__(*args, **kwargs)

def execute(self, context):
    # Operator only prints a Hello World message
    log.info("Hello World : %s %s", self.param1)

1 Like