Skip to content

Instantly share code, notes, and snippets.

@yhshin11
Created September 8, 2022 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhshin11/1832bc945446a62c5c6152abb9c1a0a5 to your computer and use it in GitHub Desktop.
Save yhshin11/1832bc945446a62c5c6152abb9c1a0a5 to your computer and use it in GitHub Desktop.
Test: Run many tasks with Prefect
"""Run tasks with prefect, using DaskTaskRunner."""
from prefect import flow, task, get_run_logger
from prefect_dask import DaskTaskRunner
import time
@task
def my_task(message, count):
logger = get_run_logger()
for i in range(count):
logger.info(f"Repeated message {i} out of {count} times: {message}")
time.sleep(1)
@flow
def my_flow(messages):
logger = get_run_logger()
print(logger.extra)
for message in messages:
logger.info(f"Repeating message: {message}")
my_task.submit(message, 100)
# shell_run_command.submit(command=command, return_all=True)
# call the flow!
if __name__ == "__main__":
messages = ["beepboop"] * 10000
my_flow(messages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment