CartoDB / raster-loader

https://raster-loader.readthedocs.io
Other
15 stars 4 forks source link

fix: error when bigquery dependencies not installed #133

Closed jgoizueta closed 8 months ago

jgoizueta commented 8 months ago

Issue

If raster-loader is installed without the optional bigquery dependencies if fails with uncontrolled error even if bigquery not used:

Traceback (most recent call last):
  File "/Users/ernesto/cartodb/rasterenv/bin/carto", line 5, in <module>
    from raster_loader.cli import main
  File "/Users/ernesto/cartodb/raster-loader/raster_loader/__init__.py", line 3, in <module>
    from raster_loader.io.bigquery import (
  File "/Users/ernesto/cartodb/raster-loader/raster_loader/io/bigquery.py", line 33, in <module>
    class AccessTokenCredentials(Credentials):
                                 ^^^^^^^^^^^
NameError: name 'Credentials' is not defined    

Proposed Changes

Prevent the uncontrolled error; if bigquery is used and the depencies are not available fail with the same error message as before the bug was introduced:

Google Cloud BigQuery is not installed.
Please install Google Cloud BigQuery to use this function.
See https://googleapis.dev/python/bigquery/latest/index.html
for installation instructions.
OR, run `pip install google-cloud-bigquery` to install from pypi.
Jesus89 commented 8 months ago

import_error_bigquery

Google Cloud BigQuery client is not installed.
Please install Google Cloud BigQuery dependencies to use this function.
run `pip install -U raster-loader[bigquery]` to install from pypi.

import_error_snowflake

Snowflake client is not installed.
Please install Snowflake dependencies to use this function.
run `pip install -U raster-loader[snowflake]` to install from pypi.

Remove:

Jesus89 commented 8 months ago

Please update the error messages according to the previous comment