surahman commented on a change in pull request #3786:
URL: https://github.com/apache/incubator-heron/pull/3786#discussion_r837056714
##########
File path: 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:
It is the production code that is faulty and causing this error. The
test merely calls it. If you choose to go back to your original code you will
need to update this routine, and anything that depends on it, as well as the
tests.
<details><summary>Build Log Failure</summary>
```bash
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _
self = <heron.tools.tracker.src.python.query_operators.Subtract object at
0x7fe237a53e20>
tracker = <Mock id='140609572909[840]()'>, tmanager = <Mock
id='140609572912960'>
start = 100, end = 300
async def execute(self, tracker, tmanager: TManagerLocation, start: int,
end: int) -> Any:
"""
Return _f applied over all values in [start, end] of the two operands.
Scalars
are expanded a timeseries with all points equal to the scalar.
"""
metrics, metrics2 = await asyncio.gather(
self._get_metrics(self.operand1, tracker, tmanager, start, end),
self._get_metrics(self.operand2, tracker, tmanager, start, end),
)
# In case both are multivariate, only equal instances will get operated
if self._is_multivariate(metrics) and self._is_multivariate(metrics2):
all_metrics = []
for key in metrics:
if key not in metrics2:
continue
met = Metrics(None, None, key, start, end, {})
for timestamp in list(metrics[key].timeline.keys()):
value = self._f(
metrics[key].timeline[timestamp],
metrics2[key].timeline.get(timestamp),
)
if value is None:
metrics[key].timeline.pop(timestamp, None)
else:
met.timeline[timestamp] = value
all_metrics.append(met)
return all_metrics
# If first is univariate
if not self._is_multivariate(metrics):
all_metrics = []
for key, metric in metrics2.items():
# Initialize with first metrics timeline, but second metric's
instance
# because that is multivariate
if metrics:
met = Metrics(None, None, metric.instance, start, end,
metrics[""].timeline.copy())
for timestamp in list(met.timeline.keys()):
> v = self._f(met.timeline[timestamp],
metric.timeline[timestamp])
E KeyError: 120
../../../../../../../../../../_tmp/2b5b8aef99713d16d1504f0eb43a6602/.pex/unzipped_pexes/9e6c937c2cca84dde46c456e33bc2dcb1a8c4dc0/heron/tools/tracker/src/python/query_operators.py:466:
KeyError
- generated xml file:
/home/travis/.cache/bazel/_bazel_travis/be6dac4936703c7eedcb4f5cf38cdd65/execroot/org_apache_heron/bazel-out/k8-fastbuild/testlogs/heron/tools/tracker/tests/python/query_operator_unittest/test.xml
-
```
</details>
--
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]