Create code scenarios via Python API.

lightnessofbein
lightnessofbein Registered Posts: 5
edited July 16 in Using Dataiku

Hey everyone!

I was wondering, is there a way to create scenarios, similar to the following way of recipe creation? The main requirement is to be able to create code scenarios, not step-based ones.

https://doc.dataiku.com/dss/latest/python-api/flow.html

builder = project.new_recipe("python")

# Set the input
builder.with_input("myinputdataset")
# Create a new managed dataset for the output in the filesystem_managed connection
builder.with_new_output_dataset("grouped_dataset", "filesystem_managed")

# Set the code - builder is a PythonRecipeCreator, and has a ``with_script`` method
builder.with_script("""
import dataiku
from dataiku import recipe
input_dataset = recipe.get_inputs_as_datasets()[0]
output_dataset = recipe.get_outputs_as_datasets()[0]

df = input_dataset.get_dataframe()
df = df.groupby("something").count()
output_dataset.write_with_schema(df)
""")

recipe = builder.create()

Tagged:

Answers

Setup Info
    Tags
      Help me…