Solved

Cognite Python SDK

  • 7 February 2024
  • 1 reply
  • 44 views

Badge

I have some gaps regarding the Cognite python SDK I hope someone could fill:

  1. Is there a way to archive a dataSet with the sdk?
  2. When deleting a file now it doesn’t delete the reference so it looks like I still have files in my dataset. (attached picture) how can I delete the references as well?
  3. Is there a way to delete a datamodel using the sdk? In the documentation exists:
from cognite.client import CogniteClient
c = CogniteClient()
c.data_modeling.data_models.delete(("mySpace", "myDataModel", "v1"))

   It runs but it doesn’t delete the dataModel for me. Please let me know if there is another way.

 

icon

Best answer by Anders Albert 8 February 2024, 09:30

View original

1 reply

Userlevel 2
Badge
  1. Yes, you would have to update the dataset you want to archieve as follows 
    client.data_sets.update(DataSetUpdate(external_id="my_dataset").metadata.add({"archived": "true"}))

     

  2. How do you delete the files? Using the SDK should delete the file and the filemetadat: https://cognite-sdk-python.readthedocs-hosted.com/en/latest/files.html#cognite.client._api.files.FilesAPI.delete
  3. Deleting data models works. However, note that you will not get an exception if the data model does not exist. It will return an empty list if it doesn't find anything, or the list of the data models that is has deleted. Could there be a typo in the data modeling ID?

Reply