https://prefect.io logo
t

Theis Ferré Hjortkjær

09/18/2023, 7:09 AM
Hi all Anyone that has experience with using the prefect-ray integration? I have a prefect agent and Ray cluster running inside my kubernetes cluster. Both seems works as intended as a standalone. However, when i try to use the prefect-ray integration and specify resources for a task i.e.
Copy code
from prefect import flow, task
from prefect_ray.task_runners import RayTaskRunner
from prefect_ray.context import remote_options

@task
def process(x):
    return x + 1


@flow(task_runner=RayTaskRunner("ray://<my-ray-service>:10001"))
def my_flow():
    # equivalent to setting @ray.remote(num_cpus=4)
    with remote_options(num_cpus=4):
        process.submit(42)
It fails with a runtime error:
RuntimeError: There is no current event loop in thread 'ray_client_server_1'.
If i do not specify resources for my task, everything works as intended. I have submitted an issue, but it has not been picked up yet, so i thought maybe i could get some help here 🙂 https://github.com/PrefectHQ/prefect/issues/10542