GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing dolphinscheduler.apache.org — Upload and Use Multiple Resources — apache-dolphinscheduler 4.1.0-dev documentation Upload and Use Multiple ResourcesResource center help us manager resources in a centralized way, easy to change and distribute them to all the workers. for more detail you can see resources files. In this section we will show you how to upload and use multiple resources which is more common in production environment and in the real word. Overviewfrom pydolphinscheduler.core import Workflow from pydolphinscheduler.core.resource import Resource from pydolphinscheduler.tasks import Shell dependence = "dependence.py" main = "main.py" with Workflow( name="multi_resources_example", # [start create_new_resources] resource_list=[ Resource( name=dependence, content="from datetime import datetime\nnow = datetime.now()", ), Resource(name=main, content="from dependence import now\nprint(now)"), ], # [end create_new_resources] ) as workflow: # [start use_exists_resources] task_use_resource = Shell( name="use-resource", command=f"python {main}", resource_list=[ dependence, main, ], ) # [end use_exists_resources] workflow.run() In this example, we will upload two python files to resource center and use them in one single task, the python
files are named Upload ResourcesThe module from pydolphinscheduler.core.resource import Resource Then we need to create two resources object and assign them to resource_list=[ Resource( name=dependence, content="from datetime import datetime\nnow = datetime.now()", ), Resource(name=main, content="from dependence import now\nprint(now)"), ], Use ResourcesSame as using single resource, all we need is to assign them to task_use_resource = Shell( name="use-resource", command=f"python {main}", resource_list=[ dependence, main, ], ) After run the workflow, will execute main.py and print the current datetime. You can see the result like this: 2022-11-29 16:16:51.952742 |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |