When I run the following code in Jupyter notebook in CDF, I dont get any problem and it runs fine
import pandas as pd
root_asset = 'LPM_YT_MODEL'
def handle(client, data=None, secrets=None, function_call_info=None):
start=pd.Timestamp(data["start_date"])
end=pd.Timestamp(data["end_date"])
ts_names_list = client.time_series.list(limit=None,asset_subtree_ids=[client.assets.list(name=root_asset)[0].id])
time_series_data_extids = ts_names_list.as_external_ids()
data_points = {ts: client.time_series.data.retrieve_dataframe(external_id=ts,start=start,end=end,) for ts in time_series_data_extids if not client.time_series.data.retrieve_dataframe(external_id=ts,start=start,end=end,).empty}
but when this is executed as cognite function, it is throwing following error
Traceback (most recent call last):
File "/home/site/wwwroot/function/_cognite_function_entry_point.py", line 455, in run_handle
result = handle(*function_argument_values)
File "/home/site/wwwroot/function/handler.py", line 12, in handle
time_series_data_extids = ts_names_list.as_external_ids()
File "/home/site/wwwroot/.python_packages/lib/site-packages/cognite/client/data_classes/_base.py", line 214, in __getattribute__
attr = super().__getattribute__(item)
AttributeError: 'TimeSeriesList' object has no attribute 'as_external_ids'