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

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

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

0 Kudos
5 Replies
Turribeach

What are you trying to achieve?

0 Kudos
cclee93
Level 2
Author

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

 

0 Kudos

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. 

0 Kudos
cclee93
Level 2
Author

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.

0 Kudos

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

0 Kudos

Labels

?
Labels (2)
A banner prompting to get Dataiku