Instructions to use openpecha/aligner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openpecha/aligner with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("openpecha/aligner") model = AutoModelForSeq2SeqLM.from_pretrained("openpecha/aligner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse files- handler.py +11 -5
handler.py
CHANGED
|
@@ -69,10 +69,14 @@ def create_github_repo(repo_path: Path, repo_name: str, version: str, realign: b
|
|
| 69 |
# Initialize a Git repository
|
| 70 |
subprocess.run(f"git init".split(), cwd=str(repo_path))
|
| 71 |
|
| 72 |
-
#
|
| 73 |
subprocess.run("git add .".split(), cwd=str(repo_path))
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
# Check if realigning
|
| 78 |
if realign:
|
|
@@ -83,6 +87,10 @@ def create_github_repo(repo_path: Path, repo_name: str, version: str, realign: b
|
|
| 83 |
logging.error("Version not specified for realignment.")
|
| 84 |
return
|
| 85 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# Create a new repository on GitHub
|
| 87 |
response = requests.post(
|
| 88 |
GITHUB_API_ENDPOINT,
|
|
@@ -93,7 +101,6 @@ def create_github_repo(repo_path: Path, repo_name: str, version: str, realign: b
|
|
| 93 |
auth=(GITHUB_USERNAME, GITHUB_ACCESS_TOKEN),
|
| 94 |
)
|
| 95 |
response.raise_for_status()
|
| 96 |
-
|
| 97 |
time.sleep(3)
|
| 98 |
|
| 99 |
# Add the GitHub remote to the local Git repository
|
|
@@ -107,7 +114,6 @@ def create_github_repo(repo_path: Path, repo_name: str, version: str, realign: b
|
|
| 107 |
subprocess.run(f"git push -u origin {branch_name}".split(), cwd=str(repo_path))
|
| 108 |
|
| 109 |
return f"Branch '{branch_name}' updated in {repo_name}" if realign else response.json()["html_url"]
|
| 110 |
-
|
| 111 |
def convert_raw_align_to_tm(align_fn: Path, tm_path: Path):
|
| 112 |
if DEBUG:
|
| 113 |
logging.debug("[INFO] Conerting raw alignment to TM repo...")
|
|
|
|
| 69 |
# Initialize a Git repository
|
| 70 |
subprocess.run(f"git init".split(), cwd=str(repo_path))
|
| 71 |
|
| 72 |
+
# Add files and check if there are changes to commit
|
| 73 |
subprocess.run("git add .".split(), cwd=str(repo_path))
|
| 74 |
+
status_result = subprocess.run("git status --porcelain".split(), cwd=str(repo_path), capture_output=True)
|
| 75 |
+
if status_result.stdout:
|
| 76 |
+
commit_message = "Initial commit" if not realign else f"Commit for version {version}"
|
| 77 |
+
subprocess.run(f"git commit -m".split() + [commit_message], cwd=str(repo_path))
|
| 78 |
+
else:
|
| 79 |
+
logging.info("No changes to commit.")
|
| 80 |
|
| 81 |
# Check if realigning
|
| 82 |
if realign:
|
|
|
|
| 87 |
logging.error("Version not specified for realignment.")
|
| 88 |
return
|
| 89 |
else:
|
| 90 |
+
# Create and checkout main branch if it doesn't exist
|
| 91 |
+
subprocess.run("git branch -m main".split(), cwd=str(repo_path))
|
| 92 |
+
subprocess.run("git checkout main".split(), cwd=str(repo_path))
|
| 93 |
+
|
| 94 |
# Create a new repository on GitHub
|
| 95 |
response = requests.post(
|
| 96 |
GITHUB_API_ENDPOINT,
|
|
|
|
| 101 |
auth=(GITHUB_USERNAME, GITHUB_ACCESS_TOKEN),
|
| 102 |
)
|
| 103 |
response.raise_for_status()
|
|
|
|
| 104 |
time.sleep(3)
|
| 105 |
|
| 106 |
# Add the GitHub remote to the local Git repository
|
|
|
|
| 114 |
subprocess.run(f"git push -u origin {branch_name}".split(), cwd=str(repo_path))
|
| 115 |
|
| 116 |
return f"Branch '{branch_name}' updated in {repo_name}" if realign else response.json()["html_url"]
|
|
|
|
| 117 |
def convert_raw_align_to_tm(align_fn: Path, tm_path: Path):
|
| 118 |
if DEBUG:
|
| 119 |
logging.debug("[INFO] Conerting raw alignment to TM repo...")
|