Raymond Weitekamp commited on
Commit
31d39e4
·
1 Parent(s): 32a0510

fix: properly handle OAuth token in dataset push

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -266,6 +266,8 @@ def create_gradio_interface():
266
  max_words: int,
267
  public_checkbox: bool,
268
  collector: OCRDataCollector | None = None,
 
 
269
  *args
270
  ):
271
  """Handle submission with clean parameter order"""
@@ -334,7 +336,7 @@ def create_gradio_interface():
334
  })
335
 
336
  # Push updates to hub
337
- dataset.push_to_hub(repo_id, split="train")
338
  os.remove(temp_path)
339
 
340
  new_text = collector.get_random_text_block(max_words)
@@ -348,7 +350,9 @@ def create_gradio_interface():
348
  image_input, # Uploaded image
349
  max_words_slider, # Max words
350
  public_checkbox, # Public dataset option
351
- gr.State(collector) # Pass the collector instance
 
 
352
  ],
353
  outputs=[image_input, text_box]
354
  )
 
266
  max_words: int,
267
  public_checkbox: bool,
268
  collector: OCRDataCollector | None = None,
269
+ profile: gr.OAuthProfile | None = None,
270
+ oauth_token: gr.OAuthToken | None = None,
271
  *args
272
  ):
273
  """Handle submission with clean parameter order"""
 
336
  })
337
 
338
  # Push updates to hub
339
+ dataset.push_to_hub(repo_id, split="train", token=oauth_token.token if oauth_token else None)
340
  os.remove(temp_path)
341
 
342
  new_text = collector.get_random_text_block(max_words)
 
350
  image_input, # Uploaded image
351
  max_words_slider, # Max words
352
  public_checkbox, # Public dataset option
353
+ gr.State(collector),
354
+ gr.State(None), # Profile will be filled by Gradio
355
+ gr.State(None) # Token will be filled by Gradio
356
  ],
357
  outputs=[image_input, text_box]
358
  )