menouar commited on
Commit
d898977
·
1 Parent(s): 3caf65d

Check the output_dir's value

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -8,6 +8,8 @@ from utils.components_creator import *
8
 
9
  finetuning_notebook = "Finetuning_NoteBook"
10
 
 
 
11
  css = """
12
  .container {
13
  align-items: center;
@@ -87,6 +89,7 @@ def get_value(components: dict[Component, Any], elem_id: str) -> Any:
87
 
88
  def preview_notebook():
89
  html_exporter = HTMLExporter()
 
90
  (body, resources) = html_exporter.from_notebook_node(notebook)
91
 
92
  html_path = f"{finetuning_notebook}.html"
@@ -96,6 +99,8 @@ def preview_notebook():
96
 
97
 
98
  def generate_code(components: dict[Component, Any]):
 
 
99
  create_install_libraries_cells(notebook['cells'])
100
  flash_attention_value = get_value(components, FLASH_ATTENTION_ID)
101
  if flash_attention_value:
@@ -285,7 +290,6 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(text_size='lg', font=["monospace"],
285
  preview_btn = gr.Button(f"👀 Preview {finetuning_notebook}.ipynb", variant="primary", visible=False)
286
  download_btn = gr.HTML(show_label=False, visible=True)
287
 
288
- notebook = nbf.v4.new_notebook()
289
  greet_btn.click(fn=generate_code, inputs=all_components, outputs=[preview_btn, download_btn])
290
 
291
  preview_btn.click(fn=preview_notebook, inputs=None, outputs=iframe)
 
8
 
9
  finetuning_notebook = "Finetuning_NoteBook"
10
 
11
+ notebook = None
12
+
13
  css = """
14
  .container {
15
  align-items: center;
 
89
 
90
  def preview_notebook():
91
  html_exporter = HTMLExporter()
92
+ global notebook
93
  (body, resources) = html_exporter.from_notebook_node(notebook)
94
 
95
  html_path = f"{finetuning_notebook}.html"
 
99
 
100
 
101
  def generate_code(components: dict[Component, Any]):
102
+ global notebook
103
+ notebook = nbf.v4.new_notebook()
104
  create_install_libraries_cells(notebook['cells'])
105
  flash_attention_value = get_value(components, FLASH_ATTENTION_ID)
106
  if flash_attention_value:
 
290
  preview_btn = gr.Button(f"👀 Preview {finetuning_notebook}.ipynb", variant="primary", visible=False)
291
  download_btn = gr.HTML(show_label=False, visible=True)
292
 
 
293
  greet_btn.click(fn=generate_code, inputs=all_components, outputs=[preview_btn, download_btn])
294
 
295
  preview_btn.click(fn=preview_notebook, inputs=None, outputs=iframe)