Skip to main content
Solved

Cognite Python SDK


Forum|alt.badge.img

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.

 

Best answer by Anders Albert

  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?
View original
Did this topic help you find an answer to your question?

Anders  Albert
Seasoned Practitioner
Forum|alt.badge.img
  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?

Forum|alt.badge.img
  • Committed
  • January 29, 2025

If you are archiving multiple datasets, you will need to use `metadata.set` instead of `metadata.add`


Reply


Cookie Policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings