ray.runtime_context.RuntimeContext.get_task_function_name#

RuntimeContext.get_task_function_name() str | None[source]#

Get current task function name string for this worker.

Example

import ray

@ray.remote
class Actor:
    def get_task_function_name(self):
        return ray.get_runtime_context().get_task_function_name()

@ray.remote
class AsyncActor:
    async def get_task_function_name(self):
        return ray.get_runtime_context().get_task_function_name()

@ray.remote
def get_task_function_name():
    return ray.get_runtime_context().get_task_function_name()

a = Actor.remote()
b = AsyncActor.remote()
# Task functions are available for actor tasks.
print(ray.get(a.get_task_function_name.remote()))
# Task functions are available for async actor tasks.
print(ray.get(b.get_task_function_name.remote()))
# Task functions are available for normal tasks.
print(ray.get(get_task_function_name.remote()))
[python modual name].Actor.get_task_function_name
[python modual name].AsyncActor.get_task_function_name
[python modual name].get_task_function_name
Returns:

The current worker’s task function call string