Skip to content

Instantly share code, notes, and snippets.

@concreted
Created May 3, 2023 20:07
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 concreted/6d9f4a1165fc79c510f9a63ac28363b4 to your computer and use it in GitHub Desktop.
Save concreted/6d9f4a1165fc79c510f9a63ac28363b4 to your computer and use it in GitHub Desktop.
Prefect Ray Crash Example
import ray
import time
from prefect import task, flow
class foo:
def __init__(self):
pass
def run(self, i):
return f"hi {i}"
@task
def test():
f = ray.remote(num_gpus=0)(foo)
pool = ray.util.ActorPool([f.remote()])
print(pool)
results = pool.map(lambda a, i: a.run.remote(i), [1])
print(list(results))
print("done")
@task
def sleep():
time.sleep(60 * 10)
@flow(log_prints=True)
def ray_test():
test()
sleep()
if __name__ == "__main__":
ray_test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment