From bd10016e269f1c52cd99ebe8f1c59498b350e127 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Sun, 14 Oct 2018 13:20:51 +1300 Subject: [PATCH 01/15] [Fix](#649) changes to support ns timepoints extensive but not fully tested, unittests updates to follow also fixes ( #527,#489, #346, #344, #340) --- influxdb/_dataframe_client.py | 20 ++++++++++---------- influxdb/line_protocol.py | 24 +++++++++++++++--------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 06da7ac4..fb995207 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -261,7 +261,7 @@ def _convert_dataframe_to_json(dataframe, {'measurement': measurement, 'tags': dict(list(tag.items()) + list(tags.items())), 'fields': rec, - 'time': np.int64(ts.value / precision_factor)} + 'time': np.int64(ts.value // precision_factor)} for ts, tag, rec in zip(dataframe.index, dataframe[tag_columns].to_dict('record'), dataframe[field_columns].to_dict('record')) @@ -329,10 +329,10 @@ def _convert_dataframe_to_lines(self, # Make array of timestamp ints if isinstance(dataframe.index, pd.PeriodIndex): - time = ((dataframe.index.to_timestamp().values.astype(np.int64) / + time = ((dataframe.index.to_timestamp().values.astype(np.int64) // precision_factor).astype(np.int64).astype(str)) else: - time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) / + time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) // precision_factor).astype(np.int64).astype(str)) # If tag columns exist, make an array of formatted tag keys and values @@ -439,16 +439,16 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'): return dframe def _datetime_to_epoch(self, datetime, time_precision='s'): - seconds = (datetime - self.EPOCH).total_seconds() + nanoseconds = (datetime - self.EPOCH).value if time_precision == 'h': - return seconds / 3600 + return np.int64(nanoseconds // 1e9 // 3600) elif time_precision == 'm': - return seconds / 60 + return np.int64(nanoseconds // 1e9 // 60) elif time_precision == 's': - return seconds + return np.int64(nanoseconds // 1e9) elif time_precision == 'ms': - return seconds * 1e3 + return np.int64(nanoseconds // 1e6) elif time_precision == 'u': - return seconds * 1e6 + return np.int64(nanoseconds // 1e3) elif time_precision == 'n': - return seconds * 1e9 + return nanoseconds diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index e8816fc0..15b6dcd4 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -13,7 +13,9 @@ from dateutil.parser import parse from six import iteritems, binary_type, text_type, integer_types, PY2 -EPOCH = UTC.localize(datetime.utcfromtimestamp(0)) +import pandas as pd # Provide for ns timestamps + +EPOCH = pd.Timestamp(0, tz='UTC') def _convert_timestamp(timestamp, precision=None): @@ -21,25 +23,29 @@ def _convert_timestamp(timestamp, precision=None): return timestamp # assume precision is correct if timestamp is int if isinstance(_get_unicode(timestamp), text_type): - timestamp = parse(timestamp) + timestamp = pd.Timestamp(timestamp) if isinstance(timestamp, datetime): if not timestamp.tzinfo: - timestamp = UTC.localize(timestamp) + timestamp = pd.Timestamp(timestamp, tz='UTC') - ns = (timestamp - EPOCH).total_seconds() * 1e9 + if isinstance(timestamp, pd._libs.tslib.Timestamp): + if not timestamp.tzinfo: + timestamp = pd.Timestamp(timestamp, tz = 'UTC') + + ns = (timestamp - EPOCH).value if precision is None or precision == 'n': return ns elif precision == 'u': - return ns / 1e3 + return ns // 1e3 elif precision == 'ms': - return ns / 1e6 + return ns // 1e6 elif precision == 's': - return ns / 1e9 + return ns // 1e9 elif precision == 'm': - return ns / 1e9 / 60 + return ns // 1e9 // 60 elif precision == 'h': - return ns / 1e9 / 3600 + return ns // 1e9 // 3600 raise ValueError(timestamp) From 6681e10888648c0a1268f3f4652e1e58b6c5fcde Mon Sep 17 00:00:00 2001 From: Anthony Uphof Date: Sun, 14 Oct 2018 14:07:19 +1300 Subject: [PATCH 02/15] [FIX] correct setuptools version for travis ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f3d4a5d..ee1c949f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,7 @@ matrix: install: - pip install tox-travis - - pip install setuptools==20.6.6 + - pip install setuptools==30.0.0 - pip install coveralls - mkdir -p "influxdb_install/${INFLUXDB_VER}" - if [ -n "${INFLUXDB_VER}" ] ; then wget "https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VER}_amd64.deb" ; fi From 5e99c09de8be6d910b86ad3861b7f64203c7a424 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Mon, 15 Oct 2018 09:05:49 +1300 Subject: [PATCH 03/15] [FIX] CI unit test failure - Test timezone in TestLineProtocol --- influxdb/line_protocol.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index 15b6dcd4..f4f9a1ba 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -25,14 +25,18 @@ def _convert_timestamp(timestamp, precision=None): if isinstance(_get_unicode(timestamp), text_type): timestamp = pd.Timestamp(timestamp) - if isinstance(timestamp, datetime): + if isinstance(timestamp, datetime): # change to pandas.Timestamp if not timestamp.tzinfo: timestamp = pd.Timestamp(timestamp, tz='UTC') + else: + timestamp = pd.Timestamp(timestamp) if isinstance(timestamp, pd._libs.tslib.Timestamp): - if not timestamp.tzinfo: + if not timestamp.tzinfo: # set to UTC for time since EPOCH timestamp = pd.Timestamp(timestamp, tz = 'UTC') - + else: + timestamp = timestamp.astimezone('UTC') + ns = (timestamp - EPOCH).value if precision is None or precision == 'n': return ns From b3b6fe702b31cd6bed847bc514d0f72801ab7e6c Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Mon, 15 Oct 2018 09:23:44 +1300 Subject: [PATCH 04/15] [ADD] list dependency on pandas for ns precision timestamp --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index d4f9611c..a94ab2d2 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,7 @@ Main dependency is: Additional dependencies are: - pandas: for writing from and reading to DataFrames (http://pandas.pydata.org/) +- pandas: for ns resolution of timepoints - Sphinx: Tool to create and manage the documentation (http://sphinx-doc.org/) - Nose: to auto-discover tests (http://nose.readthedocs.org/en/latest/) - Mock: to mock tests (https://pypi.python.org/pypi/mock) From b195e38e650b9b32bb0788a7ea7a2df5d8b0a696 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Mon, 15 Oct 2018 11:32:55 +1300 Subject: [PATCH 05/15] [FIX] unitests for (#649) ns precision timestamps --- influxdb/tests/client_test.py | 28 +++++++++---------- influxdb/tests/dataframe_client_test.py | 16 +++++------ influxdb/tests/test_line_protocol.py | 37 ++++++++++++++++++++----- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/influxdb/tests/client_test.py b/influxdb/tests/client_test.py index e27eef17..6613c385 100644 --- a/influxdb/tests/client_test.py +++ b/influxdb/tests/client_test.py @@ -90,7 +90,7 @@ def setUp(self): "host": "server01", "region": "us-west" }, - "time": "2009-11-10T23:00:00.123456Z", + "time": "2009-11-10 23:10:55.123456789", "fields": { "value": 0.64 } @@ -202,7 +202,7 @@ def test_write_points(self): ) self.assertEqual( 'cpu_load_short,host=server01,region=us-west ' - 'value=0.64 1257894000123456000\n', + 'value=0.64 1257894655123456789\n', m.last_request.body.decode('utf-8'), ) @@ -224,7 +224,7 @@ def test_write_points_toplevel_attributes(self): ) self.assertEqual( 'cpu_load_short,host=server01,region=us-west,tag=hello ' - 'value=0.64 1257894000123456000\n', + 'value=0.64 1257894655123456789\n', m.last_request.body.decode('utf-8'), ) @@ -273,7 +273,7 @@ def test_write_points_udp(self): self.assertEqual( 'cpu_load_short,host=server01,region=us-west ' - 'value=0.64 1257894000123456000\n', + 'value=0.64 1257894655123456789\n', received_data.decode() ) @@ -298,35 +298,35 @@ def test_write_points_with_precision(self): cli.write_points(self.dummy_points, time_precision='n') self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123456000\n', + b'value=0.64 1257894655123456789\n', m.last_request.body, ) cli.write_points(self.dummy_points, time_precision='u') self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123456\n', + b'value=0.64 1257894655123456\n', m.last_request.body, ) cli.write_points(self.dummy_points, time_precision='ms') self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123\n', + b'value=0.64 1257894655123\n', m.last_request.body, ) cli.write_points(self.dummy_points, time_precision='s') self.assertEqual( b"cpu_load_short,host=server01,region=us-west " - b"value=0.64 1257894000\n", + b"value=0.64 1257894655\n", m.last_request.body, ) cli.write_points(self.dummy_points, time_precision='m') self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 20964900\n', + b'value=0.64 20964910\n', m.last_request.body, ) @@ -352,7 +352,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123456000\n', + b'value=0.64 1257894655123456789\n', received_data, ) @@ -360,7 +360,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123456\n', + b'value=0.64 1257894655123456\n', received_data, ) @@ -368,7 +368,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894000123\n', + b'value=0.64 1257894655123\n', received_data, ) @@ -376,7 +376,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b"cpu_load_short,host=server01,region=us-west " - b"value=0.64 1257894000\n", + b"value=0.64 1257894655\n", received_data, ) @@ -384,7 +384,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 20964900\n', + b'value=0.64 20964910\n', received_data, ) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index 72447c89..84a7c86b 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -914,36 +914,36 @@ def test_get_list_database(self): def test_datetime_to_epoch(self): """Test convert datetime to epoch in TestDataFrameClient object.""" - timestamp = pd.Timestamp('2013-01-01 00:00:00.000+00:00') + timestamp = pd.Timestamp('2013-01-01 23:10:55.123456789+00:00') cli = DataFrameClient('host', 8086, 'username', 'password', 'db') self.assertEqual( cli._datetime_to_epoch(timestamp), - 1356998400.0 + 1357081855 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='h'), - 1356998400.0 / 3600 + 1357081855 // 3600 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='m'), - 1356998400.0 / 60 + 1357081855 // 60 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='s'), - 1356998400.0 + 1357081855 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='ms'), - 1356998400000.0 + 1357081855123 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='u'), - 1356998400000000.0 + 1357081855123456 ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='n'), - 1356998400000000000.0 + 1357081855123456789 ) def test_dsn_constructor(self): diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index a3d84793..44081f9d 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -11,7 +11,7 @@ from pytz import UTC, timezone from influxdb import line_protocol - +import pandas as pd class TestLineProtocol(unittest.TestCase): """Define the LineProtocol test object.""" @@ -48,31 +48,54 @@ def test_make_lines(self): def test_timezone(self): """Test timezone in TestLineProtocol object.""" + # datetime tests dt = datetime(2009, 11, 10, 23, 0, 0, 123456) utc = UTC.localize(dt) berlin = timezone('Europe/Berlin').localize(dt) eastern = berlin.astimezone(timezone('US/Eastern')) - data = { - "points": [ + # pandas ns timestamp tests + pddt = pd.Timestamp('2009-11-10 23:00:00.123456789') + pdutc = pd.Timestamp(pddt, tz = 'UTC') + pdberlin = pdutc.astimezone('Europe/Berlin') + pdeastern = pdberlin.astimezone('US/Eastern') + + data = { "points": [ {"measurement": "A", "fields": {"val": 1}, - "time": 0}, + "time": 0}, + #string representations {"measurement": "A", "fields": {"val": 1}, - "time": "2009-11-10T23:00:00.123456Z"}, + "time": "2009-11-10T23:00:00.123456Z"}, # String version for datetime + {"measurement": "A", "fields": {"val": 1}, + "time": "2009-11-10 23:00:00.123456789"}, # String version for pandas ns timestamp + # datetime {"measurement": "A", "fields": {"val": 1}, "time": dt}, {"measurement": "A", "fields": {"val": 1}, "time": utc}, {"measurement": "A", "fields": {"val": 1}, "time": berlin}, {"measurement": "A", "fields": {"val": 1}, "time": eastern}, - ] - } + # pandas timestamp + {"measurement": "A", "fields": {"val": 1}, "time": pddt}, + {"measurement": "A", "fields": {"val": 1}, "time": pdutc}, + {"measurement": "A", "fields": {"val": 1}, "time": pdberlin}, + {"measurement": "A", "fields": {"val": 1}, "time": pdeastern}, + ]} + + self.assertEqual( line_protocol.make_lines(data), '\n'.join([ 'A val=1i 0', 'A val=1i 1257894000123456000', + 'A val=1i 1257894000123456789', + #datetime results 'A val=1i 1257894000123456000', 'A val=1i 1257894000123456000', 'A val=1i 1257890400123456000', 'A val=1i 1257890400123456000', + #pandas ns timestamp results + 'A val=1i 1257894000123456789', + 'A val=1i 1257894000123456789', + 'A val=1i 1257894000123456789', + 'A val=1i 1257894000123456789', ]) + '\n' ) From e8f24089552b1d468560e8f652613e17575ced81 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Mon, 15 Oct 2018 13:15:24 +1300 Subject: [PATCH 06/15] [FIX] changes for flake8 compliance --- influxdb/line_protocol.py | 10 +++--- influxdb/tests/test_line_protocol.py | 48 +++++++++++++++------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index f4f9a1ba..13a80f6f 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -9,11 +9,9 @@ from datetime import datetime from numbers import Integral -from pytz import UTC -from dateutil.parser import parse from six import iteritems, binary_type, text_type, integer_types, PY2 -import pandas as pd # Provide for ns timestamps +import pandas as pd # Provide for ns timestamps EPOCH = pd.Timestamp(0, tz='UTC') @@ -25,15 +23,15 @@ def _convert_timestamp(timestamp, precision=None): if isinstance(_get_unicode(timestamp), text_type): timestamp = pd.Timestamp(timestamp) - if isinstance(timestamp, datetime): # change to pandas.Timestamp + if isinstance(timestamp, datetime): # change to pandas.Timestamp if not timestamp.tzinfo: timestamp = pd.Timestamp(timestamp, tz='UTC') else: timestamp = pd.Timestamp(timestamp) if isinstance(timestamp, pd._libs.tslib.Timestamp): - if not timestamp.tzinfo: # set to UTC for time since EPOCH - timestamp = pd.Timestamp(timestamp, tz = 'UTC') + if not timestamp.tzinfo: # set to UTC for time since EPOCH + timestamp = pd.Timestamp(timestamp, tz='UTC') else: timestamp = timestamp.astimezone('UTC') diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index 44081f9d..10796044 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -13,6 +13,7 @@ from influxdb import line_protocol import pandas as pd + class TestLineProtocol(unittest.TestCase): """Define the LineProtocol test object.""" @@ -55,30 +56,31 @@ def test_timezone(self): eastern = berlin.astimezone(timezone('US/Eastern')) # pandas ns timestamp tests pddt = pd.Timestamp('2009-11-10 23:00:00.123456789') - pdutc = pd.Timestamp(pddt, tz = 'UTC') + pdutc = pd.Timestamp(pddt, tz='UTC') pdberlin = pdutc.astimezone('Europe/Berlin') pdeastern = pdberlin.astimezone('US/Eastern') - data = { "points": [ - {"measurement": "A", "fields": {"val": 1}, - "time": 0}, - #string representations - {"measurement": "A", "fields": {"val": 1}, - "time": "2009-11-10T23:00:00.123456Z"}, # String version for datetime - {"measurement": "A", "fields": {"val": 1}, - "time": "2009-11-10 23:00:00.123456789"}, # String version for pandas ns timestamp - # datetime - {"measurement": "A", "fields": {"val": 1}, "time": dt}, - {"measurement": "A", "fields": {"val": 1}, "time": utc}, - {"measurement": "A", "fields": {"val": 1}, "time": berlin}, - {"measurement": "A", "fields": {"val": 1}, "time": eastern}, - # pandas timestamp - {"measurement": "A", "fields": {"val": 1}, "time": pddt}, - {"measurement": "A", "fields": {"val": 1}, "time": pdutc}, - {"measurement": "A", "fields": {"val": 1}, "time": pdberlin}, - {"measurement": "A", "fields": {"val": 1}, "time": pdeastern}, - ]} - + data = {"points": [ + {"measurement": "A", "fields": {"val": 1}, "time": 0}, + # string representations + # String version for datetime + {"measurement": "A", "fields": {"val": 1}, + "time": "2009-11-10T23:00:00.123456Z"}, + # String version for pandas ns timestamp + {"measurement": "A", "fields": {"val": 1}, + "time": "2009-11-10 23:00:00.123456789"}, + # datetime + {"measurement": "A", "fields": {"val": 1}, "time": dt}, + {"measurement": "A", "fields": {"val": 1}, "time": utc}, + {"measurement": "A", "fields": {"val": 1}, "time": berlin}, + {"measurement": "A", "fields": {"val": 1}, "time": eastern}, + # pandas timestamp + {"measurement": "A", "fields": {"val": 1}, "time": pddt}, + {"measurement": "A", "fields": {"val": 1}, "time": pdutc}, + {"measurement": "A", "fields": {"val": 1}, "time": pdberlin}, + {"measurement": "A", "fields": {"val": 1}, "time": pdeastern}, + ] + } self.assertEqual( line_protocol.make_lines(data), @@ -86,12 +88,12 @@ def test_timezone(self): 'A val=1i 0', 'A val=1i 1257894000123456000', 'A val=1i 1257894000123456789', - #datetime results + # datetime results 'A val=1i 1257894000123456000', 'A val=1i 1257894000123456000', 'A val=1i 1257890400123456000', 'A val=1i 1257890400123456000', - #pandas ns timestamp results + # pandas ns timestamp results 'A val=1i 1257894000123456789', 'A val=1i 1257894000123456789', 'A val=1i 1257894000123456789', From dd039aa571a15b43ae16799dbb2da6a302731016 Mon Sep 17 00:00:00 2001 From: Anthony Uphof Date: Wed, 24 Apr 2019 15:16:28 +1200 Subject: [PATCH 07/15] [IMP] tests for microsecond convert The changes highlight issue brought up by @tpietruszka requiring precision factor to be of type int as apposed to currently float https://github.com/influxdata/influxdb-python/pull/650#issuecomment-485915261 --- influxdb/tests/client_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/influxdb/tests/client_test.py b/influxdb/tests/client_test.py index 3fdbabc3..9aeaa095 100644 --- a/influxdb/tests/client_test.py +++ b/influxdb/tests/client_test.py @@ -90,7 +90,7 @@ def setUp(self): "host": "server01", "region": "us-west" }, - "time": "2009-11-10 23:10:55.123456789", + "time": "2009-11-10 23:10:55.123456987", "fields": { "value": 0.64 } @@ -202,7 +202,7 @@ def test_write_points(self): ) self.assertEqual( 'cpu_load_short,host=server01,region=us-west ' - 'value=0.64 1257894655123456789\n', + 'value=0.64 1257894655123456987\n', m.last_request.body.decode('utf-8'), ) @@ -224,7 +224,7 @@ def test_write_points_toplevel_attributes(self): ) self.assertEqual( 'cpu_load_short,host=server01,region=us-west,tag=hello ' - 'value=0.64 1257894655123456789\n', + 'value=0.64 1257894655123456987\n', m.last_request.body.decode('utf-8'), ) @@ -273,7 +273,7 @@ def test_write_points_udp(self): self.assertEqual( 'cpu_load_short,host=server01,region=us-west ' - 'value=0.64 1257894655123456789\n', + 'value=0.64 1257894655123456987\n', received_data.decode() ) @@ -298,7 +298,7 @@ def test_write_points_with_precision(self): cli.write_points(self.dummy_points, time_precision='n') self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894655123456789\n', + b'value=0.64 1257894655123456987\n', m.last_request.body, ) @@ -352,7 +352,7 @@ def test_write_points_with_precision_udp(self): received_data, addr = s.recvfrom(1024) self.assertEqual( b'cpu_load_short,host=server01,region=us-west ' - b'value=0.64 1257894655123456789\n', + b'value=0.64 1257894655123456987\n', received_data, ) From b8df1f9e4d19397f7d339e65138d2547c33cbe0b Mon Sep 17 00:00:00 2001 From: Anthony Uphof Date: Wed, 24 Apr 2019 15:20:56 +1200 Subject: [PATCH 08/15] [IMP] tests for microsecond convert The changes highlight issue brought up by @tpietruszka requiring precision factor to be of type int as apposed to currently float https://github.com/influxdata/influxdb-python/pull/650#issuecomment-485915261 --- influxdb/tests/dataframe_client_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index ab931caa..f7aca6ef 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -930,7 +930,7 @@ def test_get_list_database(self): def test_datetime_to_epoch(self): """Test convert datetime to epoch in TestDataFrameClient object.""" - timestamp = pd.Timestamp('2013-01-01 23:10:55.123456789+00:00') + timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') cli = DataFrameClient('host', 8086, 'username', 'password', 'db') self.assertEqual( @@ -959,7 +959,7 @@ def test_datetime_to_epoch(self): ) self.assertEqual( cli._datetime_to_epoch(timestamp, time_precision='n'), - 1357081855123456789 + 1357081855123456987 ) def test_dsn_constructor(self): From 6643b09daaf0853f3721ffd47927e78e75e67ce9 Mon Sep 17 00:00:00 2001 From: Anthony Uphof Date: Wed, 24 Apr 2019 15:23:12 +1200 Subject: [PATCH 09/15] [IMP] tests for microsecond convert The changes highlight issue brought up by @tpietruszka requiring precision factor to be of type int as apposed to currently float https://github.com/influxdata/influxdb-python/pull/650#issuecomment-485915261 --- influxdb/tests/test_line_protocol.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index 10796044..879b7988 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -68,7 +68,7 @@ def test_timezone(self): "time": "2009-11-10T23:00:00.123456Z"}, # String version for pandas ns timestamp {"measurement": "A", "fields": {"val": 1}, - "time": "2009-11-10 23:00:00.123456789"}, + "time": "2009-11-10 23:00:00.123456987"}, # datetime {"measurement": "A", "fields": {"val": 1}, "time": dt}, {"measurement": "A", "fields": {"val": 1}, "time": utc}, @@ -87,17 +87,17 @@ def test_timezone(self): '\n'.join([ 'A val=1i 0', 'A val=1i 1257894000123456000', - 'A val=1i 1257894000123456789', + 'A val=1i 1257894000123456987', # datetime results 'A val=1i 1257894000123456000', 'A val=1i 1257894000123456000', 'A val=1i 1257890400123456000', 'A val=1i 1257890400123456000', # pandas ns timestamp results - 'A val=1i 1257894000123456789', - 'A val=1i 1257894000123456789', - 'A val=1i 1257894000123456789', - 'A val=1i 1257894000123456789', + 'A val=1i 1257894000123456987', + 'A val=1i 1257894000123456987', + 'A val=1i 1257894000123456987', + 'A val=1i 1257894000123456987', ]) + '\n' ) From 460312701d9c901268fda7325c5830baca6ad45f Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Thu, 10 Oct 2019 09:31:02 +1300 Subject: [PATCH 10/15] [IMP] update Test for timestamp conversions also updated inline docs detail significance of precision factor to be of type int --- influxdb/tests/dataframe_client_test.py | 14 ++++++- influxdb/tests/test_line_protocol.py | 51 +++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index f7aca6ef..c1df4e2a 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -929,7 +929,19 @@ def test_get_list_database(self): ) def test_datetime_to_epoch(self): - """Test convert datetime to epoch in TestDataFrameClient object.""" + """Test convert datetime to epoch in TestDataFrameClient object. + Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation + Choosing the test value is important that nanosecond resolution values are greater than 895ns + Example : the issue is only observable ns > 895ns + # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') + # ts_ns = np.int64(ts.value) + # # For conversion to microsecond + # precision_factor=1e3 + # expected_ts_us = 1357081855123456 + # np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 + # np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + + """ timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') cli = DataFrameClient('host', 8086, 'username', 'password', 'db') diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index 879b7988..a08973aa 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -47,6 +47,57 @@ def test_make_lines(self): 'bool_val=True,float_val=1.1,int_val=1i,string_val="hello!"\n' ) + def test_convert_timestamp(self): + """Test line_protocol _convert_timestamp + Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation + Choosing the test value is important that nanosecond resolution values are greater than 895ns + Example : the issue is only observable ns > 895ns + # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') + # ts_ns = np.int64(ts.value) + # # For conversion to microsecond + # precision_factor=1e3 + # expected_ts_us = 1357081855123456 + # np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 + # np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + + """ + + #TODO: add test for timestamp isinstance(timestamp, Integral) + #TODO: add test for timestamp isinstance(_get_unicode(timestamp), text_type) + #TODO: add test for timestamp isinstance(timestamp, datetime) also include test tzinfo present or not + + + + timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') + self.assertEqual( + line_protocol._convert_timestamp(timestamp), + 1357081855123456987 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='h'), + 1357081855 // 3600 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='m'), + 1357081855 // 60 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='s'), + 1357081855 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='ms'), + 1357081855123 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='u'), + 1357081855123456 + ) + self.assertEqual( + line_protocol._convert_timestamp(timestamp, time_precision='n'), + 1357081855123456987 + ) + def test_timezone(self): """Test timezone in TestLineProtocol object.""" # datetime tests From 843fd333d9bc59b26b602619ac7c5647ee717444 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Thu, 10 Oct 2019 09:40:35 +1300 Subject: [PATCH 11/15] [FIX] issue of incorrect conversion due to floats. as identified by @tpietruszka when precision factor is a float, result is an approximation. also define precision factors in 1 place as int's and improved consistency in usage. --- influxdb/_dataframe_client.py | 53 ++++++++++++++++------------------- influxdb/line_protocol.py | 41 ++++++++++++++++----------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 0f06c108..37bf9357 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -15,6 +15,25 @@ from .client import InfluxDBClient from .line_protocol import _escape_tag +# Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation +# Example : the issue is only observable with nanosecond resolution values are greater than 895ns +# ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') +# ts_ns = np.int64(ts.value) +# # For conversion to microsecond +# precision_factor=1e3 +# expected_ts_us = 1357081855123456 +# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 +# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + +_time_precision_factors = { + "n": 1, + "u": np.int64(1e3), + "ms": np.int64(1e6), + "s": np.int64(1e9), + "m": np.int64(1e9 * 60), + "h": np.int64( 1e9 * 3600), + } + def _pandas_time_unit(time_precision): unit = time_precision @@ -261,14 +280,7 @@ def _convert_dataframe_to_json(dataframe, # Convert dtype for json serialization dataframe = dataframe.astype('object') - precision_factor = { - "n": 1, - "u": 1e3, - "ms": 1e6, - "s": 1e9, - "m": 1e9 * 60, - "h": 1e9 * 3600, - }.get(time_precision, 1) + precision_factor =_time_precision_factors.get(time_precision, 1) points = [ {'measurement': measurement, @@ -331,18 +343,11 @@ def _convert_dataframe_to_lines(self, field_columns = list(column_series[~column_series.isin( tag_columns)]) - precision_factor = { - "n": 1, - "u": 1e3, - "ms": 1e6, - "s": 1e9, - "m": 1e9 * 60, - "h": 1e9 * 3600, - }.get(time_precision, 1) + precision_factor =_time_precision_factors.get(time_precision, 1) # Make array of timestamp ints if isinstance(dataframe.index, pd.PeriodIndex): - time = ((dataframe.index.to_timestamp().values.astype(np.int64) // + time = ((dataframe.index.to_timestamp().values.astype(np.int64) // precision_factor).astype(np.int64).astype(str)) else: time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) // @@ -453,15 +458,5 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'): def _datetime_to_epoch(self, datetime, time_precision='s'): nanoseconds = (datetime - self.EPOCH).value - if time_precision == 'h': - return np.int64(nanoseconds // 1e9 // 3600) - elif time_precision == 'm': - return np.int64(nanoseconds // 1e9 // 60) - elif time_precision == 's': - return np.int64(nanoseconds // 1e9) - elif time_precision == 'ms': - return np.int64(nanoseconds // 1e6) - elif time_precision == 'u': - return np.int64(nanoseconds // 1e3) - elif time_precision == 'n': - return nanoseconds + precision_factor =_time_precision_factors.get(time_precision, 1) + return np.int64(nanoseconds // np.int64(precision_factor)) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index 13a80f6f..1bb0957d 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -12,11 +12,31 @@ from six import iteritems, binary_type, text_type, integer_types, PY2 import pandas as pd # Provide for ns timestamps +import numpy as np # Provided for accurate precision_factor conversion EPOCH = pd.Timestamp(0, tz='UTC') - -def _convert_timestamp(timestamp, precision=None): +# Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation +# Example : the issue is only observable with nanosecond resolution values are greater than 895ns +# ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') +# ts_ns = np.int64(ts.value) +# # For conversion to microsecond +# precision_factor=1e3 +# expected_ts_us = 1357081855123456 +# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 +# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + +_time_precision_factors = { + "n": 1, + "u": np.int64(1e3), + "ms": np.int64(1e6), + "s": np.int64(1e9), + "m": np.int64(1e9 * 60), + "h": np.int64( 1e9 * 3600), + } + + +def _convert_timestamp(timestamp, time_precision=None): if isinstance(timestamp, Integral): return timestamp # assume precision is correct if timestamp is int @@ -35,20 +55,9 @@ def _convert_timestamp(timestamp, precision=None): else: timestamp = timestamp.astimezone('UTC') - ns = (timestamp - EPOCH).value - if precision is None or precision == 'n': - return ns - elif precision == 'u': - return ns // 1e3 - elif precision == 'ms': - return ns // 1e6 - elif precision == 's': - return ns // 1e9 - elif precision == 'm': - return ns // 1e9 // 60 - elif precision == 'h': - return ns // 1e9 // 3600 - + nanoseconds = (timestamp - EPOCH).value + precision_factor =_time_precision_factors.get(time_precision, 1) + return np.int64(nanoseconds // np.int64(precision_factor)) raise ValueError(timestamp) From f22ddfff701a34bb657a300ceff2d21a7d518fd9 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Thu, 10 Oct 2019 09:59:01 +1300 Subject: [PATCH 12/15] [FIX] test failure --- influxdb/tests/test_line_protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index a08973aa..1b6ed9f4 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -106,7 +106,7 @@ def test_timezone(self): berlin = timezone('Europe/Berlin').localize(dt) eastern = berlin.astimezone(timezone('US/Eastern')) # pandas ns timestamp tests - pddt = pd.Timestamp('2009-11-10 23:00:00.123456789') + pddt = pd.Timestamp('2009-11-10 23:00:00.123456987') pdutc = pd.Timestamp(pddt, tz='UTC') pdberlin = pdutc.astimezone('Europe/Berlin') pdeastern = pdberlin.astimezone('US/Eastern') From bf88766aea0e899c13cc69efeaa120a71f2df02a Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Thu, 10 Oct 2019 14:10:40 +1300 Subject: [PATCH 13/15] [FIX] CI PEP257 and FLAKE8 issues --- influxdb/line_protocol.py | 28 ++++++++++++------------- influxdb/tests/dataframe_client_test.py | 14 +++++++++---- influxdb/tests/test_line_protocol.py | 24 +++++++++++++-------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index 1bb0957d..17aea997 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -12,28 +12,28 @@ from six import iteritems, binary_type, text_type, integer_types, PY2 import pandas as pd # Provide for ns timestamps -import numpy as np # Provided for accurate precision_factor conversion +import numpy as np # Provided for accurate precision_factor conversion EPOCH = pd.Timestamp(0, tz='UTC') -# Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation -# Example : the issue is only observable with nanosecond resolution values are greater than 895ns +# Precisions factors must be int for correct calculation to ints. +# if precision is float the result of a floor calc is an approximation +# Example : the issue is only observable with nanosecond resolution +# values are greater than 895ns # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') # ts_ns = np.int64(ts.value) # # For conversion to microsecond # precision_factor=1e3 # expected_ts_us = 1357081855123456 -# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 -# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 +# np.int64(ts_ns // precision_factor) # is INCORRECT 1357081855123457 +# np.int64(ts_ns // np.int64(precision_factor) # is CORRECT 1357081855123456 -_time_precision_factors = { - "n": 1, - "u": np.int64(1e3), - "ms": np.int64(1e6), - "s": np.int64(1e9), - "m": np.int64(1e9 * 60), - "h": np.int64( 1e9 * 3600), - } +_time_precision_factors = {"n": 1, + "u": np.int64(1e3), + "ms": np.int64(1e6), + "s": np.int64(1e9), + "m": np.int64(1e9 * 60), + "h": np.int64(1e9 * 3600), } def _convert_timestamp(timestamp, time_precision=None): @@ -56,7 +56,7 @@ def _convert_timestamp(timestamp, time_precision=None): timestamp = timestamp.astimezone('UTC') nanoseconds = (timestamp - EPOCH).value - precision_factor =_time_precision_factors.get(time_precision, 1) + precision_factor = _time_precision_factors.get(time_precision, 1) return np.int64(nanoseconds // np.int64(precision_factor)) raise ValueError(timestamp) diff --git a/influxdb/tests/dataframe_client_test.py b/influxdb/tests/dataframe_client_test.py index c1df4e2a..20124125 100644 --- a/influxdb/tests/dataframe_client_test.py +++ b/influxdb/tests/dataframe_client_test.py @@ -930,16 +930,22 @@ def test_get_list_database(self): def test_datetime_to_epoch(self): """Test convert datetime to epoch in TestDataFrameClient object. - Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation - Choosing the test value is important that nanosecond resolution values are greater than 895ns + + Precisions factors must be int for correct calculation to ints. + if precision is float the result of a floor calc is an approximation + Choosing the test value is important that nanosecond resolution + values are greater than 895ns + Example : the issue is only observable ns > 895ns # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') # ts_ns = np.int64(ts.value) # # For conversion to microsecond # precision_factor=1e3 # expected_ts_us = 1357081855123456 - # np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 - # np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + # following is INCORRECT 1357081855123457 + # np.int64(ts_ns // precision_factor) + # following is CORRECT 1357081855123456 + # np.int64(ts_ns // np.int64(precision_factor) """ timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') diff --git a/influxdb/tests/test_line_protocol.py b/influxdb/tests/test_line_protocol.py index 1b6ed9f4..34f0db00 100644 --- a/influxdb/tests/test_line_protocol.py +++ b/influxdb/tests/test_line_protocol.py @@ -49,24 +49,30 @@ def test_make_lines(self): def test_convert_timestamp(self): """Test line_protocol _convert_timestamp - Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation - Choosing the test value is important that nanosecond resolution values are greater than 895ns + + Precisions factors must be int for correct calculation to ints. if + precision is float the result of a floor calc is an approximation + Choosing the test value is important that nanosecond resolution values + are greater than 895ns + Example : the issue is only observable ns > 895ns # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') # ts_ns = np.int64(ts.value) # # For conversion to microsecond # precision_factor=1e3 # expected_ts_us = 1357081855123456 - # np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 - # np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 + # # following is INCORRECT 1357081855123457 + # np.int64(ts_ns // precision_factor) + # # following is CORRECT 1357081855123456 + # np.int64(ts_ns // np.int64(precision_factor) """ - #TODO: add test for timestamp isinstance(timestamp, Integral) - #TODO: add test for timestamp isinstance(_get_unicode(timestamp), text_type) - #TODO: add test for timestamp isinstance(timestamp, datetime) also include test tzinfo present or not - - + # TODO: add tests for timestamp instances + # 1) isinstance(timestamp, Integral) + # 2) isinstance(_get_unicode(timestamp), text_type) + # 3) isinstance(timestamp, datetime) with tzinfo + # 4) isinstance(timestamp, datetime) without tzinfo timestamp = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') self.assertEqual( From 7e161e275782fb0242c78a84236e18ec0de76026 Mon Sep 17 00:00:00 2001 From: "BSF-PC-AU1\\BSFau" Date: Thu, 10 Oct 2019 14:21:35 +1300 Subject: [PATCH 14/15] [FIX] CI further Flake8 fixes --- influxdb/_dataframe_client.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/influxdb/_dataframe_client.py b/influxdb/_dataframe_client.py index 37bf9357..f2024a34 100644 --- a/influxdb/_dataframe_client.py +++ b/influxdb/_dataframe_client.py @@ -15,24 +15,26 @@ from .client import InfluxDBClient from .line_protocol import _escape_tag -# Precisions factors must be int for correct calculation to ints. if float the result of a floor calc is an approximation -# Example : the issue is only observable with nanosecond resolution values are greater than 895ns +# Precisions factors must be int for correct calculation to ints. +# if precision is a float the result of a floor calc is an approximation +# Example : the issue is only observable with nanosecond resolution +# values are greater than 895ns # ts = pd.Timestamp('2013-01-01 23:10:55.123456987+00:00') # ts_ns = np.int64(ts.value) # # For conversion to microsecond # precision_factor=1e3 # expected_ts_us = 1357081855123456 -# np.int64(ts_ns // precision_factor) # results in INCORRECT 1357081855123457 -# np.int64(ts_ns // np.int64(precision_factor) # results in CORRECT 1357081855123456 +# # following is INCORRECT 1357081855123457 +# np.int64(ts_ns // precision_factor) +# # following is CORRECT 1357081855123456 +# np.int64(ts_ns // np.int64(precision_factor) -_time_precision_factors = { - "n": 1, - "u": np.int64(1e3), - "ms": np.int64(1e6), - "s": np.int64(1e9), - "m": np.int64(1e9 * 60), - "h": np.int64( 1e9 * 3600), - } +_time_precision_factors = {"n": 1, + "u": np.int64(1e3), + "ms": np.int64(1e6), + "s": np.int64(1e9), + "m": np.int64(1e9 * 60), + "h": np.int64(1e9 * 3600), } def _pandas_time_unit(time_precision): @@ -280,7 +282,7 @@ def _convert_dataframe_to_json(dataframe, # Convert dtype for json serialization dataframe = dataframe.astype('object') - precision_factor =_time_precision_factors.get(time_precision, 1) + precision_factor = _time_precision_factors.get(time_precision, 1) points = [ {'measurement': measurement, @@ -343,11 +345,11 @@ def _convert_dataframe_to_lines(self, field_columns = list(column_series[~column_series.isin( tag_columns)]) - precision_factor =_time_precision_factors.get(time_precision, 1) + precision_factor = _time_precision_factors.get(time_precision, 1) # Make array of timestamp ints if isinstance(dataframe.index, pd.PeriodIndex): - time = ((dataframe.index.to_timestamp().values.astype(np.int64) // + time = ((dataframe.index.to_timestamp().values.astype(np.int64) // precision_factor).astype(np.int64).astype(str)) else: time = ((pd.to_datetime(dataframe.index).values.astype(np.int64) // @@ -458,5 +460,5 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'): def _datetime_to_epoch(self, datetime, time_precision='s'): nanoseconds = (datetime - self.EPOCH).value - precision_factor =_time_precision_factors.get(time_precision, 1) + precision_factor = _time_precision_factors.get(time_precision, 1) return np.int64(nanoseconds // np.int64(precision_factor)) From d11956a837cba9c7b2650064096d61e3236eaf40 Mon Sep 17 00:00:00 2001 From: Sebastian Borza Date: Wed, 8 Apr 2020 15:13:39 -0500 Subject: [PATCH 15/15] remove unnecessary inclusion of iteritems This was removed in an upstream PR but reintroduced incorrectly here. --- influxdb/line_protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/line_protocol.py b/influxdb/line_protocol.py index 22946787..02ad23fd 100644 --- a/influxdb/line_protocol.py +++ b/influxdb/line_protocol.py @@ -8,7 +8,7 @@ from datetime import datetime from numbers import Integral -from six import iteritems, binary_type, text_type, integer_types, PY2 +from six import binary_type, text_type, integer_types, PY2 import pandas as pd # Provide for ns timestamps import numpy as np # Provided for accurate precision_factor conversion