lukehinds commited on
Commit
b833760
·
1 Parent(s): 65a3392

Fixed the return values from handle_submission

Browse files
Files changed (1) hide show
  1. app.py +28 -15
app.py CHANGED
@@ -370,21 +370,34 @@ with demo:
370
 
371
  # Prepare request data
372
  request_data = {
373
- "model": [model],
374
- "base_model": [base_model],
375
- "revision": [revision if revision else "main"],
376
- "precision": [precision],
377
- "weight_type": [weight_type],
378
- "model_type": [model_type],
379
- "status": ["PENDING"],
380
- "timestamp": [datetime.now().isoformat()]
381
  }
382
 
383
- # Convert request data to a Dataset
384
- dataset = Dataset.from_dict(request_data)
385
 
386
- # Push the dataset to the Hugging Face Hub
387
- dataset.push_to_hub(QUEUE_REPO)
 
 
 
 
 
 
 
 
 
 
 
 
 
388
 
389
  logger.info(f"Added request for {model} to {QUEUE_REPO}")
390
 
@@ -394,10 +407,10 @@ with demo:
394
  # Start processing queue in background
395
  scheduler.add_job(process_evaluation_queue, id='process_queue_job', replace_existing=True)
396
 
397
- return gr.Markdown("Submission successful! Your model has been added to the evaluation queue. Please check the 'Pending Evaluation Queue' for status updates."), pending_eval_queue_df
398
  except Exception as e:
399
  logger.error(f"Submission failed: {str(e)}", exc_info=True)
400
- return gr.Markdown(f"Error: {str(e)}"), None
401
 
402
  # Remove the queue_manager initialization
403
  # queue_manager = QueueManager(queue_dir=os.path.join(CACHE_PATH, "eval-queue"))
@@ -412,7 +425,7 @@ with demo:
412
  weight_type,
413
  model_type,
414
  ],
415
- submission_result,
416
  )
417
 
418
  with gr.Row():
 
370
 
371
  # Prepare request data
372
  request_data = {
373
+ "model": model,
374
+ "base_model": base_model,
375
+ "revision": revision if revision else "main",
376
+ "precision": precision,
377
+ "weight_type": weight_type,
378
+ "model_type": model_type,
379
+ "status": "PENDING",
380
+ "timestamp": datetime.now().isoformat()
381
  }
382
 
383
+ # Create a unique filename for the request
384
+ filename = f"{model.replace('/', '_')}_request.json"
385
 
386
+ # Save request data as JSON
387
+ with open(filename, 'w') as f:
388
+ json.dump(request_data, f, indent=2)
389
+
390
+ # Upload the JSON file to the Hub
391
+ api = HfApi()
392
+ api.upload_file(
393
+ path_or_fileobj=filename,
394
+ path_in_repo=filename,
395
+ repo_id=QUEUE_REPO,
396
+ repo_type="dataset"
397
+ )
398
+
399
+ # Clean up local file
400
+ os.remove(filename)
401
 
402
  logger.info(f"Added request for {model} to {QUEUE_REPO}")
403
 
 
407
  # Start processing queue in background
408
  scheduler.add_job(process_evaluation_queue, id='process_queue_job', replace_existing=True)
409
 
410
+ return "Submission successful! Your model has been added to the evaluation queue. Please check the 'Pending Evaluation Queue' for status updates.", pending_eval_queue_df
411
  except Exception as e:
412
  logger.error(f"Submission failed: {str(e)}", exc_info=True)
413
+ return f"Error: {str(e)}", None
414
 
415
  # Remove the queue_manager initialization
416
  # queue_manager = QueueManager(queue_dir=os.path.join(CACHE_PATH, "eval-queue"))
 
425
  weight_type,
426
  model_type,
427
  ],
428
+ [submission_result, pending_eval_table],
429
  )
430
 
431
  with gr.Row():