surahman commented on a change in pull request #3786:
URL: https://github.com/apache/incubator-heron/pull/3786#discussion_r835974279
##########
File path: heron/tools/ui/src/python/main.py
##########
@@ -306,6 +309,34 @@ def file_download(
headers={"Content-Disposition": f"attachment; filename={filename}"},
)
+# List envelope for Exceptions response
+class ApiListEnvelope(pydantic.BaseModel):
+ """Envelope for heron-ui JSON API."""
+ status: str
+ message: str
+ version: str = VERSION
+ executiontime: int
+ result: list
+
+def api_topology_list_json(method: Callable[[], dict]) -> ApiListEnvelope:
+ """Wrap the output of a method with a response envelope."""
+ started = time.time()
+ result = method()
+ Log.debug(f"Api topology: {result}")
+ if type(result) is None:
+ return ApiEnvelope(
+ status="failure",
+ message="No topology found",
+ executiontime=time.time() - started,
+ result={},
+ )
+ else:
+ return ApiListEnvelope(
+ status="success",
+ message="",
+ executiontime=time.time() - started,
+ result=result,
+ )
Review comment:
The `if` clause here will always return `false` and the `else` is dead
code.
##########
File path: heron/tools/tracker/src/python/main.py
##########
@@ -125,6 +125,8 @@ def cli(
log_level = logging.DEBUG if verbose else logging.INFO
log.configure(log_level)
+ global Log
+ Log = log.Log
Review comment:
I assume the purpose of this line was to update the globally defined
`Log`? If this is the case, we need the `Log` variable to be defined as
`global` as it is now.
##########
File path: heron/tools/ui/src/python/main.py
##########
@@ -316,17 +347,25 @@ class ApiEnvelope(pydantic.BaseModel):
executiontime: int
result: dict
-
def api_topology_json(method: Callable[[], dict]) -> ApiEnvelope:
"""Wrap the output of a method with a response envelope."""
started = time.time()
result = method()
- return ApiEnvelope(
- status="success",
- message="",
- executiontime=time.time() - started,
- result=result,
- )
+ Log.debug(f"Api topology: {result}")
+ if type(result) is None:
+ return ApiEnvelope(
+ status="failure",
+ message="No topology found",
+ executiontime=time.time() - started,
+ result={},
+ )
+ else:
+ return ApiEnvelope(
+ status="success",
+ message="",
+ executiontime=time.time() - started,
+ result=result,
+ )
Review comment:
The `if` clause here will always return `false` and the `else` is dead
code.
##########
File path: heron/tools/ui/src/python/main.py
##########
@@ -614,9 +653,11 @@ def cli(
host: str, port: int, base_url_option: str, tracker_url_option: str,
verbose: bool
) -> None:
"""Start a web UI for heron which renders information from the tracker."""
- global base_url, tracker_url
+ global base_url, tracker_url, Log
base_url = base_url_option
- log.configure(level=logging.DEBUG if verbose else logging.INFO)
+ log_level = logging.DEBUG if verbose else logging.INFO
+ log.configure(log_level)
+ Log = log.Log
Review comment:
I assume the purpose of this line was to update the globally defined
`Log`? If this is the case, we need the `Log` variable to be defined as
`global` as it is now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]