opendatacube / datacube-core

Open Data Cube analyses continental scale Earth Observation data through time
http://www.opendatacube.org
Apache License 2.0
505 stars 176 forks source link

AttributeError: module 'ee.data' has no attribute '_get_cloud_api_resource' #1488

Closed max-poltora closed 1 year ago

max-poltora commented 1 year ago

Expected behaviour

dataset = dc.load(product=product,time=time,latitude=latitude,longitude=longitude)

Be able to load the dataset as indicated in the example notebook

Actual behaviour

Error message after executing

AttributeError: module 'ee.data' has no attribute '_get_cloud_api_resource'

Steps to reproduce the behaviour

Recently I have been facing a problem when running the snippet of code below in Google Colab. The code uses the Datacube module from odc_gee package.

!wget -nc https://raw.githubusercontent.com/ceos-seo/odc-colab/master/odc_colab.py
from odc_colab import odc_colab_init
odc_colab_init(install_odc_gee=True)

from odc_colab import populate_db
populate_db()

from odc_gee.earthengine import Datacube
dc = Datacube(app='ESA_WorldCover')

product = 'esa_worldcover_google'

# Kumasi, Ghana 
lat_long = (6.7, -1.6)
box_size_deg = 0.50

# Calculates the latitude and longitude bounds of the analysis box
latitude = (lat_long[0]-box_size_deg/2, lat_long[0]+box_size_deg/2)
longitude = (lat_long[1]-box_size_deg/2, lat_long[1]+box_size_deg/2)

dataset = dc.load(product=product,time=time,latitude=latitude,longitude=longitude)

After installing required packages, modules and successful authorization at Earth Engine, I run into the following error message after executing last line of code:

/usr/local/lib/python3.10/dist-packages/datacube/utils/geometry/_base.py:519: ShapelyDeprecationWarning: The 'type' attribute is deprecated, and will be removed in the future. You can use the 'geom_type' attribute instead. return self.geom.type

AttributeError Traceback (most recent call last) in <cell line: 1>() ----> 1 dataset = dc.load(product=product,time=time,latitude=latitude,longitude=longitude)

5 frames /usr/local/lib/python3.10/dist-packages/odc_gee/earthengine.py in load(self, datasets, kwargs) 82 ''' 83 datasets = datasets if datasets else self.find_datasets(kwargs) ---> 84 return super().load(datasets=datasets, **kwargs) 85 86 def _refresh_credentials(self, stop_event):

/usr/local/lib/python3.10/dist-packages/datacube/api/core.py in load(self, product, measurements, output_crs, resolution, resampling, skip_broken_datasets, dask_chunks, like, fuse_func, align, datasets, progress_cbk, query) 292 datasets = self.find_datasets(product=product, like=like, ensure_location=True, query) 293 elif isinstance(datasets, collections.abc.Iterator): --> 294 datasets = list(datasets) 295 296 if len(datasets) == 0:

/usr/local/lib/python3.10/dist-packages/odc_gee/earthengine.py in find_datasets(self, limit, **search_terms) 119 if hasattr(query, 'asset'): 120 images = self.get_images(self.build_parameters(query)) --> 121 for document in generate_documents(query.asset, images, query.product): 122 if limit != 0: 123 limit = limit - 1 if limit is not None else limit

/usr/local/lib/python3.10/dist-packages/odc_gee/earthengine.py in generate_documents(asset, images, product) 295 from datacube.index.hl import prep_eo3 296 from odc_gee.indexing import make_metadata_doc --> 297 for image in images: 298 yield prep_eo3(make_metadata_doc(asset, image, product)) 299

/usr/local/lib/python3.10/dist-packages/odc_gee/earthengine.py in get_images(self, parameters) 158 yield response 159 except Exception as error: --> 160 raise error 161 162 def build_parameters(self, query):

/usr/local/lib/python3.10/dist-packages/odc_gee/earthengine.py in get_images(self, parameters) 140 ''' 141 try: --> 142 request = self.ee.data._get_cloud_api_resource().projects().assets().listImages( 143 **parameters) 144 while request is not None:

AttributeError: module 'ee.data' has no attribute '_get_cloud_api_resource'

What could be the problem?

Environment information

SpacemanPaul commented 1 year ago

This does not appear to be an issue with datacube-core, but somewhere in the odc_gee package. Datacube-core neither defines nor uses the ee.data package.

I see you have already raised an issue on the appropriate repositories. I'll try and find someone who can help you.

(https://github.com/ceos-seo/odc-gee/issues/3 and https://github.com/ceos-seo/odc-colab/issues/10)