Skip to content

Commit

Permalink
[QOL-6190] check for a 'compatibility mode' flag and prefer messytabl…
Browse files Browse the repository at this point in the history
…es if it is set, #90

- This will be slower on resources that don't need type-guessing, but will behave much more like the DataPusher, which simplifies the transition.
  • Loading branch information
ThrawnCA committed Dec 4, 2019
1 parent 718798c commit b985b68
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rq import get_current_job
import sqlalchemy as sa

from ckan.plugins.toolkit import get_action
from ckan.plugins.toolkit import get_action, asbool
try:
from ckan.plugins.toolkit import config
except ImportError:
Expand Down Expand Up @@ -279,12 +279,19 @@ def messytables_load():

# Load it
logger.info('Loading CSV')
compatibility_mode = config.get('ckanext.xloader.compatibility_mode', False)
try:
direct_load()
except JobError as e:
logger.warning('Fast load using COPY failed: {}'.format(e))
logger.info('Trying again with messytables to best-guess data types')
messytables_load()
if asbool(compatibility_mode):
logger.info("Compatibility mode is {}, using messytables to guess types".format(compatibility_mode))
messytables_load()
else:
logger.info("Compatibility mode is {}, attempting fast direct copy".format(compatibility_mode))
try:
direct_load()
except JobError as e:
logger.warning('Fast load using COPY failed: {}'.format(e))
logger.info('Trying again with messytables to best-guess data types')
messytables_load()
except FileCouldNotBeLoadedError as e:
logger.warning('Loading excerpt for this format not supported.')
logger.error('Loading file raised an error: {}'.format(e))
Expand Down

0 comments on commit b985b68

Please sign in to comment.