Spaces:
Sleeping
Sleeping
Update submit_job.py
Browse files- submit_job.py +25 -22
submit_job.py
CHANGED
|
@@ -1,42 +1,48 @@
|
|
| 1 |
"""
|
| 2 |
Submit the Data-Centric AI training job to HF infrastructure.
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
python submit_job.py
|
|
|
|
|
|
|
|
|
|
| 9 |
"""
|
| 10 |
import os, sys
|
| 11 |
from huggingface_hub import HfApi
|
| 12 |
|
| 13 |
TOKEN = os.environ.get("HF_TOKEN") or input("Enter your HF token (hf_...): ").strip()
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
api = HfApi(token=TOKEN)
|
| 21 |
|
| 22 |
print("Submitting HF training job...")
|
| 23 |
-
print(f" Docker image: {
|
| 24 |
print(f" ENV_URL : {ENV_URL}")
|
| 25 |
-
print(f" Hardware : a10g-large
|
| 26 |
|
| 27 |
-
#
|
| 28 |
bash_cmd = f"""
|
| 29 |
-
apt-get update && apt-get install -y git && \\
|
| 30 |
git clone {REPO_URL} /app && cd /app && \\
|
| 31 |
-
pip install -q
|
| 32 |
-
pip install -q 'unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git' \\
|
| 33 |
-
trl>=0.15.0 datasets>=2.0.0 transformers>=4.40.0 accelerate>=0.30.0 matplotlib && \\
|
| 34 |
pip install -e . && \\
|
| 35 |
python hf_job_train.py
|
| 36 |
"""
|
| 37 |
|
| 38 |
job = api.run_job(
|
| 39 |
-
image=
|
| 40 |
command=["bash", "-c", bash_cmd],
|
| 41 |
env={
|
| 42 |
"ENV_URL": ENV_URL,
|
|
@@ -45,12 +51,9 @@ job = api.run_job(
|
|
| 45 |
flavor="a10g-large",
|
| 46 |
)
|
| 47 |
|
| 48 |
-
print(f"\nJob submitted
|
| 49 |
print(f" Job ID : {job.id}")
|
| 50 |
print(f" Status : {job.status}")
|
| 51 |
-
print(f" Monitor : https://huggingface.co/
|
| 52 |
-
print(f"\
|
| 53 |
-
print(f"
|
| 54 |
-
print(f" git add plots/ logs/")
|
| 55 |
-
print(f' git commit -m "Add training results"')
|
| 56 |
-
print(f" git push origin main && git push hf main")
|
|
|
|
| 1 |
"""
|
| 2 |
Submit the Data-Centric AI training job to HF infrastructure.
|
| 3 |
|
| 4 |
+
⚠️ RECOMMENDED: Use the Colab notebook instead — it's more reliable.
|
| 5 |
+
https://colab.research.google.com/github/CelestialWorthyOfHeavenAndEarth/data-centric-env/blob/main/train_colab.ipynb
|
| 6 |
|
| 7 |
+
HF Jobs is provided as an alternative for automated / unattended runs.
|
| 8 |
+
|
| 9 |
+
Usage (Windows):
|
| 10 |
+
set HF_TOKEN=hf_yourtoken
|
| 11 |
python submit_job.py
|
| 12 |
+
|
| 13 |
+
Usage (Linux/Mac):
|
| 14 |
+
HF_TOKEN=hf_yourtoken python submit_job.py
|
| 15 |
"""
|
| 16 |
import os, sys
|
| 17 |
from huggingface_hub import HfApi
|
| 18 |
|
| 19 |
TOKEN = os.environ.get("HF_TOKEN") or input("Enter your HF token (hf_...): ").strip()
|
| 20 |
|
| 21 |
+
ENV_URL = "https://aswini-kumar-data-centric-env.hf.space"
|
| 22 |
+
REPO_URL = "https://huggingface.co/spaces/Aswini-Kumar/data-centric-env"
|
| 23 |
+
|
| 24 |
+
# Use official Unsloth Docker image — has torch 2.4.1 + compatible torchao pre-installed
|
| 25 |
+
# See: https://hub.docker.com/r/unsloth/unsloth/tags
|
| 26 |
+
DOCKER_IMAGE = "unsloth/unsloth:latest-torch241"
|
| 27 |
|
| 28 |
api = HfApi(token=TOKEN)
|
| 29 |
|
| 30 |
print("Submitting HF training job...")
|
| 31 |
+
print(f" Docker image: {DOCKER_IMAGE}")
|
| 32 |
print(f" ENV_URL : {ENV_URL}")
|
| 33 |
+
print(f" Hardware : a10g-large")
|
| 34 |
|
| 35 |
+
# Clone repo + run training (torchao + unsloth are pre-installed in the image)
|
| 36 |
bash_cmd = f"""
|
| 37 |
+
apt-get update -qq && apt-get install -y -qq git && \\
|
| 38 |
git clone {REPO_URL} /app && cd /app && \\
|
| 39 |
+
pip install -q openenv-core[core]>=0.2.1 scikit-learn>=1.3.0 pandas>=2.0.0 numpy matplotlib && \\
|
|
|
|
|
|
|
| 40 |
pip install -e . && \\
|
| 41 |
python hf_job_train.py
|
| 42 |
"""
|
| 43 |
|
| 44 |
job = api.run_job(
|
| 45 |
+
image=DOCKER_IMAGE,
|
| 46 |
command=["bash", "-c", bash_cmd],
|
| 47 |
env={
|
| 48 |
"ENV_URL": ENV_URL,
|
|
|
|
| 51 |
flavor="a10g-large",
|
| 52 |
)
|
| 53 |
|
| 54 |
+
print(f"\nJob submitted!")
|
| 55 |
print(f" Job ID : {job.id}")
|
| 56 |
print(f" Status : {job.status}")
|
| 57 |
+
print(f" Monitor : https://huggingface.co/jobs/Aswini-Kumar/{job.id}")
|
| 58 |
+
print(f"\n⚡ Alternatively, use Colab for a more reliable run:")
|
| 59 |
+
print(f" https://colab.research.google.com/github/CelestialWorthyOfHeavenAndEarth/data-centric-env/blob/main/train_colab.ipynb")
|
|
|
|
|
|
|
|
|