Spaces:
Running
Running
Use venv inside HF Jobs training container
Browse files
training/launch_hf_job.py
CHANGED
|
@@ -6,7 +6,7 @@ import shlex
|
|
| 6 |
import sys
|
| 7 |
from textwrap import dedent
|
| 8 |
|
| 9 |
-
from huggingface_hub import run_job
|
| 10 |
|
| 11 |
|
| 12 |
# Current Unsloth pulls torchao, which expects torch >= 2.11. Keep the Jobs
|
|
@@ -26,6 +26,8 @@ def bootstrap_repo(repo_url: str) -> list[str]:
|
|
| 26 |
"command -v git || (apt-get update && apt-get install -y git)",
|
| 27 |
f"git clone {shlex.quote(repo_url)} sentinel-env",
|
| 28 |
"cd sentinel-env",
|
|
|
|
|
|
|
| 29 |
"python -m pip install --upgrade pip",
|
| 30 |
"pip install -r requirements.txt",
|
| 31 |
"pip install -r requirements-train.txt",
|
|
@@ -132,17 +134,19 @@ def parse_args() -> argparse.Namespace:
|
|
| 132 |
|
| 133 |
def main() -> None:
|
| 134 |
args = parse_args()
|
| 135 |
-
token = os.environ.get("HF_TOKEN")
|
| 136 |
if not token:
|
| 137 |
raise SystemExit(
|
| 138 |
dedent(
|
| 139 |
"""
|
| 140 |
-
|
| 141 |
|
| 142 |
-
|
| 143 |
read -s HF_TOKEN
|
| 144 |
export HF_TOKEN
|
| 145 |
-
|
|
|
|
|
|
|
| 146 |
"""
|
| 147 |
).strip()
|
| 148 |
)
|
|
|
|
| 6 |
import sys
|
| 7 |
from textwrap import dedent
|
| 8 |
|
| 9 |
+
from huggingface_hub import get_token, run_job
|
| 10 |
|
| 11 |
|
| 12 |
# Current Unsloth pulls torchao, which expects torch >= 2.11. Keep the Jobs
|
|
|
|
| 26 |
"command -v git || (apt-get update && apt-get install -y git)",
|
| 27 |
f"git clone {shlex.quote(repo_url)} sentinel-env",
|
| 28 |
"cd sentinel-env",
|
| 29 |
+
"python -m venv --system-site-packages .job-venv || (apt-get update && apt-get install -y python3-venv && python -m venv --system-site-packages .job-venv)",
|
| 30 |
+
". .job-venv/bin/activate",
|
| 31 |
"python -m pip install --upgrade pip",
|
| 32 |
"pip install -r requirements.txt",
|
| 33 |
"pip install -r requirements-train.txt",
|
|
|
|
| 134 |
|
| 135 |
def main() -> None:
|
| 136 |
args = parse_args()
|
| 137 |
+
token = os.environ.get("HF_TOKEN") or get_token()
|
| 138 |
if not token:
|
| 139 |
raise SystemExit(
|
| 140 |
dedent(
|
| 141 |
"""
|
| 142 |
+
No Hugging Face token was found.
|
| 143 |
|
| 144 |
+
Either run:
|
| 145 |
read -s HF_TOKEN
|
| 146 |
export HF_TOKEN
|
| 147 |
+
|
| 148 |
+
Or log in once:
|
| 149 |
+
.venv/bin/hf auth login --add-to-git-credential
|
| 150 |
"""
|
| 151 |
).strip()
|
| 152 |
)
|