Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom task names in dashboard #50059

Open
janosh opened this issue Jan 24, 2025 · 0 comments
Open

Custom task names in dashboard #50059

janosh opened this issue Jan 24, 2025 · 0 comments
Labels
dashboard Issues specific to the Ray Dashboard enhancement Request for new feature and/or capability triage Needs triage (eg: priority, bug/not-bug, and owning component)

Comments

@janosh
Copy link

janosh commented Jan 24, 2025

by default, the task name shown in the dashboard for a task is the name of the @ray.remote decorated function, say def my_task. if you invoke my_task 10k times with different arguments, it would be much nicer, if some stringified version of the function args was appended to the function name (ideally returned by a user-definable stringify function). e.g. in my case, running a function over many crystal structures might require a stringifier like

def _get_task_name(func: Callable, args: tuple[Any, ...], kwargs: dict[str, Any]) -> str:
    """Generate descriptive task name based on function and its inputs."""
    task_name = func.__name__

    # Check all args and kwargs for pymatgen Structure or ASE Atoms objects
    all_args = [*args, *kwargs.values()]
    for arg in all_args:
        # Check for pymatgen Structure
        if hasattr(arg, "composition") and hasattr(arg, "formula"):
            return f"{task_name}_{arg.formula}"
        # Check for ASE Atoms
        if hasattr(arg, "get_chemical_formula"):
            return f"{task_name}_{arg.get_chemical_formula()}"

    return task_name

i'm currently trying to apply this function in a decorator that wraps @ray.remote:

def ray_task(
    *,
    mongo_config: MongoConfig | list[MongoConfig] | None = None,
    verbosity: Verbosity = Verbosity.none,
    **ray_options: Any,
) -> Callable[[Decorated], Decorated]:
    """Decorator for Ray tasks with optional single/multi-collection MongoDB output.

   # other code ...

    def decorator(func: Decorated) -> Decorated:
        @ray.remote(**ray_options)  # Configure the remote task with Ray options
        @functools.wraps(func)
        def wrapper(*args: Any, **kwargs: Any) -> Any:
            # Generate descriptive task name
            task_name = _get_task_name(func, args, kwargs)
            # Override the task name in the Ray dashboard
            wrapper.options(name=task_name)

but this has no effect. i'm logging the task name to make sure it's what i expect but the new task name does not make it's way into the web dashboard. all invocations continue to be grouped and listed only the function name

am i misunderstanding the docs here that led me to believe this should work? even setting the name directly on a remote function without the wrapper decorator bells and whistles has no effect.

Tasks and Actors are grouped and nested using the following criteria:

All Tasks and Actors are grouped together. View individual entries by expanding the corresponding row.

Tasks are grouped by their name attribute (e.g., task.options(name="<name_here>").remote()).

Child Tasks (nested Tasks) are nested under their parent Task’s row.

@vaibhavbafna5 for awareness

@janosh janosh added enhancement Request for new feature and/or capability triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Jan 24, 2025
@jcotant1 jcotant1 added the dashboard Issues specific to the Ray Dashboard label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard Issues specific to the Ray Dashboard enhancement Request for new feature and/or capability triage Needs triage (eg: priority, bug/not-bug, and owning component)
Projects
None yet
Development

No branches or pull requests

2 participants