Custom Anomaly Detection UDF with Python3

I am able to get this tutorial working with Python2. But considering Python2 will eventually be deprecated, I figured it’d be smart to try and get a UDF working with Python3. I am one error away from getting it to work (I think).

After trying to replay the recording through print_temps task, I get the following error:
task run: tTest3: read error: proto: integer overflow

I believe the agent is able to execute the ‘agent.start()’ and ‘agent.wait()’ statements at the bottom of ttest.py, so I believe the error is coming from some other source code?

Here is the kapacitor.log after running
kapacitor replay -task print_temps -recording $rid -rec-time

ts=2019-10-11T15:15:03.978-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=task_master:236e1825-b306-448c-a9fc-2789b48fdf80 parent=b00ce48a-654d-41c2-9103-b7428609751a child=stream collected=86385 emitted=86384
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=task_master:236e1825-b306-448c-a9fc-2789b48fdf80 parent=write_points child=stream collected=0 emitted=0
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=stream child=stream0 collected=86385 emitted=86385
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=stream0 child=from1 collected=86385 emitted=86385
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=from1 child=window2 collected=86385 emitted=86385
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=window2 child=tTest7 collected=287 emitted=0
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=window2 child=tTest5 collected=287 emitted=0
ts=2019-10-11T15:15:03.979-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=window2 child=tTest3 collected=287 emitted=0
ts=2019-10-11T15:15:04.173-07:00 lvl=info msg=“http request” service=http host=::1 username=- start=2019-10-11T15:15:04.173306-07:00 method=GET uri=/kapacitor/v1/replays/236e1825-b306-448c-a9fc-2789b48fdf80 protocol=HTTP/1.1 status=202 referer=- user-agent=KapacitorClient request-id=933715ce-ec74-11e9-800b-000000000000 duration=614.704µs
ts=2019-10-11T15:15:04.253-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest5 text=“Starting agent for TTestHandler”
ts=2019-10-11T15:15:04.253-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest7 text=“Starting agent for TTestHandler”
ts=2019-10-11T15:15:04.254-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest3 text=“Starting agent for TTestHandler”
ts=2019-10-11T15:15:04.352-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest7 text=“Agent Finished!”
ts=2019-10-11T15:15:04.369-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest5 text=“Agent Finished!”
ts=2019-10-11T15:15:04.371-07:00 lvl=info msg=“UDF log” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest3 text=“Agent Finished!”
ts=2019-10-11T15:15:04.391-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=tTest7 child=alert8 collected=0 emitted=0
ts=2019-10-11T15:15:04.391-07:00 lvl=error msg=“node failed” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest7 err=“read error: proto: integer overflow”
ts=2019-10-11T15:15:04.414-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=tTest5 child=alert6 collected=0 emitted=0
ts=2019-10-11T15:15:04.414-07:00 lvl=error msg=“node failed” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest5 err=“read error: proto: integer overflow”
ts=2019-10-11T15:15:04.416-07:00 lvl=debug msg=“closing edge” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps parent=tTest3 child=alert4 collected=0 emitted=0
ts=2019-10-11T15:15:04.416-07:00 lvl=error msg=“node failed” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps node=tTest3 err=“read error: proto: integer overflow”
ts=2019-10-11T15:15:04.416-07:00 lvl=error msg=“failed to stop task with out error” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80 task=print_temps err=“tTest3: read error: proto: integer overflow”
ts=2019-10-11T15:15:04.416-07:00 lvl=info msg=“closed task master” service=kapacitor task_master=main task_master=236e1825-b306-448c-a9fc-2789b48fdf80

I’ve already changed the way the data is decoded (mac_roman), and the _in=sys.stdin.buffer in the signature of the init function.

Please help!

Thanks
Mikey