lvwerra HF Staff commited on
Commit
1f9efe8
·
1 Parent(s): 7924d77

initial version

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -1,7 +1,30 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from datasets import load_dataset
3
+ import nbformat
4
+ from nbconvert import HTMLExporter
5
 
6
+ # Instantiate the exporter. We use the `classic` template for now; we'll get into more details
7
+ # later about how to customize the exporter further.
8
+ html_exporter = HTMLExporter(template_name="classic")
9
 
10
+ ds = load_dataset("data-agents/kaggle-notebooks", split="train", streaming=True)
11
+ ds_iter = iter(ds)
12
+
13
+ def parse_notebook():
14
+ notebook_string = next(ds_iter)["text"]
15
+ notebook_parsed = nbformat.reads(notebook_string, as_version=4)
16
+ (notebook_body, resources) = html_exporter.from_notebook_node(notebook_parsed)
17
+ return notebook_body
18
+
19
+
20
+ with gr.Blocks() as demo:
21
+ gr.Markdown("# Kaggle Notebooks")
22
+ button = gr.Button("Get next!")
23
+
24
+ with gr.Row():
25
+ with gr.Column():
26
+ html = gr.HTML("")
27
+
28
+ button.click(fn=parse_notebook, inputs=[], outputs=[html])
29
+ demo.load(fn=parse_notebook, inputs=[], outputs=[html])
30
+ demo.launch()