Skip to content

Commit

Permalink
[Serve] Add deprecated warnings (ray-project#26374)
Browse files Browse the repository at this point in the history
  • Loading branch information
sihanwang41 committed Jul 12, 2022
1 parent 22dfd1f commit f5c5215
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python/ray/_private/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ def deprecated(
removal_release: Optional[str] = None,
removal_date: Optional[str] = None,
warn_once: bool = True,
stacklevel=2,
):
"""
Creates a decorator for marking functions as deprecated. The decorator
Expand All @@ -1036,6 +1037,7 @@ def deprecated(
warn_once: If true, the deprecation warning will only be logged
on the first invocation. Otherwise, the deprecation warning will
be logged on every invocation. Defaults to True.
stacklevel: adjust the warnings stacklevel to trace the source call
Returns:
A decorator to be used for wrapping deprecated functions.
Expand Down Expand Up @@ -1066,7 +1068,7 @@ def new_func(*args, **kwargs):
)
+ (f" {instructions}" if instructions is not None else "")
)
warnings.warn(msg)
warnings.warn(msg, stacklevel=stacklevel)
return func(*args, **kwargs)

return new_func
Expand Down
3 changes: 3 additions & 0 deletions python/ray/serve/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
install_serve_encoders_to_fastapi,
)
from ray.util.annotations import PublicAPI
from ray._private.utils import deprecated

logger = logging.getLogger(__file__)

Expand Down Expand Up @@ -456,6 +457,7 @@ def decorator(_func_or_class):
return decorator(_func_or_class) if callable(_func_or_class) else decorator


@deprecated(instructions="Please see https://docs.ray.io/en/latest/serve/index.html")
@PublicAPI
def get_deployment(name: str) -> Deployment:
"""Dynamically fetch a handle to a Deployment object.
Expand Down Expand Up @@ -497,6 +499,7 @@ def get_deployment(name: str) -> Deployment:
)


@deprecated(instructions="Please see https://docs.ray.io/en/latest/serve/index.html")
@PublicAPI
def list_deployments() -> Dict[str, Deployment]:
"""Returns a dictionary of all active deployments.
Expand Down
10 changes: 10 additions & 0 deletions python/ray/serve/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
RayActorOptionsSchema,
DeploymentSchema,
)
from ray._private.utils import deprecated


logger = logging.getLogger(SERVE_LOGGER_NAME)
Expand Down Expand Up @@ -199,6 +200,9 @@ def bind(self, *args, **kwargs) -> Union[ClassNode, FunctionNode]:
},
)

@deprecated(
instructions="Please see https://docs.ray.io/en/latest/serve/index.html"
)
@PublicAPI
def deploy(self, *init_args, _blocking=True, **init_kwargs):
"""Deploy or update this deployment.
Expand Down Expand Up @@ -227,12 +231,18 @@ def deploy(self, *init_args, _blocking=True, **init_kwargs):
_blocking=_blocking,
)

@deprecated(
instructions="Please see https://docs.ray.io/en/latest/serve/index.html"
)
@PublicAPI
def delete(self):
"""Delete this deployment."""

return get_global_client().delete_deployments([self._name])

@deprecated(
instructions="Please see https://docs.ray.io/en/latest/serve/index.html"
)
@PublicAPI
def get_handle(
self, sync: Optional[bool] = True
Expand Down

0 comments on commit f5c5215

Please sign in to comment.