Skip to content

Selectors give strange error when having 0 relevant entries (shopping basket client)

If I want to get entries for a specific collection from my shopping basket, I could use a connector. That would be done like this:

from shopping_client import shopping_client
from samp import samp_connector

esap_api_host = "https://sdc-dev.astron.nl/"
sampcon = samp_connector()

sc = shopping_client(host=esap_api_host, connectors=[rucicon, sampcon])
mydata = get_basket(convert_to_pandas=True)

If I have samp data in my shopping basket, all is good. If I do not have samp data, the client will fail with:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-46-cce22ad7246f> in <module>
----> 1 basket_pandas=sc.get_basket(convert_to_pandas=True)

/opt/conda/lib/python3.8/site-packages/shopping_client/shopping_client.py in get_basket(self, convert_to_pandas, reload, filter_archives)
     85 
     86         if convert_to_pandas:
---> 87             return self._basket_to_pandas()
     88 
     89         return self.basket

/opt/conda/lib/python3.8/site-packages/shopping_client/shopping_client.py in _basket_to_pandas(self)
    112     def _basket_to_pandas(self):
    113         if len(self.connectors):
--> 114             converted_basket = {
    115                 connector.name: pd.concat(
    116                     [

/opt/conda/lib/python3.8/site-packages/shopping_client/shopping_client.py in <dictcomp>(.0)
    113         if len(self.connectors):
    114             converted_basket = {
--> 115                 connector.name: pd.concat(
    116                     [
    117                         connector.basket_item_to_pandas(item)

/opt/conda/lib/python3.8/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    309                     stacklevel=stacklevel,
    310                 )
--> 311             return func(*args, **kwargs)
    312 
    313         return wrapper

/opt/conda/lib/python3.8/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, ignore_index, keys, levels, names, verify_integrity, sort, copy)
    292     ValueError: Indexes have overlapping values: ['a']
    293     """
--> 294     op = _Concatenator(
    295         objs,
    296         axis=axis,

/opt/conda/lib/python3.8/site-packages/pandas/core/reshape/concat.py in __init__(self, objs, axis, join, keys, levels, names, ignore_index, verify_integrity, copy, sort)
    349 
    350         if len(objs) == 0:
--> 351             raise ValueError("No objects to concatenate")
    352 
    353         if keys is None:

ValueError: No objects to concatenate

Either the error shoul be clearer, or some empty object should be returned.