PrefectHQ / prefect-ray

Prefect integrations with Ray
https://prefecthq.github.io/prefect-ray/
Apache License 2.0
63 stars 5 forks source link

Propagating prefect task names to ray tasks instead of it showing up as _run_prefect_task in the Ray dashboard #86

Closed achordia20 closed 10 months ago

achordia20 commented 1 year ago

Expectation / Proposal

Propagate the prefect task name (whether function or manual name override in the task decorator) to the ray task.

Traceback / Example

Screen Shot 2023-05-18 at 12 43 20 PM

azmyrajab commented 11 months ago

Curious if anyone has been able to take a look at this?

One could achieve this by using .options as per below

        if remote_options:
            ray_decorator = ray.remote(**remote_options)
        else:
            ray_decorator = ray.remote

        self._ray_refs[key] = ray_decorator(self._run_prefect_task).options(name=user_specified_task_name).remote(
            sync_compatible(call.func), *upstream_ray_obj_refs, **call_kwargs
        )
j-tr commented 11 months ago

@azmyrajab Here's my attempt to solve this: #103. Happy to incorporate any feedback. From what I understand, options can only be used to change properties that can be set via the remote options (i.e. parameters to https://docs.ray.io/en/latest/ray-core/api/doc/ray.remote.html). Name is none of them.

azmyrajab commented 11 months ago

Hi Justin, thank you so much for taking a look at this

Fyi its a trick that does work, but I think its a feature that is not well documented as you noticed. It was added here https://github.com/ray-project/ray/issues/10371 to address these type of scenarios where a factory function produces multiple tasks.

Here is an example I just ran by 'patching' the Ray Prefect source:

image
        if remote_options:
            ray_decorator = ray.remote(**remote_options)
        else:
            ray_decorator = ray.remote

        self._ray_refs[key] = ray_decorator(self._run_prefect_task).options(name="hello_world").remote(
            sync_compatible(call.func), *upstream_ray_obj_refs, **call_kwargs
        )

In any case taking a look at your https://github.com/PrefectHQ/prefect-ray/pull/103 now - will be very grateful if it solves this problem no matter

azmyrajab commented 11 months ago

Yes, I think the ray feature is intended for that (see https://github.com/ray-project/ray/pull/10449/files for the implementation), and instead of modifying __qualname__ you can propagate the prefect task name via options and I think this will be a nice solution

j-tr commented 11 months ago

thank you for pointing me to #10371. just changed my MR to use options instead.

j-tr commented 11 months ago

desertaxle happy to receive any feedback on #103.