Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[impv] Auto create resource when set resource in task if there are exist files in local system #58

Open
jieguangzhou opened this issue Dec 21, 2022 · 0 comments

Comments

@jieguangzhou
Copy link
Member

# [start workflow]
from 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()
# [end workflow]

Change the above usage to the following usage

# [start workflow]
from pydolphinscheduler.core import Workflow
from pydolphinscheduler.core.resource import Resource, LocalResource
from pydolphinscheduler.tasks import Shell

dependence = "dependence.py"
main = "main.py"

with Workflow(
    name="multi_resources_example",
) as workflow:
    # [start use_exists_resources]
    task_use_resource = Shell(
        name="use-resource",
        command=f"python {main}",
        resource_list=[
            LocalResource('dependence.py'),
            LocalResource('main.py'),
            LocalResource('*.py'),
        ],
    )
    # [end use_exists_resources]

    workflow.run()
# [end workflow]
@jieguangzhou jieguangzhou changed the title [impv] Auto create resource when set resource name in task [impv] Auto create resource when set resource in task Dec 21, 2022
@jieguangzhou jieguangzhou changed the title [impv] Auto create resource when set resource in task [impv] Auto create resource when set resource in task if there are exist files in local system Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant