Removed debug traces
This commit is contained in:
@@ -91,10 +91,8 @@ class StreetPointBulkGeocoder:
|
||||
if len(street_geocoder_searches) > self.MAX_BATCH_SIZE:
|
||||
raise Exception("Batch size can't be larger than {}".format(self.MAX_BATCH_SIZE))
|
||||
if self._should_use_batch(street_geocoder_searches):
|
||||
self._logger.debug('--> Batch geocode')
|
||||
return self._batch_geocode(street_geocoder_searches)
|
||||
else:
|
||||
self._logger.debug('--> Serial geocode')
|
||||
return self._serial_geocode(street_geocoder_searches)
|
||||
|
||||
def _batch_geocode(self, street_geocoder_searches):
|
||||
|
||||
@@ -26,7 +26,6 @@ class GoogleMapsBulkGeocoder(GoogleMapsGeocoder, StreetPointBulkGeocoder):
|
||||
for search in searches:
|
||||
(cartodb_id, street, city, state, country) = search
|
||||
lng_lat, metadata = self.geocode_meta(street, city, state, country)
|
||||
self._logger.debug('--> lng_lat: {}. metadata: {}'.format(lng_lat, metadata))
|
||||
results.append((cartodb_id, lng_lat, metadata))
|
||||
return results
|
||||
|
||||
@@ -35,7 +34,6 @@ class GoogleMapsBulkGeocoder(GoogleMapsGeocoder, StreetPointBulkGeocoder):
|
||||
pool = Pool(processes=self.PARALLEL_PROCESSES)
|
||||
for search in searches:
|
||||
(cartodb_id, street, city, state, country) = search
|
||||
self._logger.debug('async geocoding --> {}'.format(search))
|
||||
address = compose_address(street, city, state, country)
|
||||
if address:
|
||||
components = self._build_optional_parameters(city, state, country)
|
||||
|
||||
@@ -63,7 +63,6 @@ class GoogleMapsGeocoder():
|
||||
|
||||
def _process_results(self, results):
|
||||
if results:
|
||||
self._logger.debug('--> results: {}'.format(results[0]))
|
||||
return [
|
||||
self._extract_lng_lat_from_result(results[0]),
|
||||
self._extract_metadata_from_result(results[0])
|
||||
|
||||
@@ -47,7 +47,6 @@ class HereMapsBulkGeocoder(HereMapsGeocoder, StreetPointBulkGeocoder):
|
||||
|
||||
def _batch_geocode(self, searches):
|
||||
request_id = self._send_batch(self._searches_to_csv(searches))
|
||||
self._logger.debug('--> Sent batch {}'.format(request_id))
|
||||
|
||||
last_processed = 0
|
||||
stalled_retries = 0
|
||||
@@ -55,26 +54,19 @@ class HereMapsBulkGeocoder(HereMapsGeocoder, StreetPointBulkGeocoder):
|
||||
while True:
|
||||
job_info = self._job_status(request_id)
|
||||
if job_info.processed_count == last_processed:
|
||||
self._logger.debug('--> no progress ({})'.format(last_processed))
|
||||
stalled_retries += 1
|
||||
if stalled_retries > self.MAX_STALLED_RETRIES:
|
||||
raise Exception('Too many retries for job {}'.format(request_id))
|
||||
else:
|
||||
self._logger.debug('--> progress ({} != {})'.format(job_info.processed_count, last_processed))
|
||||
stalled_retries = 0
|
||||
last_processed = job_info.processed_count
|
||||
|
||||
self._logger.debug('--> Job poll check ({}): {}'.format(
|
||||
stalled_retries, job_info))
|
||||
if job_info.status in self.JOB_FINAL_STATES:
|
||||
break
|
||||
else:
|
||||
time.sleep(self.BATCH_RETRY_SLEEP_S)
|
||||
|
||||
self._logger.debug('--> Job complete: {}'.format(job_info))
|
||||
|
||||
results = self._download_results(request_id)
|
||||
self._logger.debug('--> Results: {} rows; {}'.format(len(results), results))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ class HereMapsGeocoder(Traceable):
|
||||
try:
|
||||
response = self._perform_request(params)
|
||||
result = response['Response']['View'][0]['Result'][0]
|
||||
self._logger.debug('--> Result: {}'.format(result))
|
||||
return [self._extract_lng_lat_from_result(result),
|
||||
self._extract_metadata_from_result(result)]
|
||||
except IndexError:
|
||||
|
||||
@@ -28,7 +28,6 @@ class MapboxBulkGeocoder(MapboxGeocoder, StreetPointBulkGeocoder):
|
||||
results = []
|
||||
for search in searches:
|
||||
elements = self._encoded_elements(search)
|
||||
self._logger.debug('--> Sending serial search: {}'.format(search))
|
||||
result = self.geocode_meta(*elements)
|
||||
|
||||
results.append((search[0], result[0], result[1]))
|
||||
@@ -52,13 +51,10 @@ class MapboxBulkGeocoder(MapboxGeocoder, StreetPointBulkGeocoder):
|
||||
free = ', '.join([elem for elem in elements if elem])
|
||||
frees.append(free)
|
||||
|
||||
self._logger.debug('--> sending free search: {}'.format(frees))
|
||||
full_results = self.geocode_free_text_meta(frees)
|
||||
results = []
|
||||
self._logger.debug('--> searches: {}; xy: {}'.format(searches, full_results))
|
||||
for s, r in zip(searches, full_results):
|
||||
results.append((s[0], r[0], r[1]))
|
||||
self._logger.debug('--> results: {}'.format(results))
|
||||
return results
|
||||
|
||||
def _country_code(self, country):
|
||||
|
||||
@@ -53,7 +53,6 @@ class MapboxGeocoder(Traceable):
|
||||
|
||||
def _parse_geocoder_response(self, response):
|
||||
json_response = json.loads(response)
|
||||
self._logger.debug('--> json response: {}'.format(json_response))
|
||||
|
||||
if json_response:
|
||||
if type(json_response) != list:
|
||||
@@ -154,7 +153,6 @@ class MapboxGeocoder(Traceable):
|
||||
|
||||
try:
|
||||
free_search = ';'.join([self._escape(fs) for fs in free_searches])
|
||||
self._logger.debug('--> free search: {}, country: {}'.format(free_search, country))
|
||||
response = self._geocoder.forward(address=free_search.decode('utf-8'),
|
||||
country=country)
|
||||
|
||||
|
||||
@@ -37,10 +37,8 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
|
||||
city = city.encode('utf-8') if city else None
|
||||
state = state.encode('utf-8') if state else None
|
||||
country = country.encode('utf-8') if country else None
|
||||
self._logger.debug('--> Sending serial search: {}'.format(search))
|
||||
result = self.geocode_meta(searchtext=address, city=city,
|
||||
state_province=state, country=country)
|
||||
self._logger.debug('--> result sent')
|
||||
results.append((search_id, result[0], result[1]))
|
||||
return results
|
||||
|
||||
@@ -50,12 +48,10 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
|
||||
results = []
|
||||
for s, r in zip(searches, full_results):
|
||||
results.append((s[0], r[0], r[1]))
|
||||
self._logger.debug('--> results: {}'.format(results))
|
||||
return results
|
||||
|
||||
def _send_batch(self, searches):
|
||||
body = {'batchItems': [{'query': self._query(s)} for s in searches]}
|
||||
self._logger.debug('--> {}; Body: {}'.format(self.BATCH_URL, body))
|
||||
request_params = {
|
||||
'key': self._apikey
|
||||
}
|
||||
@@ -63,9 +59,7 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
|
||||
allow_redirects=False,
|
||||
params=request_params,
|
||||
timeout=(self.connect_timeout, self.read_timeout))
|
||||
self._logger.debug('--> response: {}'.format(response.status_code))
|
||||
if response.status_code == 303:
|
||||
self._logger.debug(response.headers)
|
||||
return response.headers['Location']
|
||||
else:
|
||||
msg = "Error sending batch: {}; Headers: {}".format(
|
||||
@@ -78,14 +72,12 @@ class TomTomBulkGeocoder(TomTomGeocoder, StreetPointBulkGeocoder):
|
||||
while True:
|
||||
response = self.session.get(self.BASE_URL + location)
|
||||
if response.status_code == 200:
|
||||
self._logger.debug('--> Results ready {}'.format(location))
|
||||
return self._parse_results(response.json())
|
||||
elif response.status_code == 202:
|
||||
stalled_retries += 1
|
||||
if stalled_retries > self.MAX_STALLED_RETRIES:
|
||||
raise Exception('Too many retries for job {}'.format(location))
|
||||
location = response.headers['Location']
|
||||
self._logger.debug('--> Waiting for {}'.format(location))
|
||||
time.sleep(self.BATCH_RETRY_SLEEP_S)
|
||||
else:
|
||||
msg = "Error downloading batch: {}; Headers: {}".format(
|
||||
|
||||
Reference in New Issue
Block a user