Solved

cognite-sdk

  • 14 July 2023
  • 4 replies
  • 35 views

Badge +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'

 

 

icon

Best answer by roman.chesnokov 14 July 2023, 09:59

View original

4 replies

Userlevel 3

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

Userlevel 4
Badge

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

Badge +2

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?

Userlevel 3

@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.

Reply