Submit your inspiring success story or innovative use case to the 2022 Dataiku Frontrunner Awards! ENTER YOUR SUBMISSION

Compute Metrics using Python API

Solved!
sj0071992
Neuron
Neuron
Compute Metrics using Python API

Hi,

 

Is  there any way to run the compute button using python API to refresh the data size of dataset?

 

Thanks in Advance

0 Kudos
1 Solution
sergeyd
Dataiker
Dataiker

Hi @sj0071992 

Try this code using dataikuapi.dss.dataset.DSSDataset.compute_metrics : 

import dataiku

client = dataiku.api_client()
project = client.get_default_project()  # Get a handle to the current default project

ds = project.get_dataset("your-dataset")  # TODO: Change the dataset name

# Compute dataset metrics
ds.compute_metrics(
    # Change the example metric identifiers below to a subset of the ones you actually want to run
    metric_ids=['records:COUNT_RECORDS', 'basic:COUNT_COLUMNS']
)

# Run all the checks
ds.run_checks()

 

View solution in original post

1 Reply
sergeyd
Dataiker
Dataiker

Hi @sj0071992 

Try this code using dataikuapi.dss.dataset.DSSDataset.compute_metrics : 

import dataiku

client = dataiku.api_client()
project = client.get_default_project()  # Get a handle to the current default project

ds = project.get_dataset("your-dataset")  # TODO: Change the dataset name

# Compute dataset metrics
ds.compute_metrics(
    # Change the example metric identifiers below to a subset of the ones you actually want to run
    metric_ids=['records:COUNT_RECORDS', 'basic:COUNT_COLUMNS']
)

# Run all the checks
ds.run_checks()