Add custom checks to dataset programatically

Anis
Anis Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer Posts: 18 ✭✭✭✭

Hi,

Is there a way to add custom checks in the same way as adding metrics to a dataset through the dataset api ?

Thanks

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker
    edited July 17 Answer ✓

    Hi @dadbuz
    ,

    You can add checks to a dataset via the api using get_settings() and save()

    However to know the exact format of the check should first create the check you want manually on an existing dataset and then copy this to other datasets as needed.

    For example, if I have the following 2 checks:

    Screenshot 2022-03-23 at 09.53.49.png

    The get_settings() metricsChecks will return :

    Screenshot 2022-03-23 at 09.56.18.png

    If I want to apply the same check to another dataset what I can do is :

    import dataiku
    import pprint
    
    client = dataiku.api_client()
    project = client.get_default_project()
    
    def copy_checks_ds(source_dataset, destination_dataset):
    
        original_settings = project.get_dataset(source_dataset).get_settings().get_raw()['metricsChecks']
        copy_to_dataset = project.get_dataset(destination_dataset)                                         
        
        settings = copy_to_dataset.get_settings()
        params = settings.get_raw()
        params['metricsChecks'] = original_settings
        
        settings.save()
    
    # call copy
    copy_checks_ds("original_dataset_name","destination_dataset_name") 

    Let me know if that helps!

Answers

  • Anis
    Anis Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered, Dataiku DSS Developer Posts: 18 ✭✭✭✭

    Thanks Alex!

    I was looking at the wrong setting - 'checks' instead of 'metricsChecks';

    Will test this and if it works I will accept the answer.

  • wsih
    wsih Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 3

    Hi @AlexT
    ,

    I don't know why this not working for the model evaluation store, I try to change the settings of mes to add checks programmatically, but after build it is still not there.

    Screen Shot 2023-07-12 at 02.26.46.png

Setup Info
    Tags
      Help me…