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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -18,7 +18,6 @@ from embedding_atlas.utils import Hasher
18
 
19
  # --- Helper function from embedding_atlas/cli.py ---
20
  def find_column_name(existing_names, candidate):
21
- """Finds a unique column name, appending '_1', '_2', etc. if the candidate name already exists."""
22
  if candidate not in existing_names:
23
  return candidate
24
  else:
@@ -86,8 +85,8 @@ def generate_atlas(
86
  model_name: str,
87
  umap_neighbors: int,
88
  umap_min_dist: float,
89
- progress: gr.Progress,
90
- request: gr.Request # <<< STEP 1: ADD THE REQUEST OBJECT TO THE FUNCTION SIGNATURE
91
  ):
92
  """
93
  Loads data, computes embeddings, and serves the Embedding Atlas UI.
@@ -137,7 +136,7 @@ def generate_atlas(
137
  mount_path = f"/{uuid.uuid4().hex}"
138
  atlas_app = make_server(atlas_dataset, static_path=static_path, duckdb_uri="wasm")
139
 
140
- # --- STEP 2: USE THE CORRECT MOUNT METHOD VIA THE REQUEST OBJECT ---
141
  logging.info(f"Mounting FastAPI app at path: {mount_path}")
142
  request.app.mount(mount_path, atlas_app)
143
 
@@ -178,7 +177,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Embedding Atlas Explorer") as app:
178
  split_input.change(fn=get_split_columns, inputs=[dataset_input, split_input], outputs=text_column_input)
179
 
180
  # --- Button Click Event ---
181
- # Note: We do NOT add `request` to the inputs list. Gradio injects it automatically.
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],
 
18
 
19
  # --- Helper function from embedding_atlas/cli.py ---
20
  def find_column_name(existing_names, candidate):
 
21
  if candidate not in existing_names:
22
  return candidate
23
  else:
 
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
  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
 
 
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],