Can I use the R API to trigger a dataset build/job?

Vinnie
Vinnie Registered Posts: 10 ✭✭✭✭

I want to create an R Shiny application to query data. The data exists in dataiku where a pipeline runs nightly. I would like to add a button to my app that would rebuild my data on an ad-hoc basis. Is this possible? In python it looks like this works. Is there an R equivalent?

import dataiku

project = dataiku.api_client().get_default_project()

dataset = project.get_dataset("my_dataset")


dataset.build()

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,326 Dataiker

    Hi,
    The R API does allow for building datasets/running scenarios; that being said, you have several options to achieve this from R Shiny by interacting with the Python API or a REST API

    1) You could create a seperate Webapp API endpoint( Flask or Dash) in the same project that runs the required builds via the Python APIs


    https://developer.dataiku.com/latest/tutorials/webapps/common/api/index.html


    2) Call this from RShiny via libraries like
    library(httr2)library(jsonlite)

    url <- "http://<DATAIKU_ADDRESS>:<DATAIKU_PORT>/web-apps-backends/<PROJECT_KEY>/<WEBAPP_ID>/run_scenario"

    body_data <- list(scenario_id = "MY_SCENARIO_ID")

    resp <- request(url) |>req_headers(Authorization = "Bearer <USE_YOUR_API_KEY>","Content-Type" = "application/json") |>req_body_json(body_data) |>req_perform()


    The other option is to run Python code directly from your rShiny webapp using reticulate
    https://community.dataiku.com/discussion/27475/calling-custom-python-function-in-shiny-webapp



Setup Info
    Tags
      Help me…