From 03e1d1ca613b590494602a19bed606c4bf2f2b7c Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:13:59 +0100 Subject: [PATCH 1/8] Change default provider to mapbox instead of mapzen --- .../cartodb_services/cartodb_services/metrics/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index aab4dd5..f068ab2 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -136,7 +136,7 @@ class RoutingConfig(ServiceConfig): ROUTING_PROVIDER_KEY = 'routing_provider' MAPZEN_PROVIDER = 'mapzen' MAPBOX_PROVIDER = 'mapbox' - DEFAULT_PROVIDER = MAPZEN_PROVIDER + DEFAULT_PROVIDER = MAPBOX_PROVIDER QUOTA_KEY = 'mapzen_routing_quota' SOFT_LIMIT_KEY = 'soft_mapzen_routing_limit' METRICS_LOG_KEY = 'routing_log_path' @@ -226,7 +226,7 @@ class IsolinesRoutingConfig(ServiceConfig): MAPZEN_PROVIDER = 'mapzen' MAPBOX_PROVIDER = 'mapbox' HEREMAPS_PROVIDER = 'heremaps' - DEFAULT_PROVIDER = MAPZEN_PROVIDER + DEFAULT_PROVIDER = MAPBOX_PROVIDER METRICS_LOG_KEY = 'isolines_log_path' def __init__(self, redis_connection, db_conn, username, orgname=None): @@ -391,7 +391,7 @@ class GeocoderConfig(ServiceConfig): USERNAME_KEY = 'username' ORGNAME_KEY = 'orgname' PERIOD_END_DATE = 'period_end_date' - DEFAULT_PROVIDER = MAPZEN_GEOCODER + DEFAULT_PROVIDER = MAPBOX_GEOCODER METRICS_LOG_KEY = 'geocoder_log_path' def __init__(self, redis_connection, db_conn, username, orgname=None, forced_provider=None): From 39dabffb8529993d1d6b13164a57a77463bdbab6 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:29 +0100 Subject: [PATCH 2/8] Now is not mandatory to have mapzen configuration becuase its deprecated as provider --- .../python/cartodb_services/cartodb_services/metrics/config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index f068ab2..82fff8d 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -589,8 +589,9 @@ class ServicesDBConfig: def _get_mapzen_config(self): mapzen_conf_json = self._get_conf('mapzen_conf') + # We dont use mapzen anymore so we don't need to check for its configuration if not mapzen_conf_json: - raise ConfigException('Mapzen configuration missing') + return else: mapzen_conf = json.loads(mapzen_conf_json) self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] From e3f23adfdd38cadd7e926d02966c47d5c311c957 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:47 +0100 Subject: [PATCH 3/8] Bump to version 0.17.0 --- server/lib/python/cartodb_services/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index 901ee87..a87deb4 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.16.7', + version='0.17.0', description='CartoDB Services API Python Library', From 199788748b8713d97c13507e3b038cd8468aaf9e Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Wed, 21 Feb 2018 19:14:56 +0100 Subject: [PATCH 4/8] Updated NEWS.md --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 250eaeb..9fff051 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +February 22th, 2018 +================== +* Version `0.17.0` of the python library + * Change default provider to Mapbox + * Remove the obligatory nature of the Mapzen configuration due to its deprecation as provider February 13th, 2018 ================== From cbc19b869c8c13c93210a7ec7642c8e41423e1c3 Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Thu, 22 Feb 2018 11:14:33 +0100 Subject: [PATCH 5/8] Fix CR suggestions --- .../cartodb_services/metrics/config.py | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index 82fff8d..16e076d 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -576,51 +576,51 @@ class ServicesDBConfig: heremaps_conf_json = self._get_conf('heremaps_conf') if not heremaps_conf_json: raise ConfigException('Here maps configuration missing') - else: - heremaps_conf = json.loads(heremaps_conf_json) - self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id'] - self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code'] - self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][ - 'geocoder_cost_per_hit'] - self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {}) - self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id'] - self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code'] - self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {}) + + heremaps_conf = json.loads(heremaps_conf_json) + self._heremaps_geocoder_app_id = heremaps_conf['geocoder']['app_id'] + self._heremaps_geocoder_app_code = heremaps_conf['geocoder']['app_code'] + self._heremaps_geocoder_cost_per_hit = heremaps_conf['geocoder'][ + 'geocoder_cost_per_hit'] + self._heremaps_geocoder_service_params = heremaps_conf['geocoder'].get('service', {}) + self._heremaps_isolines_app_id = heremaps_conf['isolines']['app_id'] + self._heremaps_isolines_app_code = heremaps_conf['isolines']['app_code'] + self._heremaps_isolines_service_params = heremaps_conf['isolines'].get('service', {}) def _get_mapzen_config(self): mapzen_conf_json = self._get_conf('mapzen_conf') # We dont use mapzen anymore so we don't need to check for its configuration if not mapzen_conf_json: return - else: - mapzen_conf = json.loads(mapzen_conf_json) - self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] - self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota'] - self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {}) - self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {}) - self._mapzen_routing_api_key = mapzen_conf['routing']['api_key'] - self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota'] - self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {}) - self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key'] - self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota'] - self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {}) + + mapzen_conf = json.loads(mapzen_conf_json) + self._mapzen_matrix_api_key = mapzen_conf['matrix']['api_key'] + self._mapzen_matrix_quota = mapzen_conf['matrix']['monthly_quota'] + self._mapzen_matrix_service_params = mapzen_conf['matrix'].get('service', {}) + self._mapzen_isochrones_service_params = mapzen_conf.get('isochrones', {}).get('service', {}) + self._mapzen_routing_api_key = mapzen_conf['routing']['api_key'] + self._mapzen_routing_quota = mapzen_conf['routing']['monthly_quota'] + self._mapzen_routing_service_params = mapzen_conf['routing'].get('service', {}) + self._mapzen_geocoder_api_key = mapzen_conf['geocoder']['api_key'] + self._mapzen_geocoder_quota = mapzen_conf['geocoder']['monthly_quota'] + self._mapzen_geocoder_service_params = mapzen_conf['geocoder'].get('service', {}) def _get_mapbox_config(self): mapbox_conf_json = self._get_conf('mapbox_conf') if not mapbox_conf_json: raise ConfigException('Mapbox configuration missing') - else: - mapbox_conf = json.loads(mapbox_conf_json) - self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys'] - self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota'] - self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {}) - self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {}) - self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys'] - self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota'] - self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {}) - self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys'] - self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota'] - self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {}) + + mapbox_conf = json.loads(mapbox_conf_json) + self._mapbox_matrix_api_keys = mapbox_conf['matrix']['api_keys'] + self._mapbox_matrix_quota = mapbox_conf['matrix']['monthly_quota'] + self._mapbox_matrix_service_params = mapbox_conf['matrix'].get('service', {}) + self._mapbox_isochrones_service_params = mapbox_conf.get('isochrones', {}).get('service', {}) + self._mapbox_routing_api_keys = mapbox_conf['routing']['api_keys'] + self._mapbox_routing_quota = mapbox_conf['routing']['monthly_quota'] + self._mapbox_routing_service_params = mapbox_conf['routing'].get('service', {}) + self._mapbox_geocoder_api_keys = mapbox_conf['geocoder']['api_keys'] + self._mapbox_geocoder_quota = mapbox_conf['geocoder']['monthly_quota'] + self._mapbox_geocoder_service_params = mapbox_conf['geocoder'].get('service', {}) def _get_data_observatory_config(self): do_conf_json = self._get_conf('data_observatory_conf') From 05e2cc981e243d556eb78f97abdf9ffda072b48d Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Thu, 22 Feb 2018 11:20:16 +0100 Subject: [PATCH 6/8] Change min log level for tests to WARNING --- client/test/expected/00_installation_test.out | 2 ++ client/test/sql/00_installation_test.sql | 2 ++ server/extension/test/expected/00_install_test.out | 2 ++ server/extension/test/sql/00_install_test.sql | 2 ++ 4 files changed, 8 insertions(+) diff --git a/client/test/expected/00_installation_test.out b/client/test/expected/00_installation_test.out index fe179b7..650b141 100644 --- a/client/test/expected/00_installation_test.out +++ b/client/test/expected/00_installation_test.out @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/client/test/sql/00_installation_test.sql b/client/test/sql/00_installation_test.sql index f091cd4..49eab80 100644 --- a/client/test/sql/00_installation_test.sql +++ b/client/test/sql/00_installation_test.sql @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/server/extension/test/expected/00_install_test.out b/server/extension/test/expected/00_install_test.out index f87ca05..cfb9ee7 100644 --- a/server/extension/test/expected/00_install_test.out +++ b/server/extension/test/expected/00_install_test.out @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; diff --git a/server/extension/test/sql/00_install_test.sql b/server/extension/test/sql/00_install_test.sql index 9ffe2e1..2d7d41a 100644 --- a/server/extension/test/sql/00_install_test.sql +++ b/server/extension/test/sql/00_install_test.sql @@ -1,3 +1,5 @@ +-- Only show warning or error messages in the tests output +SET client_min_messages TO WARNING; -- Install dependencies CREATE EXTENSION postgis; CREATE EXTENSION plpythonu; From 97f1611d6252cc96f009ec67adb4ed1761ff389e Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Tue, 27 Feb 2018 18:09:21 +0100 Subject: [PATCH 7/8] Only get mapzen/mapbox values in case the provider of routing is one of these --- .../cartodb_services/metrics/config.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py index 16e076d..6179d1b 100644 --- a/server/lib/python/cartodb_services/cartodb_services/metrics/config.py +++ b/server/lib/python/cartodb_services/cartodb_services/metrics/config.py @@ -147,10 +147,12 @@ class RoutingConfig(ServiceConfig): self._routing_provider = self._redis_config[self.ROUTING_PROVIDER_KEY] if not self._routing_provider: self._routing_provider = self.DEFAULT_PROVIDER - self._mapzen_api_key = self._db_config.mapzen_routing_api_key - self._mapzen_service_params = self._db_config.mapzen_routing_service_params - self._mapbox_api_keys = self._db_config.mapbox_routing_api_keys - self._mapbox_service_params = self._db_config.mapbox_routing_service_params + if self._routing_provider == self.MAPZEN_PROVIDER: + self._mapzen_api_key = self._db_config.mapzen_routing_api_key + self._mapzen_service_params = self._db_config.mapzen_routing_service_params + elif self._routing_provider == self.MAPBOX_PROVIDER: + self._mapbox_api_keys = self._db_config.mapbox_routing_api_keys + self._mapbox_service_params = self._db_config.mapbox_routing_service_params self._set_monthly_quota() self._set_soft_limit() self._period_end_date = date_parse(self._redis_config[self.PERIOD_END_DATE]) From ad46de1156ef9db4f0763a0b0b538542aa0827ca Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Tue, 27 Feb 2018 18:11:50 +0100 Subject: [PATCH 8/8] Bump version and update NEWS.md --- NEWS.md | 6 ++++++ server/lib/python/cartodb_services/setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 9fff051..036318d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ + +February 27th, 2018 +================== +* Version `0.17.1` of the python library + * Fix bug when the mapzen credentials are not in the db config and we keep getting them + February 22th, 2018 ================== * Version `0.17.0` of the python library diff --git a/server/lib/python/cartodb_services/setup.py b/server/lib/python/cartodb_services/setup.py index a87deb4..95a2c16 100644 --- a/server/lib/python/cartodb_services/setup.py +++ b/server/lib/python/cartodb_services/setup.py @@ -10,7 +10,7 @@ from setuptools import setup, find_packages setup( name='cartodb_services', - version='0.17.0', + version='0.17.1', description='CartoDB Services API Python Library',