Python

Task Python.

class pydolphinscheduler.tasks.python.Python(name: str, definition: str | LambdaType, *args, **kwargs)[source]

Bases: Task

Task Python object, declare behavior for Python task to dolphinscheduler.

Python task support two types of parameters for :param:code, and here is an example:

Using str type of :param:code

python_task = Python(name="str_type", code="print('Hello Python task.')")

Or using Python callable type of :param:code

def foo():
    print("Hello Python task.")

python_task = Python(name="str_type", code=foo)
Parameters:
  • name – The name for Python task. It define the task name.

  • definition – String format of Python script you want to execute or Python callable you want to execute.

_build_exe_str() str[source]

Build executable string from given definition.

Attribute self.definition almost is a function, we need to call this function after parsing it to string. The easier way to call a function is using syntax func() and we use it to call it too.

_downstream_task_codes: Set[int]
_task_custom_attr: set = {'raw_script'}
_task_relation: Set[TaskRelation]
_upstream_task_codes: Set[int]
property raw_script: str

Get python task define attribute raw_script.