From 5a967031c8ea0a71d4d8aa2bef5823941831c507 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Mon, 19 Oct 2015 23:58:25 -0700 Subject: [PATCH 1/5] Adding python 3.5 to build matrix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 547582177b0ea..7f28cb9d6d247 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: python python: - "2.7" - #- "3.5" + - "3.5" cache: directories: - $HOME/.wheelhouse/ From e3e3d0b1f543e8a9a2c6122de894ef3c26d718bd Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 20 Oct 2015 00:11:39 -0700 Subject: [PATCH 2/5] py3 compat changes --- panoramix/bin/panoramix | 4 +++- panoramix/models.py | 1 - tests/core_tests.py | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/panoramix/bin/panoramix b/panoramix/bin/panoramix index 9a7ac4f0b7147..22b4507edaed4 100755 --- a/panoramix/bin/panoramix +++ b/panoramix/bin/panoramix @@ -79,7 +79,9 @@ def load_examples(sample): BirthNames.create(db.engine) session = db.session() - with gzip.open(config.get("BASE_DIR") + '/data/birth_names.csv.gz') as f: + with gzip.open( + config.get("BASE_DIR") + '/data/birth_names.csv.gz', + encoding="ascii") as f: bb_csv = csv.reader(f) for i, (state, year, name, gender, num) in enumerate(bb_csv): if i == 0 or year < "1965": # jumpy data before 1965 diff --git a/panoramix/models.py b/panoramix/models.py index a55e56a3bcd5a..dfa3459140e17 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -458,7 +458,6 @@ def query( engine = self.database.get_sqla_engine() sql = str(qry.compile(engine, compile_kwargs={"literal_binds": True})) - print sql df = read_sql_query( sql=sql, con=engine diff --git a/tests/core_tests.py b/tests/core_tests.py index 49d10d4ae5a47..a9aac3220367e 100644 --- a/tests/core_tests.py +++ b/tests/core_tests.py @@ -1,7 +1,6 @@ import imp import os import unittest -import urllib2 os.environ['PANORAMIX_CONFIG'] = 'tests.panoramix_test_config' from flask.ext.testing import LiveServerTestCase, TestCase From fc76e87653fff7c1a45b6b3ca601bac84040bf3a Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 20 Oct 2015 11:44:25 -0700 Subject: [PATCH 3/5] Trying mode='rt' --- panoramix/bin/panoramix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/panoramix/bin/panoramix b/panoramix/bin/panoramix index 22b4507edaed4..8bb1de17fcf52 100755 --- a/panoramix/bin/panoramix +++ b/panoramix/bin/panoramix @@ -4,6 +4,7 @@ import csv from datetime import datetime import gzip import json +import os from subprocess import Popen from flask.ext.script import Manager @@ -79,9 +80,8 @@ def load_examples(sample): BirthNames.create(db.engine) session = db.session() - with gzip.open( - config.get("BASE_DIR") + '/data/birth_names.csv.gz', - encoding="ascii") as f: + filepath = os.path.join(config.get("BASE_DIR"), 'data/birth_names.csv.gz') + with gzip.open(filepath, mode='rt') as f: bb_csv = csv.reader(f) for i, (state, year, name, gender, num) in enumerate(bb_csv): if i == 0 or year < "1965": # jumpy data before 1965 From a58d184711e021ad11878b42958b01fb737961cc Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 20 Oct 2015 11:52:40 -0700 Subject: [PATCH 4/5] Removing references to basestring --- panoramix/forms.py | 3 ++- panoramix/models.py | 4 +++- panoramix/viz.py | 6 ++++-- requirements.txt | 12 +++++++++--- setup.py | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/panoramix/forms.py b/panoramix/forms.py index 5fdeace8783ad..2f204a1a50c83 100644 --- a/panoramix/forms.py +++ b/panoramix/forms.py @@ -4,6 +4,7 @@ from wtforms import validators from copy import copy from panoramix import app +from six import string_types config = app.config @@ -240,7 +241,7 @@ class QueryForm(OmgWtForm): QueryForm, 'flt_eq_' + str(i), TextField("Super", default='')) for ff in viz.form_fields: - if isinstance(ff, basestring): + if isinstance(ff, string_types): ff = [ff] for s in ff: if s: diff --git a/panoramix/models.py b/panoramix/models.py index dfa3459140e17..8bb3bdcc982ae 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -22,6 +22,8 @@ import requests import textwrap +from six import string_types + from panoramix import app, db, get_session, utils from panoramix.viz import viz_types from sqlalchemy.ext.declarative import declared_attr @@ -766,7 +768,7 @@ def query( if granularity != "all": granularity = utils.parse_human_timedelta( granularity).total_seconds() * 1000 - if not isinstance(granularity, basestring): + if not isinstance(granularity, string_types): granularity = {"type": "duration", "duration": granularity} qry = dict( diff --git a/panoramix/viz.py b/panoramix/viz.py index d45a40097f325..3feb0408e08ea 100644 --- a/panoramix/viz.py +++ b/panoramix/viz.py @@ -14,6 +14,8 @@ from panoramix import app, utils from panoramix.forms import FormFactory +from six import string_types + config = app.config @@ -468,7 +470,7 @@ def to_series(self, df, classed='', title_suffix=''): if df[name].dtype.kind not in "biufc": continue df['timestamp'] = pd.to_datetime(df.index, utc=False) - if isinstance(name, basestring): + if isinstance(name, string_types): series_title = name else: name = ["{}".format(s) for s in name] @@ -622,7 +624,7 @@ def get_json_data(self): if df[name].dtype.kind not in "biufc": continue df['timestamp'] = pd.to_datetime(df.index, utc=False) - if isinstance(name, basestring): + if isinstance(name, string_types): series_title = name elif len(self.metrics) > 1: series_title = ", ".join(name) diff --git a/requirements.txt b/requirements.txt index 7af8d26e03866..de416bfefe6ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ alembic>=0.7.7, <0.8.0 -flask>=0.10.1, <1.0.0 +coverage +coveralls +flask==0.10.1 flask-appbuilder>=1.4.5, <2.0.0 flask-login==0.2.11 flask-migrate>=1.5.1, <2.0.0 @@ -7,10 +9,14 @@ flask-script>=2.0.5, <3.0.0 flask-testing>=0.4.2, <0.5.0 gunicorn>=19.3.0, <20.0.0 markdown>=2.6.2, <3.0.0 -numpy>=1.10, <2 -pandas==0.16.2, <0.17 +nose +numpy>=1.9 +pandas==0.16.2 parsedatetime>=1.5, <2.0.0 pydruid>=0.2.2, <0.3 python-dateutil>=2.4.2, <3.0.0 requests>=2.7.0, <3.0.0 sqlparse>=0.1.16, <0.2.0 +pyhive +pymysql +six diff --git a/setup.py b/setup.py index dcc5626ce3c17..85075a89dbe7f 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ 'flask-testing>=0.4.2, <0.5.0', 'gunicorn>=19.3.0, <20.0.0', 'markdown>=2.6.2, <3.0.0', - 'numpy>=1.10, <2', + 'numpy>=1.9, <2', 'pandas==0.16.2, <0.17', 'parsedatetime>=1.5, <2.0.0', 'pydruid>=0.2.2, <0.3', From 4d8966376fc11c3ddf875f4c060789cb83902f55 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 20 Oct 2015 13:02:50 -0700 Subject: [PATCH 5/5] Aiming at python 3.4 - test --- .travis.yml | 2 +- panoramix/utils.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f28cb9d6d247..ba88b3ef51f0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: python python: - "2.7" - - "3.5" + - "3.4" cache: directories: - $HOME/.wheelhouse/ diff --git a/panoramix/utils.py b/panoramix/utils.py index 0d3dcef3c8ceb..c1e930cfe7ab8 100644 --- a/panoramix/utils.py +++ b/panoramix/utils.py @@ -113,6 +113,7 @@ def color(s): "#A14D83", "#4FA3AB", "#4EDED2", "#4EDED2", "#FFCA4F", "#FFC4B3", "#C9BF97", "#C9BF97", "#898C8C", ] + s = s.encode('utf-8') h = hashlib.md5(s) i = int(h.hexdigest(), 16) return colors[i % len(colors)]