Yurii Paniv commited on
Commit
e3fc854
·
1 Parent(s): a9df991

Log straight away

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -47,9 +47,12 @@ if getenv("HF_API_TOKEN") is not None:
47
  #log_queue = Queue()
48
  #t = Thread(target=check_thread, args=(log_queue,))
49
  #t.start()
50
-
51
- # handle zeroGPU
52
- log_queue = None
 
 
 
53
  else:
54
  print("No HF_API_TOKEN found. Logging is disabled.")
55
 
@@ -82,11 +85,15 @@ def translate(input_text):
82
  print(f"{datetime.utcnow()} | Translating: {input_text}")
83
 
84
  if getenv("HF_API_TOKEN") is not None:
85
- if log_queue is None:
86
- log_queue = Queue()
87
- t = Thread(target=check_thread, args=(log_queue,))
88
- t.start()
89
- log_queue.put([input_text])
 
 
 
 
90
 
91
  input_text = f"[INST] {input_text} [/INST]"
92
  inputs = tokenizer([input_text], return_tensors="pt").to(model.device)
 
47
  #log_queue = Queue()
48
  #t = Thread(target=check_thread, args=(log_queue,))
49
  #t.start()
50
+
51
+ logging_callback = log_data(
52
+ hf_token=getenv("HF_API_TOKEN"),
53
+ dataset_name=getenv("OUTPUT_DATASET"),
54
+ private=True,
55
+ )
56
  else:
57
  print("No HF_API_TOKEN found. Logging is disabled.")
58
 
 
85
  print(f"{datetime.utcnow()} | Translating: {input_text}")
86
 
87
  if getenv("HF_API_TOKEN") is not None:
88
+ try:
89
+ logging_callback = log_data(
90
+ hf_token=getenv("HF_API_TOKEN"),
91
+ dataset_name=getenv("OUTPUT_DATASET"),
92
+ private=True,
93
+ )
94
+ logging_callback([input_text])
95
+ except:
96
+ print("Error happened while pushing data to HF.")
97
 
98
  input_text = f"[INST] {input_text} [/INST]"
99
  inputs = tokenizer([input_text], return_tensors="pt").to(model.device)