From 375d3e85f442226c6990ecf0e812fff94bed2de9 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Tue, 20 Dec 2022 19:01:31 +0900 Subject: [PATCH] why --- .../components/serve/auto_scaler.py | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/src/lightning_app/components/serve/auto_scaler.py b/src/lightning_app/components/serve/auto_scaler.py index 3237b2cfe3a52..66c412230b571 100644 --- a/src/lightning_app/components/serve/auto_scaler.py +++ b/src/lightning_app/components/serve/auto_scaler.py @@ -373,31 +373,38 @@ def get_code_sample(self, url: str) -> Optional[str]: return f"{input_type.request_code_sample(url)}\n{output_type.response_code_sample()}" def _get_endpoint_info_page(self) -> Optional["APIAccessFrontend"]: # noqa: F821 - try: - from lightning_api_access import APIAccessFrontend - except ModuleNotFoundError: - logger.warn("APIAccessFrontend not found. Please install lightning-api-access to enable the UI") - return - - if is_running_in_cloud(): - url = f"{self._future_url}{self.endpoint}" - else: - url = f"http://localhost:{self.port}{self.endpoint}" - - frontend_objects = {"name": self._work_name, "url": url, "method": "POST", "request": None, "response": None} - code_samples = self.get_code_sample(url) - if code_samples: - frontend_objects["code_samples"] = code_samples - # TODO also set request/response for JS UI - else: - try: - request = self._get_sample_dict_from_datatype(self._input_type) - response = self._get_sample_dict_from_datatype(self._output_type) - except TypeError: - return None - else: - frontend_objects["request"] = request - frontend_objects["response"] = response + # try: + from lightning_api_access import APIAccessFrontend + + # except ModuleNotFoundError: + # logger.warn("APIAccessFrontend not found. Please install lightning-api-access to enable the UI") + # return + + # if is_running_in_cloud(): + # url = f"{self._future_url}{self.endpoint}" + # else: + # url = f"http://127.0.0.1:{self.port}{self.endpoint}" + + frontend_objects = { + "name": "somename", + "url": f"http://127.0.0.1:{self.port}{self.endpoint}", + "method": "POST", + "request": {"text": "some text"}, + "response": {"image": "some image str"}, + } + # code_samples = self.get_code_sample(url) + # if code_samples: + # frontend_objects["code_samples"] = code_samples + # # TODO also set request/response for JS UI + # else: + # try: + # request = self._get_sample_dict_from_datatype(self._input_type) + # response = self._get_sample_dict_from_datatype(self._output_type) + # except TypeError: + # return None + # else: + # frontend_objects["request"] = request + # frontend_objects["response"] = response return APIAccessFrontend(apis=[frontend_objects])