Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,6 +20,7 @@ import asyncio
|
|
| 20 |
from functools import partial
|
| 21 |
|
| 22 |
EXAM_DATASET_ID = os.getenv("EXAM_DATASET_ID") or "agents-course/unit_1_quiz"
|
|
|
|
| 23 |
EXAM_MAX_QUESTIONS = os.getenv("EXAM_MAX_QUESTIONS") or 1
|
| 24 |
EXAM_PASSING_SCORE = os.getenv("EXAM_PASSING_SCORE") or 0.8
|
| 25 |
CERTIFYING_ORG_LINKEDIN_ID = os.getenv("CERTIFYING_ORG_LINKEDIN_ID", "000000")
|
|
@@ -27,7 +28,7 @@ COURSE_TITLE = os.getenv("COURSE_TITLE", "Fundamentals of MCP")
|
|
| 27 |
|
| 28 |
ds = load_dataset(EXAM_DATASET_ID, split="train")
|
| 29 |
|
| 30 |
-
DATASET_REPO_URL = "https://huggingface.co/datasets/
|
| 31 |
|
| 32 |
# Convert dataset to a list of dicts and randomly sort
|
| 33 |
quiz_data = ds.to_pandas().to_dict("records")
|
|
@@ -120,7 +121,7 @@ def create_linkedin_button(username: str, cert_url: str | None) -> str:
|
|
| 120 |
current_month = date.today().month
|
| 121 |
|
| 122 |
# Use the dataset certificate URL if available, otherwise fallback to default
|
| 123 |
-
certificate_url = cert_url or "https://huggingface.co/
|
| 124 |
|
| 125 |
linkedin_params = {
|
| 126 |
"startTask": "CERTIFICATION_NAME",
|
|
@@ -162,7 +163,7 @@ async def upload_certificate_to_hub(username: str, certificate_img) -> str:
|
|
| 162 |
upload_file,
|
| 163 |
path_or_fileobj=tmp.name,
|
| 164 |
path_in_repo=f"certificates/{username}/{date.today()}.png",
|
| 165 |
-
repo_id=
|
| 166 |
repo_type="dataset",
|
| 167 |
token=os.getenv("HF_TOKEN"),
|
| 168 |
)
|
|
@@ -170,7 +171,7 @@ async def upload_certificate_to_hub(username: str, certificate_img) -> str:
|
|
| 170 |
|
| 171 |
# Construct the URL to the image
|
| 172 |
cert_url = (
|
| 173 |
-
f"https://huggingface.co/datasets/
|
| 174 |
f"resolve/main/certificates/{username}/{date.today()}.png"
|
| 175 |
)
|
| 176 |
|
|
|
|
| 20 |
from functools import partial
|
| 21 |
|
| 22 |
EXAM_DATASET_ID = os.getenv("EXAM_DATASET_ID") or "agents-course/unit_1_quiz"
|
| 23 |
+
CERTIFICATE_DATASET_REPO_ID = os.getenv("CERTIFICATE_DATASET_REPO_ID") or "smol-course/certificates"
|
| 24 |
EXAM_MAX_QUESTIONS = os.getenv("EXAM_MAX_QUESTIONS") or 1
|
| 25 |
EXAM_PASSING_SCORE = os.getenv("EXAM_PASSING_SCORE") or 0.8
|
| 26 |
CERTIFYING_ORG_LINKEDIN_ID = os.getenv("CERTIFYING_ORG_LINKEDIN_ID", "000000")
|
|
|
|
| 28 |
|
| 29 |
ds = load_dataset(EXAM_DATASET_ID, split="train")
|
| 30 |
|
| 31 |
+
DATASET_REPO_URL = f"https://huggingface.co/datasets/{CERTIFICATE_DATASET_REPO_ID}"
|
| 32 |
|
| 33 |
# Convert dataset to a list of dicts and randomly sort
|
| 34 |
quiz_data = ds.to_pandas().to_dict("records")
|
|
|
|
| 121 |
current_month = date.today().month
|
| 122 |
|
| 123 |
# Use the dataset certificate URL if available, otherwise fallback to default
|
| 124 |
+
certificate_url = cert_url or "https://huggingface.co/smol-course"
|
| 125 |
|
| 126 |
linkedin_params = {
|
| 127 |
"startTask": "CERTIFICATION_NAME",
|
|
|
|
| 163 |
upload_file,
|
| 164 |
path_or_fileobj=tmp.name,
|
| 165 |
path_in_repo=f"certificates/{username}/{date.today()}.png",
|
| 166 |
+
repo_id=CERTIFICATE_DATASET_REPO_ID,
|
| 167 |
repo_type="dataset",
|
| 168 |
token=os.getenv("HF_TOKEN"),
|
| 169 |
)
|
|
|
|
| 171 |
|
| 172 |
# Construct the URL to the image
|
| 173 |
cert_url = (
|
| 174 |
+
f"https://huggingface.co/datasets/{CERTIFICATE_DATASET_REPO_ID/"
|
| 175 |
f"resolve/main/certificates/{username}/{date.today()}.png"
|
| 176 |
)
|
| 177 |
|