Admin API

abdulmalik1
Level 1
Admin API

Hi,

I'd asking about Jobs section in the following page "/admin/monitoring/background-tasks" , how I can getting this data using HTTP API or python API.

 

0 Kudos
2 Replies
AlexT
Dataiker

Hi @abdulmalik1,

There is no public API for "background-tasks" specifically. We've taken note of this feature request.

Note list_futures() API will return running tasks with the exclusion of scenarios, jobs, and notebooks. This generally captures "other running tasks", specifically webapp backends and code studios. 

From what I understand, what you want is a "list_running_jobs(") API. This currently does not exist, and the only way to obtain running job information would be through iterating through the list_jobs() API and parsing the response. For activities, you can obtain the number of running activities per job from the list_jobs() API so, note you need to iterate trough each project and in instances with lots of projects this can be costly. 

import dataiku
client = dataiku.api_client()
#get current project
project = client.get_default_project()
#to get all projects https://developer.dataiku.com/latest/concepts-and-examples/projects.html#listing-projects

for job in project.list_jobs():
    job_id = job['def']['id']
    job_object = project.get_job(job_id)
    if job_object.get_status()['baseStatus']['state'] == 'RUNNING':
        print(job_object.get_status()['globalState'])


Thanks




0 Kudos