TenzinGayche commited on
Commit
3da352c
·
verified ·
1 Parent(s): c350303

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +24 -2
handler.py CHANGED
@@ -250,11 +250,33 @@ def _run_align_script(bo_fn, en_fn, output_dir):
250
  cwd=str(ALIGNER_SCRIPT_DIR),
251
  )
252
  logging.info(f"Content length of output: {output.stdout} characters")
253
- output_fn = re.search(r"\[OUTPUT\] (.*)", output.stdout).group(1)
254
- output_fn = "/" + output_fn.split("//")[-1]
 
 
 
 
 
 
 
 
255
  end = time.time()
256
  total_time = round((end - start) / 60, 2)
257
  logging.info(f"Total time taken for Aligning: {total_time} mins")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  return output_fn
259
  def align(text_pair):
260
 
 
250
  cwd=str(ALIGNER_SCRIPT_DIR),
251
  )
252
  logging.info(f"Content length of output: {output.stdout} characters")
253
+
254
+ match = re.search(r"\[OUTPUT\] (.*)", output.stdout)
255
+ if not match:
256
+ logging.error("Failed to find output file path in script output.")
257
+ return None
258
+
259
+ output_fn = match.group(1).strip()
260
+ # Normalize the file path
261
+ output_fn = Path(output_fn)
262
+
263
  end = time.time()
264
  total_time = round((end - start) / 60, 2)
265
  logging.info(f"Total time taken for Aligning: {total_time} mins")
266
+
267
+ # Read and log the contents of the output file
268
+ try:
269
+ if output_fn.exists():
270
+ content = output_fn.read_text()
271
+ if content:
272
+ logging.info(f"First 100 characters of {output_fn}: {content[:100]}...")
273
+ else:
274
+ logging.error(f"The file {output_fn} is empty.")
275
+ else:
276
+ logging.error(f"The file {output_fn} does not exist.")
277
+ except Exception as e:
278
+ logging.error(f"Error reading file {output_fn}: {e}")
279
+
280
  return output_fn
281
  def align(text_pair):
282