def test_proto(self, application_status): status_info = StatusOverview( app_status=ApplicationStatusInfo( status=application_status, message="context about this status", deployment_timestamp=time.time(), ), deployment_statuses=[ DeploymentStatusInfo( name="name1", status=DeploymentStatus.UPDATING, message="deployment updating", ), DeploymentStatusInfo(name="name2", status=DeploymentStatus.HEALTHY, message=""), DeploymentStatusInfo( name="name3", status=DeploymentStatus.UNHEALTHY, message="this deployment is unhealthy", ), ], ) serialized_proto = status_info.to_proto().SerializeToString() deserialized_proto = StatusOverviewProto.FromString(serialized_proto) reconstructed_info = StatusOverview.from_proto(deserialized_proto) assert status_info == reconstructed_info
async def get_serve_status(self) -> bytes: serve_app_status = ApplicationStatus.RUNNING serve_app_message = "" deployment_timestamp = self.deployment_timestamp if self.config_deployment_request_ref: finished, pending = ray.wait([self.config_deployment_request_ref], timeout=0) if pending: serve_app_status = ApplicationStatus.DEPLOYING else: try: await finished[0] except RayTaskError: serve_app_status = ApplicationStatus.DEPLOY_FAILED serve_app_message = f"Deployment failed:\n{traceback.format_exc()}" app_status = ApplicationStatusInfo(serve_app_status, serve_app_message, deployment_timestamp) deployment_statuses = self.deployment_state_manager.get_deployment_statuses( ) status_info = StatusOverview( app_status=app_status, deployment_statuses=deployment_statuses, ) return status_info.to_proto().SerializeToString()
def test_equality_mismatched_deployment_statuses(self): """Check that StatusOverviews with different numbers of statuses are unequal.""" status_info_few_deployments = StatusOverview( app_status=self.get_valid_serve_application_status_info(), deployment_statuses=[ DeploymentStatusInfo(name="1", status=DeploymentStatus.HEALTHY), DeploymentStatusInfo(name="2", status=DeploymentStatus.UNHEALTHY), ], ) status_info_many_deployments = StatusOverview( app_status=self.get_valid_serve_application_status_info(), deployment_statuses=[ DeploymentStatusInfo(name="1", status=DeploymentStatus.HEALTHY), DeploymentStatusInfo(name="2", status=DeploymentStatus.UNHEALTHY), DeploymentStatusInfo(name="3", status=DeploymentStatus.UNHEALTHY), DeploymentStatusInfo(name="4", status=DeploymentStatus.UPDATING), ], ) assert status_info_few_deployments != status_info_many_deployments
def test_empty_list_valid(self): """Should be able to create StatusOverview with no deployment statuses.""" # Check default is empty list status_info = StatusOverview( app_status=self.get_valid_serve_application_status_info()) status_info.deployment_statuses == [] # Ensure empty list can be passed in explicitly status_info = StatusOverview( app_status=self.get_valid_serve_application_status_info(), deployment_statuses=[], ) status_info.deployment_statuses == []
def get_valid_serve_status_schema(self): return StatusOverview( app_status=ApplicationStatusInfo( status="DEPLOYING", message="", deployment_timestamp=time.time(), ), deployment_statuses=[ DeploymentStatusInfo( name="deployment_1", status="HEALTHY", message="", ), DeploymentStatusInfo( name="deployment_2", status="UNHEALTHY", message="this deployment is deeply unhealthy", ), ], )
def get_serve_status(self) -> StatusOverview: proto = StatusOverviewProto.FromString( ray.get(self._controller.get_serve_status.remote())) return StatusOverview.from_proto(proto)
def test_app_status_required(self): with pytest.raises(TypeError): StatusOverview(deployment_statuses=[])