surahman commented on code in PR #3786:
URL: https://github.com/apache/incubator-heron/pull/3786#discussion_r845645169
##########
heron/statemgrs/src/python/statemanager.py:
##########
@@ -92,8 +92,8 @@ def is_host_port_reachable(self):
socket.create_connection(hostport, StateManager.TIMEOUT_SECONDS)
return True
except:
- LOG.info("StateManager %s Unable to connect to host: %s port %i"
- % (self.name, hostport[0], hostport[1]))
+ LOG.info("StateManager %s Unable to connect to host: %s port %i",
+ self.name, hostport[0], hostport[1])
Review Comment:
I am not sure but I think the `%i` format flag is deprecated in Python3. I
am not sure if `hostportlist` is a list of integers or strings but perhaps
consider this if they are:
```suggestion
LOG.info("StateManager %s Unable to connect to host: %d port %d",
self.name, hostport[0], hostport[1])
```
##########
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:
Was it the desired outcome to update the global `Log` variable, or was this
just for debugging and development? Do we need to revert this?
##########
heron/tools/tracker/src/python/metricstimeline.py:
##########
@@ -73,21 +73,21 @@ async def get_metrics_timeline(
# Form and send the http request.
url = f"http://{tmanager.host}:{tmanager.stats_port}/stats"
- with httpx.AsyncClient() as client:
+ async with httpx.AsyncClient() as client:
result = await client.post(url,
data=request_parameters.SerializeToString())
# Check the response code - error if it is in 400s or 500s
- if result.code >= 400:
+ if result.status_code >= 400:
message = f"Error in getting metrics from Tmanager, code: {result.code}"
raise Exception(message)
# Parse the response from tmanager.
response_data = tmanager_pb2.MetricResponse()
response_data.ParseFromString(result.content)
- if response_data.status.status == common_pb2.NOTOK:
- if response_data.status.HasField("message"):
- Log.warn("Received response from Tmanager: %s",
response_data.status.message)
+ # if response_data.status.status == common_pb2.NOTOK:
+ # if response_data.status.HasField("message"):
+ # Log.warn("Received response from Tmanager: %s",
response_data.status.message)
Review Comment:
We still need to remove these.
##########
heron/tools/tracker/src/python/routers/container.py:
##########
@@ -143,8 +142,8 @@ class ExceptionLog(BaseModel):
hostname: str
instance_id: str
stack_trace: str = Field(..., alias="stacktrace")
- last_time: int = Field(..., alias="lasttime")
- first_time: int = Field(..., alias="firsttime")
+ last_time: str = Field(..., alias="lasttime")
+ first_time: str = Field(..., alias="firsttime")
Review Comment:
Do these need to be `str` or can we revert back to `int`? I have seen some
locations in the code where start and end times are being used for calculations.
##########
heronpy/connectors/pulsar/pulsarstreamlet.py:
##########
@@ -29,7 +29,7 @@ class PulsarStreamlet(Streamlet):
"""Streamlet facade on top of PulsarSpout"""
def __init__(self, service_url, topic_name, stage_name=None,
parallelism=None,
receive_timeout_ms=None, input_schema=None):
- super(PulsarStreamlet, self).__init__(parents=[],
+ super().__init__(parents=[],
stage_name=stage_name,
parallelism=parallelism)
Review Comment:
```suggestion
super().__init__(parents=[], stage_name=stage_name,
parallelism=parallelism)
```
##########
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:
Is the intention to actually update the global `Log` variable or was this
only intended for the duration of debugging/development?
##########
heron/tools/tracker/src/python/query_operators.py:
##########
@@ -150,11 +150,11 @@ async def execute(
raise Exception(metrics["message"])
# Put a blank timeline.
- if not metrics.get("timeline"):
- metrics["timeline"] = {
+ if not metrics.timeline:
+ metrics.timeline = {
Review Comment:
I think this was resolved with the updates to the test suite and a few other
locations?
##########
heron/tools/common/src/python/clients/tracker.py:
##########
@@ -122,27 +122,26 @@ def strip_whitespace(s):
backpressure=backpressure
)
-def api_get(url: str, params=None) -> dict:
+def api_get(url: str, params=None) -> Any:
"""Make a GET request to a tracker URL and return the result."""
start = time.time()
try:
+ Log.debug(f"Requesting URL: {url} with params: {params}")
response = requests.get(url, params)
response.raise_for_status()
except Exception as e:
- Log.error(f"Unable to get response from {url}: {e}")
+ Log.error(f"Unable to get response from {url} with params {params}: {e}")
return None
end = time.time()
data = response.json()
- if data["status"] != "success":
- Log.error("error from tracker: %s", data["message"])
+ if response.status_code != requests.codes.ok:
+ Log.error("error from tracker: %s", response.status_code)
return None
- execution = data["executiontime"] * 1000
duration = (end - start) * 1000
- Log.debug(f"URL fetch took {execution:.2}ms server time for {url}")
Log.debug(f"URL fetch took {duration:.2}ms round trip time for {url}")
- return data["result"]
+ return data
Review Comment:
Are we okay on this front now - this is not an issue?
--
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]