-
-
Save concreted/6d9f4a1165fc79c510f9a63ac28363b4 to your computer and use it in GitHub Desktop.
Prefect Ray Crash Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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