Skip to main content
Answer

cognite-sdk

  • July 14, 2023
  • 4 replies
  • 53 views

Forum|alt.badge.img+2

I am trying to run a code to fetch timeseries based on some tags available in a project. While I execute the same code using jupyter notebooks in CDF online-notebook feature, the code runs fine. 

When I am trying to run the same code script in local after setting up connectivity using interactive-login and then when I run the timeseries retrieve code, I am getting an error. Please help.

Code:

from datetime import datetime, timezone
utc = timezone.utc


pi= client.time_series.data.retrieve_dataframe(external_id=['pi:2FC1898.DACA.PV','pi:2TC1066.DACA.PV','pi:LAB_133-X013_APIGRAVOB','pi:2FC1898.PIDA.OP'],
start=datetime(2023, 1, 1, tzinfo=utc),
end=datetime(2023, 5, 1, tzinfo=utc),
aggregates=["average"],
granularity="1d")

 

 

Error- Traceback:

---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)Cell In [9], line 5      1 from datetime import datetime, timezone      2 utc = timezone.utc----> 5 pi= client.time_series.data.retrieve_dataframe(external_id=['pi:2FC1898.DACA.PV','pi:2TC1066.DACA.PV','pi:LAB_133-X013_APIGRAVOB','pi:2FC1898.PIDA.OP'],      6                     start=datetime(2023, 1, 1, tzinfo=utc),      7                     end=datetime(2023, 5, 1, tzinfo=utc),      8                     aggregates=["average"],      9                     granularity="1d")AttributeError: 'TimeSeriesAPI' object has no attribute 'data'

 

 

Best answer by roman.chesnokov

Hey @eashwar11 , please update the version of SDK installed locally. 

4 replies

roman.chesnokov
Seasoned Practitioner
  • Seasoned Practitioner
  • Answer
  • July 14, 2023

Hey @eashwar11 , please update the version of SDK installed locally. 


Forum|alt.badge.img

Hi @eashwar11 ! It seems you are running with an older / outdated version of the Cognite Python SDK! Try upgrading and the problem should go away! 😊 

Edit: @roman.chesnokov beat me to it


Forum|alt.badge.img+2
  • Author
  • July 14, 2023

Thanks @roman.chesnokov @Håkon V. Treider 

It worked. I ran the upgrade command 

pip install --upgrade cognite-sdk

in a project specific folder and when launched the notebook from that folder, it worked.

Should I add this SDK in my PATH variable so that it runs for any notebook in any folder?


roman.chesnokov
Seasoned Practitioner

@eashwar11 it depends on your setup. We usually use poetry for our local projects, so if I need to update something, I update the version in the toml file.