<commit_before>CREATE OR REPLACE
FUNCTION geocode_admin0(search text, tx_id bigint, user_id name)
  RETURNS Geometry AS
$$
  import logging
  from sys import path
  path.append( '/home/ubuntu/www/cartodb-geocoder/server/lib/python/cartodb_geocoder' )
  import quota_service

  LOG_FILENAME = '/tmp/plpython.log'
  logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

  if user_id in SD and tx_id in SD[user_id] and 'redis_connection' in SD[user_id][tx_id]:
    logging.debug("Using redis cached connection...")
    qs = quota_service.QuotaService(logging, user_id, tx_id, redis_connection=SD[user_id][tx_id]['redis_connection'])
  else:
    qs = quota_service.QuotaService(logging, user_id, tx_id, redis_host='localhost', redis_port=6379, redis_db=5)

  if qs.check_user_quota():
    result = plpy.execute("SELECT geom FROM geocode_admin0_polygons(Array[\'{0}\']::text[])".format(search))
    if result.status() == 5 and result.nrows() == 1:
      qs.increment_georeference_use()
      SD[user_id] = {tx_id: {'redis_connection': qs.get_redis_connection()}}
      return result[0]["geom"]
    else:
      raise Exception('Something wrong with the georefence operation')<commit_msg>Change to use the installed package<commit_after>CREATE OR REPLACE
FUNCTION geocode_admin0(search text, tx_id bigint, user_id name)
  RETURNS Geometry AS
$$
  import logging
  from cartodb_geocoder import quota_service

  LOG_FILENAME = '/tmp/plpython.log'
  logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

  if user_id in SD and tx_id in SD[user_id] and 'redis_connection' in SD[user_id][tx_id]:
    logging.debug("Using redis cached connection...")
    qs = quota_service.QuotaService(logging, user_id, tx_id, redis_connection=SD[user_id][tx_id]['redis_connection'])
  else:
    qs = quota_service.QuotaService(logging, user_id, tx_id, redis_host='localhost', redis_port=6379, redis_db=5)

  if qs.check_user_quota():
    result = plpy.execute("SELECT geom FROM geocode_admin0_polygons(Array[\'{0}\']::text[])".format(search))
    if result.status() == 5 and result.nrows() == 1:
      qs.increment_georeference_use()
      SD[user_id] = {tx_id: {'redis_connection': qs.get_redis_connection()}}
      return result[0]["geom"]
    else:
      raise Exception('Something wrong with the georefence operation')
{'fraction_non_alphanumeric': 0.12354211663066955, 'fraction_numerical': 0.009503239740820735, 'mean_word_length': 5.242587601078167, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5629023', 'n_tokens_mistral': 838, 'n_tokens_neox': 798, 'n_words': 166}