broadfield-dev commited on
Commit
36b7e3f
·
verified ·
1 Parent(s): 72992ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -85,8 +85,8 @@ def generate_atlas(
85
  model_name: str,
86
  umap_neighbors: int,
87
  umap_min_dist: float,
88
- request: gr.Request, # <<< STEP 1: The Request object comes AFTER your main inputs.
89
- progress=gr.Progress(track_tqdm=True) # <<< STEP 2: The Progress object comes LAST as a default argument.
90
  ):
91
  """
92
  Loads data, computes embeddings, and serves the Embedding Atlas UI.
@@ -136,12 +136,14 @@ def generate_atlas(
136
  mount_path = f"/{uuid.uuid4().hex}"
137
  atlas_app = make_server(atlas_dataset, static_path=static_path, duckdb_uri="wasm")
138
 
139
- # --- This now uses the correct request object to mount the app ---
140
  logging.info(f"Mounting FastAPI app at path: {mount_path}")
141
  request.app.mount(mount_path, atlas_app)
142
 
143
  progress(1.0, desc="Done!")
144
- iframe_html = f"<iframe src='{mount_path}' width='100%' height='800px' frameborder='0'></iframe>"
 
 
 
145
  return gr.HTML(iframe_html)
146
 
147
  # --- Gradio UI Definition ---
@@ -177,7 +179,6 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Embedding Atlas Explorer") as app:
177
  split_input.change(fn=get_split_columns, inputs=[dataset_input, split_input], outputs=text_column_input)
178
 
179
  # --- Button Click Event ---
180
- # The 'inputs' list does NOT include 'request' or 'progress'. Gradio handles them automatically.
181
  generate_button.click(
182
  fn=generate_atlas,
183
  inputs=[dataset_input, split_input, text_column_input, sample_size_input, model_input, umap_neighbors_input, umap_min_dist_input],
@@ -187,4 +188,4 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Embedding Atlas Explorer") as app:
187
  app.load(fn=get_user_datasets, inputs=hf_user_input, outputs=dataset_input)
188
 
189
  if __name__ == "__main__":
190
- app.launch(debug=True)
 
85
  model_name: str,
86
  umap_neighbors: int,
87
  umap_min_dist: float,
88
+ request: gr.Request,
89
+ progress=gr.Progress(track_tqdm=True)
90
  ):
91
  """
92
  Loads data, computes embeddings, and serves the Embedding Atlas UI.
 
136
  mount_path = f"/{uuid.uuid4().hex}"
137
  atlas_app = make_server(atlas_dataset, static_path=static_path, duckdb_uri="wasm")
138
 
 
139
  logging.info(f"Mounting FastAPI app at path: {mount_path}")
140
  request.app.mount(mount_path, atlas_app)
141
 
142
  progress(1.0, desc="Done!")
143
+
144
+ # --- THE FINAL FIX: Add a trailing slash to the iframe src ---
145
+ iframe_html = f"<iframe src='{mount_path}/' width='100%' height='800px' frameborder='0'></iframe>"
146
+
147
  return gr.HTML(iframe_html)
148
 
149
  # --- Gradio UI Definition ---
 
179
  split_input.change(fn=get_split_columns, inputs=[dataset_input, split_input], outputs=text_column_input)
180
 
181
  # --- Button Click Event ---
 
182
  generate_button.click(
183
  fn=generate_atlas,
184
  inputs=[dataset_input, split_input, text_column_input, sample_size_input, model_input, umap_neighbors_input, umap_min_dist_input],
 
188
  app.load(fn=get_user_datasets, inputs=hf_user_input, outputs=dataset_input)
189
 
190
  if __name__ == "__main__":
191
+ app.launch(debug=True)```