tdoehmen commited on
Commit
1d1f8ae
·
1 Parent(s): 11fbe39

fixed output?

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -6,6 +6,7 @@ import os
6
  import re
7
  import threading
8
  import queue
 
9
 
10
  zero = torch.Tensor([0]).cuda()
11
  print(zero.device) # <-- 'cpu' 🤔
@@ -22,17 +23,15 @@ def run_evaluation(model_name):
22
  results = []
23
  manifest_logs = []
24
 
25
- # Use the secret HF token from the Hugging Face space
26
  if "HF_TOKEN" not in os.environ:
27
  return "Error: HF_TOKEN not found in environment variables.", "Error: Cannot start manifest server without HF_TOKEN."
28
 
29
  manifest_process = None
30
  log_queue = queue.Queue()
31
  try:
32
- # Start manifest server in background with explicit CUDA_VISIBLE_DEVICES
33
  manifest_cmd = f"""
34
  cd duckdb-nsql/ &&
35
- CUDA_VISIBLE_DEVICES=0 HF_TOKEN={os.environ['HF_TOKEN']} python -m manifest.api.app \
36
  --model_type huggingface \
37
  --model_generation_type text-generation \
38
  --model_name_or_path {model_name} \
@@ -46,15 +45,20 @@ def run_evaluation(model_name):
46
  results.append("Started manifest server in background.")
47
 
48
  # Wait for the server to initialize (adjust time as needed)
49
- for _ in range(30):
 
50
  try:
51
  line = log_queue.get(timeout=1)
52
  manifest_logs.append(line)
53
  if "Running on" in line: # Server is ready
 
54
  break
55
  except queue.Empty:
56
  pass
57
 
 
 
 
58
  # Run inference
59
  inference_cmd = f"""
60
  cd duckdb-nsql/ &&
 
6
  import re
7
  import threading
8
  import queue
9
+ import time
10
 
11
  zero = torch.Tensor([0]).cuda()
12
  print(zero.device) # <-- 'cpu' 🤔
 
23
  results = []
24
  manifest_logs = []
25
 
 
26
  if "HF_TOKEN" not in os.environ:
27
  return "Error: HF_TOKEN not found in environment variables.", "Error: Cannot start manifest server without HF_TOKEN."
28
 
29
  manifest_process = None
30
  log_queue = queue.Queue()
31
  try:
 
32
  manifest_cmd = f"""
33
  cd duckdb-nsql/ &&
34
+ CUDA_VISIBLE_DEVICES=0 HF_TOKEN={os.environ['HF_TOKEN']} python -m manifest.api.app \
35
  --model_type huggingface \
36
  --model_generation_type text-generation \
37
  --model_name_or_path {model_name} \
 
45
  results.append("Started manifest server in background.")
46
 
47
  # Wait for the server to initialize (adjust time as needed)
48
+ server_ready = False
49
+ for _ in range(60): # Increased timeout to 60 seconds
50
  try:
51
  line = log_queue.get(timeout=1)
52
  manifest_logs.append(line)
53
  if "Running on" in line: # Server is ready
54
+ server_ready = True
55
  break
56
  except queue.Empty:
57
  pass
58
 
59
+ if not server_ready:
60
+ raise Exception("Manifest server failed to start within the expected time.")
61
+
62
  # Run inference
63
  inference_cmd = f"""
64
  cd duckdb-nsql/ &&