TenzinGayche commited on
Commit
5c16155
·
verified ·
1 Parent(s): f98b0ac

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +11 -11
handler.py CHANGED
@@ -23,9 +23,9 @@ git_clone_command = "git clone https://github.com/OpenPecha/tibetan-aligner"
23
  # Run the command using subprocess
24
  try:
25
  subprocess.run(git_clone_command, shell=True, check=True)
26
- logging.info("Git clone successful!")
27
  except subprocess.CalledProcessError as e:
28
- logging.info(f"Error while running Git clone command: {e}")
29
 
30
 
31
  ALIGNER_SCRIPT_DIR = Path("./tibetan-aligner").resolve()
@@ -43,7 +43,7 @@ GITHUB_ORG = "MonlamAI"
43
  MAI_TM_PUBLISH_TODO_REPO = "MonlamAI_TMs_Publish_TODO"
44
  GITHUB_API_ENDPOINT = f"https://api.github.com/orgs/{GITHUB_ORG}/repos"
45
 
46
- DEBUG = False
47
 
48
  quiet = "-q" if DEBUG else ""
49
  def make_dir_executable(dir_path: Path):
@@ -106,7 +106,7 @@ def convert_raw_align_to_tm(align_fn: Path, tm_path: Path):
106
 
107
  def load_alignment(fn: Path):
108
  content = fn.read_text()
109
- logging.info("Content !!! \n\n"+content)
110
  if not content:
111
  return []
112
 
@@ -172,7 +172,7 @@ def add_to_publish_todo_repo(org, repo_name, file_path, access_token):
172
  response = requests.get(url, headers=headers)
173
 
174
  if response.status_code == 200:
175
- logging.info(f"[INFO] '{file_path}' already added.")
176
  return
177
 
178
  payload = {"message": f"Add {file_path}", "content": ""}
@@ -180,10 +180,10 @@ def add_to_publish_todo_repo(org, repo_name, file_path, access_token):
180
  response = requests.put(url, headers=headers, json=payload)
181
 
182
  if response.status_code == 201:
183
- logging.info(f"[INFO] '{file_path}' added to publish todo")
184
  else:
185
- logging.info(f"[ERROR] Failed to add '{file_path}'.")
186
- logging.info(f"[ERROR] Response: {response.text}")
187
 
188
 
189
  def create_tm(align_fn: Path, text_pair: Dict[str, str]):
@@ -246,10 +246,10 @@ def align(text_pair):
246
  output_dir = Path(tmpdir)
247
  bo_fn = download_file(text_pair["bo_file_url"], output_fn=output_dir / "bo.tx")
248
  en_fn = download_file(text_pair["en_file_url"], output_fn=output_dir / "en.tx")
249
- logging.info("bo_fn: ", bo_fn)
250
- logging.info("en_fn: ", en_fn)
251
  aligned_fn = _run_align_script(bo_fn, en_fn, output_dir)
252
- logging.info("aligned_fn: ", aligned_fn)
253
  repo_url = create_tm(aligned_fn, text_pair=text_pair)
254
  return {"tm_repo_url": repo_url}
255
 
 
23
  # Run the command using subprocess
24
  try:
25
  subprocess.run(git_clone_command, shell=True, check=True)
26
+ print("Git clone successful!")
27
  except subprocess.CalledProcessError as e:
28
+ print(f"Error while running Git clone command: {e}")
29
 
30
 
31
  ALIGNER_SCRIPT_DIR = Path("./tibetan-aligner").resolve()
 
43
  MAI_TM_PUBLISH_TODO_REPO = "MonlamAI_TMs_Publish_TODO"
44
  GITHUB_API_ENDPOINT = f"https://api.github.com/orgs/{GITHUB_ORG}/repos"
45
 
46
+ DEBUG = True
47
 
48
  quiet = "-q" if DEBUG else ""
49
  def make_dir_executable(dir_path: Path):
 
106
 
107
  def load_alignment(fn: Path):
108
  content = fn.read_text()
109
+ print("Content !!! \n\n"+content)
110
  if not content:
111
  return []
112
 
 
172
  response = requests.get(url, headers=headers)
173
 
174
  if response.status_code == 200:
175
+ print(f"[INFO] '{file_path}' already added.")
176
  return
177
 
178
  payload = {"message": f"Add {file_path}", "content": ""}
 
180
  response = requests.put(url, headers=headers, json=payload)
181
 
182
  if response.status_code == 201:
183
+ print(f"[INFO] '{file_path}' added to publish todo")
184
  else:
185
+ print(f"[ERROR] Failed to add '{file_path}'.")
186
+ print(f"[ERROR] Response: {response.text}")
187
 
188
 
189
  def create_tm(align_fn: Path, text_pair: Dict[str, str]):
 
246
  output_dir = Path(tmpdir)
247
  bo_fn = download_file(text_pair["bo_file_url"], output_fn=output_dir / "bo.tx")
248
  en_fn = download_file(text_pair["en_file_url"], output_fn=output_dir / "en.tx")
249
+ print("bo_fn: ", bo_fn)
250
+ print("en_fn: ", en_fn)
251
  aligned_fn = _run_align_script(bo_fn, en_fn, output_dir)
252
+ print("aligned_fn: ", aligned_fn)
253
  repo_url = create_tm(aligned_fn, text_pair=text_pair)
254
  return {"tm_repo_url": repo_url}
255