Skip to content

Commit

Permalink
add errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkrthakur committed Feb 14, 2024
1 parent 2c71447 commit 8036815
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/autotrain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@


HF_TOKEN = os.environ.get("HF_TOKEN", None)
_, _, USERS = app_utils.user_validation()
ENABLE_NGC = int(os.environ.get("ENABLE_NGC", 0))
ENABLE_NVCF = int(os.environ.get("ENABLE_NVCF", 0))
DB = AutoTrainDB("autotrain.db")
Expand Down Expand Up @@ -234,6 +233,8 @@ async def read_form(request: Request):
"""
if HF_TOKEN is None:
return templates.TemplateResponse("error.html", {"request": request})

_, _, USERS = app_utils.user_validation()
context = {
"request": request,
"valid_users": USERS,
Expand Down
6 changes: 2 additions & 4 deletions src/autotrain/app_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ def user_validation():
user_token = os.environ.get("HF_TOKEN", None)

if user_token is None:
logger.error("Please login with a write token.")
return None, None, None
raise Exception("Please login with a write token.")

user_token, valid_can_pay, who_is_training = _login_user(user_token)

if user_token is None or len(user_token) == 0:
logger.error("Please login with a write token.")
return None, None, None
raise Exception("Invalid token. Please login with a write token.")

return user_token, valid_can_pay, who_is_training

Expand Down

0 comments on commit 8036815

Please sign in to comment.