How to save a Jupyter notebook in html and upload it into a managed folder ?

cclee93
cclee93 Registered Posts: 4
edited July 16 in Using Dataiku

Hello everyone,

I am using Jupyter notebook to edit a Python recipe.

Its output should be a folder that contains the Jupyter notebook in html format.

# Output folder
folder = dataiku.Folder("Monitoring report")

# Get notebook
client = dataiku.api_client()
project_key = dataiku.default_project_key()
project = client.get_project(project_key)
nb = project.get_jupyter_notebook("notebook editor for python_recipe")

# Save notebook in html and upload to folder
??

Do you have an idea to do that kind of treatment ?

Thank you in advance for your help

Tagged:

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,166 Neuron

    What are you trying to achieve?

  • cclee93
    cclee93 Registered Posts: 4
    edited July 17

    Let's say I have a python recipe where I display some pandas dataframe (with some styles). I wish exporting it in a notebook and then save in a folder.

    import dataiku
    from dataiku import pandasutils as pdu
    import pandas as pd
    import numpy as np
    import matplotlib.pyplot as plt
    from IPython.display import display, Markdown, HTML
    
    # Get dataframe
    data_in = dataiku.Dataset("data_in")
    df = data_in.get_dataframe()
    
    # Display
    display(df.style \
                    .format(
                            "{:.2%}",
                           )
                    .set_table_styles(
                                        [{
                                              'selector': '.row_heading',
                                              'props': [('text-align', 'center')]
                                         },
                                      )
           )
    # Save the notebook and upload in folder
    
    

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,166 Neuron

    I understand that you are trying to save the notebook to a folder but why do you want to do that? What’s your goal? The notebook it’s already saved in the DATA_DIR so there might be better ways of achieving your actual requirement.

  • cclee93
    cclee93 Registered Posts: 4

    Thank you for your answer.

    My goal is to save the notebook in different subfolders, based on the year on which it is launched.

    For example:

    Notebook_2023.html

    Notebook_2024.html

    etc.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,166 Neuron

    Again that’s a step not a goal. What are you really trying to achieve? Why do you want them saved like that?

Setup Info
    Tags
      Help me…