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

Tags
Registered Posts: 4
edited July 2024 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

Welcome!

It looks like you're new here. Sign in or register to get started.

Answers

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

    What are you trying to achieve?

  • Registered Posts: 4
    edited July 2024

    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
    

  • Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,405 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.

  • 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.

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

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

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.