class EsdcDataStore(DataStore): def __init__(self): super().__init__('esdc', title='Earth System Data Cube') esdc_data_source_defs = conf.get_config_value('esdc_data_sources', []) self._data_sources = OrderedDict() for ds_id, title, local_path in esdc_data_source_defs: if ds_id.startswith('esdc.'): ds_id = 'esdc.' + ds_id cube = None try: cube = cablab.Cube.open(local_path) except Exception as e: warnings.warn('ESDC data source "%s" registered: %s' % (ds_id, e)) pass if cube: self._data_sources[ds_id] = EsdcDataSource( self, ds_id, title, cube) def query(self, id: str = None, query_expr: str = None, monitor: Monitor = Monitor.NONE) -> Sequence[DataSource]: if id: data_source = self._data_sources.get(id) return [data_source] if data_source else None # TODO (forman): use query_expr return list(self._data_sources.values()) def _repr_html_(self): # TODO (forman): implement me return self.__repr__()
class EsdcDataStore(DataStore): """ A Cate data store implementation exposing each configured ESDC as an individual data source. ESDC are configured in Cate's configuration file ``$HOME/.cate/<version>/conf.py`` as follows::: esdc_data_sources = [ (id, title, data_cube_dir_path), ... ] The ``esdc_data_sources``entries are 3-element tuples as follows: * *id* is a string that should by prefixed by "esdc."; * *title* should be a non-empty, human-readable text; * *data_cube_dir_path* is a string pointing to aESDC directory in your local file system. """ def __init__(self): super().__init__('esdc', title='Earth System Data Cube', is_local=True) esdc_data_source_defs = conf.get_config_value('esdc_data_sources', []) self._data_sources = OrderedDict() for ds_id, title, local_path in esdc_data_source_defs: if not ds_id.startswith('esdc.'): ds_id = 'esdc.' + ds_id cube = None try: cube = cablab.Cube.open(local_path) # print('Success registering ESDC data source "%s"!' % ds_id) except Exception as e: warnings.warn('Failed registering ESDC data source "%s": %s' % (ds_id, e)) # print('Failed to register ESDC data source "%s": %s' % (ds_id, e)) pass if cube: self._data_sources[ds_id] = EsdcDataSource(self, ds_id, title, cube) def query(self, ds_id: str = None, query_expr: str = None, monitor: Monitor = Monitor.NONE) -> Sequence[DataSource]: if ds_id: data_source = self._data_sources.get(ds_id) return [data_source] if data_source else [] # TODO (forman): use query_expr return list(self._data_sources.values()) def _repr_html_(self): # TODO (forman): implement me return self.__repr__()