Code0x58 commented on PR #3786: URL: https://github.com/apache/incubator-heron/pull/3786#issuecomment-1094375901
> I can't figure out why the timeline is not working. I've tracked my issue to this [line of code](https://github.com/apache/incubator-heron/blob/06e9f75988fd254053b640689879c3393703b0dd/heron/tools/common/src/python/clients/tracker.py#L575). Within the `compute_max` function, I can print the final `dict` that is returned. It has values. But when I print `data`, it only has an empty `dict`. Did you do that print within the `len(filtered_ts) > 0 and len(filtered_ts[0]["timeline"]) > 0:` branch of `compute_max(...)`? I'm wondering if the `{}` you are seeing is from the fall-though branch. Beware that `timelines` and `values` in `compute_max(...)` are generators, so will be exhausted if you do something with them before they are used in the `return dict(list(zip(keys, values)))`, so if you did `print(dict(list(zip(keys, values))))` it would consume `values` and lead to zip of the keys list and an empty generator which results in an empty zip (python 3.10 adds [`strict=True`](https://docs.python.org/3/library/functions.html#zip) to help detect these) and would so make the `return dict(...)` line return an empty dict. _p.s._ > I am not sure but I do not think there is a need to convert the zipped together values into a `list` and then a `dict`. But then I also do not believe this would affect the return value. > > https://github.com/apache/incubator-heron/blob/06e9f75988fd254053b640689879c3393703b0dd/heron/tools/common/src/python/clients/tracker.py#L626 > > Maybe try this: > > ```python > return dict(zip(keys, values)) > ``` both are equivalent and will be handled the same way due to python's duck typing, as both a generator (returned by zip, in type annotations it is compatible with [`typing.Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator) but is more strictly a [`typing.Generator`](https://docs.python.org/3/library/typing.html#typing.Generator)) and list will be treated as iterables. The use of `list(generator)` can be faster for some cases, but constructs an object which will be discarded so can be a waste of memory. -- 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]
