Web app - export result as HTML

Options
CGB
CGB Partner, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 17 Partner

Hi,

I recently developped a Web App on Bokeh. On it, I added a button to save the result.

Ideally, I would like save the HTML result in a folder to be able to download it. Unfortunately, on notebook, it works well but not in WebApp : it's like the folder was not found ...

In plan B, I saved the result as a static insight and it works well but I have another problem : I don't know how I can download it.

I take all your suggestion,

Thanks in advance !

Best Answer

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker
    edited July 17 Answer ✓
    Options

    Hi @CGB
    ,

    It should be possible to write to a managed folder from a webapp. Here's an example Bokeh webapp where I write to a file every time a text input is changed:

    import dataiku
    from bokeh.io import curdoc
    from bokeh.layouts import row, widgetbox
    from bokeh.models.widgets import TextInput
    
    folder = dataiku.Folder("MY_FOLDER")
    
    text = TextInput(title="Text")
    
    # Write the title to a file in the managed folder on update
    def update_text(attrname, old, new):
        with folder.get_writer("webapp.txt") as f:
            f.write(text.value.encode())
    
    text.on_change("value", update_text)
    
    inputs = widgetbox(text)
    curdoc().add_root(row(inputs))
    curdoc().title = "Text"

    Could you please share the code of the webapp, the error message you're getting, and the code of the notebook where it's working?

    Thanks,

    Zach

Answers

  • CGB
    CGB Partner, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 17 Partner
    edited July 17
    Options

    Hi @ZachM
    ,
    Thanks a lot for your answer, it helps me to find a perfect solution in my case.
    I share the final code used :

    import dataiku
    from bokeh.resources import CDN
    from bokeh.embed import file_html

    dataiku.Folder("MY_FOLDER")
    my_report = file_html(graph_to_save, CDN, "MY_TITLE")
    with open(folder.get_path()+'/MY_FILE.html',"w+") as f:
        f.write(my_report)

    And just by curiosity, someone knows if its possible to download statit insight ?

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker
    Options

    You can download a static insight by first adding it to a dashboard, and then exporting the dashboard to PDF or to an image.

  • CGB
    CGB Partner, L2 Designer, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 17 Partner
    Options
Setup Info
    Tags
      Help me…