Go to file
Rafa de la Torre ffdb6524da Fix bug: search_type can be None
Found via unit test:

```sh
$ nosetests -x test/
....................................................................................E
======================================================================
ERROR: test_geocode_address_with_valid_params (test.test_mapzengeocoder.MapzenGeocoderTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/requests_mock/mocker.py", line 177, in inner
    return func(*args, **kwargs)
  File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/test/test_mapzengeocoder.py", line 100, in test_geocode_address_with_valid_params
    country='ESP')
  File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py", line 28, in wrapped_function
    return QPSService(retry_timeout=timeout, queries_per_second=qps).call(original_function, *args, **kwargs)
  File "/home/ubuntu/src/dataservices-api/server/lib/python/cartodb_services/cartodb_services/mapzen/qps.py", line 53, in call
    raise e
AttributeError: 'NoneType' object has no attribute 'lower'

----------------------------------------------------------------------
Ran 85 tests in 0.140s

FAILED (errors=1)
```
2017-03-08 10:19:32 +01:00
client Client 0.15.0 version release artifacts 2017-02-01 10:52:56 +01:00
doc Update quota_information.md 2017-01-11 12:43:51 +01:00
scripts Install cdb_geocoder extension with non-admin user 2016-02-26 10:49:09 +01:00
server Fix bug: search_type can be None 2017-03-08 10:19:32 +01:00
test Extracted parameters from getmeta and getdata functions tests to fix 2017-02-01 12:12:17 +01:00
.gitignore Ignore coverage files 2016-10-03 12:18:47 +02:00
CONTRIBUTING.md Added CONTRIBUTING.md 2017-01-25 10:47:20 +01:00
LICENSE Add LICENSE file 2015-12-22 18:13:46 +01:00
NEWS.md OBS_GetData functions shall increase the DO quota usage 2017-02-06 17:47:15 +01:00
README.md Update README.md 2017-02-28 18:24:19 +01:00

CARTO Data Services API

The CARTO Data Services SQL API

Deploy instructions

Steps to deploy a new Data Services API version :

  • Deploy new version of dataservices API to all servers
  • Update the server user using: ALTER EXTENSION cdb_dataservices_server UPDATE TO '<CURRENT_VERSION>';
  • Update the python dependencies if needed: cartodb_geocoder and heremaps
  • Add the needed config in the cdb_conf table:
    • redis_metadata_config and redis_metrics_conf
      • {"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}
    • heremaps_conf
      • {"app_id": "APP_ID", "app_code": "APP_CODE"}
  • Deploy the client to all the servers with the new version
  • Deploy the editor with the new dataservices api version changed (https://github.com/CartoDB/cartodb/blob/master/app/models/user/db_service.rb#L18)
  • Execute the rails task to update first the CartoDB team organizaton to test in production
    • RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['team']
  • Check if all works perfectly for our team. If so, execute the rake tasks to update all the users and organizations:
    • RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_organizations['', true]
    • RAILS_ENV=production bundle exec rake cartodb:db:configure_geocoder_extension_for_non_org_users['', true]
  • Freeze the generated SQL file for the version. Eg. cdb_dataservices_server--0.0.1.sql

Local install instructions

  • install data services geocoder extension

    git clone https://github.com/CartoDB/data-services.git
    cd data-services/geocoder/extension
    sudo make install
    
  • install observatory extension

    git clone https://github.com/CartoDB/observatory-extension.git
    cd observatory
    sudo make install
    
  • install server and client extensions

    # in data-services repo root path:
    cd client && sudo make install
    cd server/extension && sudo make install
    
  • install python library

    # in data-services repo root path:
    cd server/lib/python/cartodb_services && sudo pip install . --upgrade 
    
  • install extensions in user database

    create extension cdb_geocoder;
    create extension plproxy;
    create extension observatory;
    create extension cdb_dataservices_server;
    create extension cdb_dataservices_client;
    
  • add configuration for different services in server database

    # If sentinel is used:
      SELECT CDB_Conf_SetConf('redis_metadata_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
      SELECT CDB_Conf_SetConf('redis_metrics_config', '{"sentinel_host": "localhost", "sentinel_port": 26379, "sentinel_master_id": "mymaster", "timeout": 0.1, "redis_db": 5}');
    
    # If sentinel is not used
      SELECT CDB_Conf_SetConf('redis_metadata_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
      SELECT CDB_Conf_SetConf('redis_metrics_config', '{"redis_host": "localhost", "redis_port": 6379, "sentinel_master_id": "", "timeout": 0.1, "redis_db": 5}');
    
    SELECT CDB_Conf_SetConf('heremaps_conf', '{"geocoder": {"app_id": "here_geocoder_app_id", "app_code": "here_geocoder_app_code", "geocoder_cost_per_hit": "1"}, "isolines" : {"app_id": "here_isolines_app_id", "app_code": "here_geocoder_app_code"}}');
    SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}')
    SELECT CDB_Conf_SetConf('mapzen_conf', '{"routing": {"api_key": "valhalla_app_key", "monthly_quota": 999999}, "geocoder": {"api_key": "search_app_key", "monthly_quota": 999999}, "matrix": {"api_key": "[your_matrix_key]", "monthly_quota": 1500000}}');
    SELECT CDB_Conf_SetConf('logger_conf', '{"geocoder_log_path": "/tmp/geocodings.log", [ "min_log_level": "[debug|info|warning|error]", "rollbar_api_key": "SERVER_SIDE_API_KEY", "log_file_path": "LOG_FILE_PATH"]}');
    SELECT CDB_Conf_SetConf('data_observatory_conf', '{"connection": {"whitelist": [], "production": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api", "staging": "host=localhost port=5432 dbname=dataservices_db user=geocoder_api"}}');
    
    # Environment to decide: rollbar message, which servers for third party use, etc. If not setted uses production by default (current behavior)
    SELECT CDB_Conf_SetConf('server_conf', '{"environment": "[development|staging|production]"}')
    
  • configure the user DB:

    -- Point to the dataservices server DB (you can use a specific database for the server or your same user's):
    SELECT CDB_Conf_SetConf('geocoder_server_config', '{ "connection_str": "host=localhost port=5432 dbname=<SERVER_DB_NAME> user=postgres"}');
    
    SELECT CDB_Conf_SetConf('user_config', '{"is_organization": false, "entity_name": "<YOUR_USERNAME>"}');
    
  • configure the search path in order to be able to execute the functions without using the schema:

    ALTER ROLE "<USER_ROLE>" SET search_path="$user", public, cartodb, cdb_dataservices_client;