Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/ray/serve/task_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def __del__(self):
if hasattr(target_cls, "__del__"):
target_cls.__del__(self)

# Preserve the original class name
_TaskConsumerWrapper.__name__ = target_cls.__name__

return _TaskConsumerWrapper

return decorator
Expand Down
15 changes: 15 additions & 0 deletions python/ray/serve/tests/unit/test_task_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pytest

from ray.serve.api import deployment
from ray.serve.schema import (
CeleryAdapterConfig,
TaskProcessorAdapter,
Expand Down Expand Up @@ -285,5 +286,19 @@ class MyConsumer:
pass


def test_default_deployment_name_stays_same_with_task_consumer(config):
"""Test that the default deployment name is the class name when using task_consumer with serve.deployment."""

@deployment
@task_consumer(task_processor_config=config)
class MyTaskConsumer:
@task_handler
def my_task(self):
pass

# The deployment name should default to the class name
assert MyTaskConsumer.name == "MyTaskConsumer"


if __name__ == "__main__":
sys.exit(pytest.main(["-v", "-s", __file__]))