Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit f9bd6cc

Browse files
Guillaume Ansanay-Alexaviau
authored andcommitted
Fix pandas calls + New test suite + Test against InfluxDB v1.1.0 (#388) (Thanks @gansanay!)
* pandas .to_datetime() is deprecated as of 0.19.0 See http://pandas.pydata.org/pandas-docs/version/0.19.1/whatsnew.html#deprecations * pandas 0.19.x breaks python 3.3 compatibility * pypy3 - pip requires Python >= 2.6 or >= 3.3 Using Python 3.4 for Travis build * Use 'language' syntax for Travis CI configuration * Fix silly error * Define new test matrix * Fix build language environments for pypy, pypy3 * Display error logs for pypy builds * Test newer versions of pypy and pypy3 * Try to fix calls to coverage/docs/flake8 * Test setting VERSION * Acknowledging the issue in Travis-CI travis-ci/travis-ci#6304 Commenting out pypy3 test * Get InfluxDB 1.1.0 * Default retetion policy name and duration unit have changed in InfluxDB * Default retention name and policy duration, again * Altering retention policy doesn't change shard group duration * Fix styling * Fix coverage link in README * Put initial coverage link back * Update README: v1.1.0 is the recommended version of InfluxDB
1 parent d3069e8 commit f9bd6cc

File tree

6 files changed

+65
-42
lines changed

6 files changed

+65
-42
lines changed

.travis.yml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
language: python
2+
23
addons:
34
apt:
45
packages:
56
- wget
6-
env:
7-
- TOX_ENV=py27
8-
# - TOX_ENV=py32
9-
# Disabling py32 tests until the following issue is fixed:
10-
# pip 8.x breaks python 3.2 compatibility
11-
# https://github.com/pypa/pip/issues/3390
12-
- TOX_ENV=py33
13-
- TOX_ENV=py34
14-
- TOX_ENV=pypy
15-
- TOX_ENV=pypy3
16-
- TOX_ENV=docs
17-
- TOX_ENV=flake8
18-
- TOX_ENV=coverage
7+
8+
matrix:
9+
include:
10+
- python: 2.7
11+
env: TOX_ENV=py27
12+
- python: pypy-5.3.1
13+
env: TOX_ENV=pypy
14+
- python: 3.4
15+
env: TOX_ENV=py34
16+
# An issue in travis-ci prevents this case from running
17+
# Link to issue: https://github.com/travis-ci/travis-ci/issues/6304
18+
# - python: pypy3.3-5.2-alpha1
19+
# env: TOX_ENV=pypy3
20+
- python: 3.4
21+
env: TOX_ENV=docs
22+
- python: 3.4
23+
env: TOX_ENV=flake8
24+
- python: 3.4
25+
env: TOX_ENV=coverage
26+
1927
install:
2028
- pip install tox
2129
- pip install coveralls
2230
- mkdir influxdb_install
23-
- wget https://dl.influxdata.com/influxdb/releases/influxdb_0.13.0_amd64.deb
31+
- wget https://dl.influxdata.com/influxdb/releases/influxdb_1.1.0_amd64.deb
2432
- dpkg -x influxdb*.deb influxdb_install
2533
script:
2634
- export INFLUXDB_PYTHON_INFLUXD_PATH=$(pwd)/influxdb_install/usr/bin/influxd
27-
- travis_wait 30 tox -e $TOX_ENV
35+
- tox -e $TOX_ENV
2836
after_success:
2937
- if [ "$TOX_ENV" == "coverage" ] ; then coveralls; fi
3038
notifications:

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ InfluxDB is an open-source distributed time series database, find more about Inf
2222

2323
.. _installation:
2424

25-
InfluxDB v0.8.X users
26-
=====================
25+
InfluxDB pre v1.1.0 users
26+
=========================
2727

28-
InfluxDB 0.9 was released and it is the new recommended version. However, InfluxDB 0.8.x users may still use the legacy client by using ``from influxdb.influxdb08 import InfluxDBClient`` instead.
28+
InfluxDB 1.1.0 was released and it is the new recommended version. InfluxDB 0.8.x users may still use the legacy client by using ``from influxdb.influxdb08 import InfluxDBClient`` instead.
2929

3030
Installation
3131
============

influxdb/_dataframe_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ def _convert_dataframe_to_lines(self,
273273
}.get(time_precision, 1)
274274

275275
# Make array of timestamp ints
276-
time = ((dataframe.index.to_datetime().values.astype(int) /
277-
precision_factor).astype(int).astype(str))
276+
if isinstance(dataframe.index, pd.tseries.period.PeriodIndex):
277+
time = ((dataframe.index.to_timestamp().values.astype(int) /
278+
precision_factor).astype(int).astype(str))
279+
else:
280+
time = ((pd.to_datetime(dataframe.index).values.astype(int) /
281+
precision_factor).astype(int).astype(str))
278282

279283
# If tag columns exist, make an array of formatted tag keys and values
280284
if tag_columns:

influxdb/influxdb08/dataframe_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ def _convert_dataframe_to_json(self, dataframe, name, time_precision='s'):
132132
isinstance(dataframe.index, pd.tseries.index.DatetimeIndex)):
133133
raise TypeError('Must be DataFrame with DatetimeIndex or \
134134
PeriodIndex.')
135-
dataframe.index = dataframe.index.to_datetime()
135+
136+
if isinstance(dataframe.index, pd.tseries.period.PeriodIndex):
137+
dataframe.index = dataframe.index.to_timestamp()
138+
else:
139+
dataframe.index = pd.to_datetime(dataframe.index)
140+
136141
if dataframe.index.tzinfo is None:
137142
dataframe.index = dataframe.index.tz_localize('UTC')
138143
dataframe['time'] = [self._datetime_to_epoch(dt, time_precision)

influxdb/tests/server_tests/client_test_with_server.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ def test_default_retention_policy(self):
431431
rsp = self.cli.get_list_retention_policies()
432432
self.assertEqual(
433433
[
434-
{'name': 'default',
435-
'duration': '0',
434+
{'name': 'autogen',
435+
'duration': '0s',
436436
'replicaN': 1,
437437
'shardGroupDuration': u'168h0m0s',
438438
'default': True}
@@ -447,11 +447,11 @@ def test_create_retention_policy_default(self):
447447

448448
self.assertEqual(
449449
[
450-
{'duration': '0',
450+
{'duration': '0s',
451451
'default': False,
452452
'replicaN': 1,
453453
'shardGroupDuration': u'168h0m0s',
454-
'name': 'default'},
454+
'name': 'autogen'},
455455
{'duration': '24h0m0s',
456456
'default': True,
457457
'replicaN': 1,
@@ -468,14 +468,17 @@ def test_create_retention_policy_default(self):
468468

469469
def test_create_retention_policy(self):
470470
self.cli.create_retention_policy('somename', '1d', 1)
471+
# NB: creating a retention policy without specifying
472+
# shard group duration
473+
# leads to a shard group duration of 1 hour
471474
rsp = self.cli.get_list_retention_policies()
472475
self.assertEqual(
473476
[
474-
{'duration': '0',
477+
{'duration': '0s',
475478
'default': True,
476479
'replicaN': 1,
477480
'shardGroupDuration': u'168h0m0s',
478-
'name': 'default'},
481+
'name': 'autogen'},
479482
{'duration': '24h0m0s',
480483
'default': False,
481484
'replicaN': 1,
@@ -491,18 +494,19 @@ def test_alter_retention_policy(self):
491494
# Test alter duration
492495
self.cli.alter_retention_policy('somename', 'db',
493496
duration='4d')
497+
# NB: altering retention policy doesn't change shard group duration
494498
rsp = self.cli.get_list_retention_policies()
495499
self.assertEqual(
496500
[
497-
{'duration': '0',
501+
{'duration': '0s',
498502
'default': True,
499503
'replicaN': 1,
500504
'shardGroupDuration': u'168h0m0s',
501-
'name': 'default'},
505+
'name': 'autogen'},
502506
{'duration': '96h0m0s',
503507
'default': False,
504508
'replicaN': 1,
505-
'shardGroupDuration': u'24h0m0s',
509+
'shardGroupDuration': u'1h0m0s',
506510
'name': 'somename'}
507511
],
508512
rsp
@@ -511,18 +515,19 @@ def test_alter_retention_policy(self):
511515
# Test alter replication
512516
self.cli.alter_retention_policy('somename', 'db',
513517
replication=4)
518+
# NB: altering retention policy doesn't change shard group duration
514519
rsp = self.cli.get_list_retention_policies()
515520
self.assertEqual(
516521
[
517-
{'duration': '0',
522+
{'duration': '0s',
518523
'default': True,
519524
'replicaN': 1,
520525
'shardGroupDuration': u'168h0m0s',
521-
'name': 'default'},
526+
'name': 'autogen'},
522527
{'duration': '96h0m0s',
523528
'default': False,
524529
'replicaN': 4,
525-
'shardGroupDuration': u'24h0m0s',
530+
'shardGroupDuration': u'1h0m0s',
526531
'name': 'somename'}
527532
],
528533
rsp
@@ -531,18 +536,19 @@ def test_alter_retention_policy(self):
531536
# Test alter default
532537
self.cli.alter_retention_policy('somename', 'db',
533538
default=True)
539+
# NB: altering retention policy doesn't change shard group duration
534540
rsp = self.cli.get_list_retention_policies()
535541
self.assertEqual(
536542
[
537-
{'duration': '0',
543+
{'duration': '0s',
538544
'default': False,
539545
'replicaN': 1,
540546
'shardGroupDuration': u'168h0m0s',
541-
'name': 'default'},
547+
'name': 'autogen'},
542548
{'duration': '96h0m0s',
543549
'default': True,
544550
'replicaN': 4,
545-
'shardGroupDuration': u'24h0m0s',
551+
'shardGroupDuration': u'1h0m0s',
546552
'name': 'somename'}
547553
],
548554
rsp
@@ -558,11 +564,11 @@ def test_alter_retention_policy_invalid(self):
558564
rsp = self.cli.get_list_retention_policies()
559565
self.assertEqual(
560566
[
561-
{'duration': '0',
567+
{'duration': '0s',
562568
'default': True,
563569
'replicaN': 1,
564570
'shardGroupDuration': u'168h0m0s',
565-
'name': 'default'},
571+
'name': 'autogen'},
566572
{'duration': '24h0m0s',
567573
'default': False,
568574
'replicaN': 1,
@@ -580,11 +586,11 @@ def test_drop_retention_policy(self):
580586
rsp = self.cli.get_list_retention_policies()
581587
self.assertEqual(
582588
[
583-
{'duration': '0',
589+
{'duration': '0s',
584590
'default': True,
585591
'replicaN': 1,
586592
'shardGroupDuration': u'168h0m0s',
587-
'name': 'default'}
593+
'name': 'autogen'}
588594
],
589595
rsp
590596
)

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[tox]
2-
envlist = py34, py27, pypy, flake8
2+
envlist = py27, py34, pypy, pypy3, flake8, coverage, docs
33

44
[testenv]
55
passenv = INFLUXDB_PYTHON_INFLUXD_PATH
66
setenv = INFLUXDB_PYTHON_SKIP_SERVER_TESTS=False
77
deps = -r{toxinidir}/requirements.txt
88
-r{toxinidir}/test-requirements.txt
9-
py27,py32,py33,py34,py26: pandas
9+
py27,py34: pandas
1010
# Only install pandas with non-pypy interpreters
1111
commands = nosetests -v --with-doctest {posargs}
1212

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy