|
@@ -0,0 +1,52 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+"""
|
|
|
+This example show you how to create workflows in batch mode. After this example run, we will create 10
|
|
|
+workflows named `workflow:<workflow_num>`, and with 3 tasks named `task:<task_num>-workflow:<workflow_num>`
|
|
|
+in each workflow. Each workflow is linear shape as below, since we set `IS_CHAIN=True`
|
|
|
+
|
|
|
+task:1-workflow:1 -> task:2-workflow:1 -> task:3-workflow:1
|
|
|
+"""
|
|
|
+
|
|
|
+from pydolphinscheduler.core.process_definition import ProcessDefinition
|
|
|
+from pydolphinscheduler.tasks.shell import Shell
|
|
|
+
|
|
|
+NUM_WORKFLOWS = 10
|
|
|
+NUM_TASKS = 5
|
|
|
+
|
|
|
+TENANT = "exists_tenant"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+IS_CHAIN = True
|
|
|
+
|
|
|
+for wf in range(0, NUM_WORKFLOWS):
|
|
|
+ workflow_name = f"workflow:{wf}"
|
|
|
+
|
|
|
+ with ProcessDefinition(name=workflow_name, tenant=TENANT) as pd:
|
|
|
+ for t in range(0, NUM_TASKS):
|
|
|
+ task_name = f"task:{t}-workflow:{wf}"
|
|
|
+ command = f"echo This is task {task_name}"
|
|
|
+ task = Shell(name=task_name, command=command)
|
|
|
+
|
|
|
+ if IS_CHAIN and t > 0:
|
|
|
+ pre_task_name = f"task:{t-1}-wf:{wf}"
|
|
|
+ pd.get_one_task_by_name(pre_task_name) >> task
|
|
|
+
|
|
|
+
|
|
|
+ pd.submit()
|