How to use the cartoframes.utils.logger.log.debug function in cartoframes

To help you get started, we’ve selected a few cartoframes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
output['remaining_quota'] = int(match.group(1))
                                output['estimated_cost'] = int(match.group(2))
                            aborted = True
                            # Don't rollback to avoid losing any partial geocodification:
                            # TODO
                            # transaction.commit()

                        if result and not aborted:
                            # Number of updated rows not available for batch queries
                            # output['updated_rows'] = result.rowcount
                            # log.debug('Number of rows updated: %d', output['updated_rows'])
                            pass

                if not aborted:
                    sql = geocoding_utils.posterior_summary_query(table_name)
                    log.debug("Executing result summary query: %s", sql)
                    result = self._execute_query(sql)
                    geocoding_utils.set_post_summary_info(summary, result, output)

        if not aborted:
            # TODO
            # transaction.commit()
            pass

        return output  # TODO: GeocodeResult object
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
def _execute_prior_summary(self, dataset_name, street, city, state, country):
        sql = geocoding_utils.exists_column_query(dataset_name, geocoding_constants.HASH_COLUMN)
        log.debug("Executing check first time query: %s", sql)
        result = self._execute_query(sql)
        if not result or result.get('total_rows', 0) == 0:
            sql = geocoding_utils.first_time_summary_query(dataset_name, street, city, state, country)
            log.debug("Executing first time summary query: %s", sql)
        else:
            sql = geocoding_utils.prior_summary_query(dataset_name, street, city, state, country)
            log.debug("Executing summary query: %s", sql)
        return self._execute_query(sql)
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
def _geocode(self, table_name, street, city=None, state=None, country=None, status=None, dry_run=False):
        # Internal Geocoding implementation.
        # Geocode a table's rows not already geocoded in a dataset'

        log.debug('table_name = "%s"', table_name)
        log.debug('street = "%s"', street)
        log.debug('city = "%s"', city)
        log.debug('state = "%s"', state)
        log.debug('country = "%s"', country)
        log.debug('status = "%s"', status)
        log.debug('dry_run = "%s"', dry_run)

        output = {}

        summary = {s: 0 for s in [
            'new_geocoded', 'new_nongeocoded',
            'changed_geocoded', 'changed_nongeocoded',
            'previously_geocoded', 'previously_nongeocoded']}

        # TODO: Use a single transaction so that reported changes (posterior - prior queries)
        # are only caused by the geocoding process. Note that no rollback should be
        # performed once the geocoding update is executed, since
        # quota spent by the Dataservices function would not be rolled back;
        # hence a Python `with` statement is not used here.
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
def _geocode(self, table_name, street, city=None, state=None, country=None, status=None, dry_run=False):
        # Internal Geocoding implementation.
        # Geocode a table's rows not already geocoded in a dataset'

        log.debug('table_name = "%s"', table_name)
        log.debug('street = "%s"', street)
        log.debug('city = "%s"', city)
        log.debug('state = "%s"', state)
        log.debug('country = "%s"', country)
        log.debug('status = "%s"', status)
        log.debug('dry_run = "%s"', dry_run)

        output = {}

        summary = {s: 0 for s in [
            'new_geocoded', 'new_nongeocoded',
            'changed_geocoded', 'changed_nongeocoded',
            'previously_geocoded', 'previously_nongeocoded']}

        # TODO: Use a single transaction so that reported changes (posterior - prior queries)
        # are only caused by the geocoding process. Note that no rollback should be
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
available_quota
                ))

            if output['required_quota'] > 0:
                with TableGeocodingLock(self._execute_query, table_name) as locked:
                    if not locked:
                        output['error'] = 'The table is already being geocoded'
                        output['aborted'] = aborted = True
                    else:
                        schema = self._schema()
                        sql, add_columns = geocoding_utils.geocode_query(
                            table_name, schema, street, city, state, country, status)

                        add_columns += [(geocoding_constants.HASH_COLUMN, 'text')]

                        log.debug("Adding columns %s if needed", ', '.join([c[0] for c in add_columns]))
                        alter_sql = "ALTER TABLE {table} {add_columns};".format(
                            table=table_name,
                            add_columns=','.join([
                                'ADD COLUMN IF NOT EXISTS {} {}'.format(name, type) for name, type in add_columns]))
                        self._execute_query(alter_sql)

                        log.debug("Executing query: %s", sql)
                        result = None
                        try:
                            result = self._execute_long_running_query(sql)
                        except Exception as err:
                            log.error(err)
                            msg = str(err)
                            output['error'] = msg
                            # FIXME: Python SDK should return proper exceptions
                            # see: https://github.com/CartoDB/cartoframes/issues/751
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
def _execute_prior_summary(self, dataset_name, street, city, state, country):
        sql = geocoding_utils.exists_column_query(dataset_name, geocoding_constants.HASH_COLUMN)
        log.debug("Executing check first time query: %s", sql)
        result = self._execute_query(sql)
        if not result or result.get('total_rows', 0) == 0:
            sql = geocoding_utils.first_time_summary_query(dataset_name, street, city, state, country)
            log.debug("Executing first time summary query: %s", sql)
        else:
            sql = geocoding_utils.prior_summary_query(dataset_name, street, city, state, country)
            log.debug("Executing summary query: %s", sql)
        return self._execute_query(sql)
github CartoDB / cartoframes / cartoframes / data / services / geocoding.py View on Github external
def _geocode(self, table_name, street, city=None, state=None, country=None, status=None, dry_run=False):
        # Internal Geocoding implementation.
        # Geocode a table's rows not already geocoded in a dataset'

        log.debug('table_name = "%s"', table_name)
        log.debug('street = "%s"', street)
        log.debug('city = "%s"', city)
        log.debug('state = "%s"', state)
        log.debug('country = "%s"', country)
        log.debug('status = "%s"', status)
        log.debug('dry_run = "%s"', dry_run)

        output = {}

        summary = {s: 0 for s in [
            'new_geocoded', 'new_nongeocoded',
            'changed_geocoded', 'changed_nongeocoded',
            'previously_geocoded', 'previously_nongeocoded']}

        # TODO: Use a single transaction so that reported changes (posterior - prior queries)
        # are only caused by the geocoding process. Note that no rollback should be
        # performed once the geocoding update is executed, since