Spaces:
Sleeping
Sleeping
updating to acces user database from private repo
Browse files
app.py
CHANGED
|
@@ -13,9 +13,11 @@ from yaml.loader import SafeLoader
|
|
| 13 |
from PIL import Image
|
| 14 |
import os
|
| 15 |
from huggingface_hub import CommitScheduler, login
|
|
|
|
| 16 |
|
| 17 |
login(token=os.environ.get("HF_TOKEN"), write_permission=True)
|
| 18 |
|
|
|
|
| 19 |
AUTHENTICATOR = None
|
| 20 |
TBYB_LOGO = Image.open('./assets/TBYB_logo_light.png')
|
| 21 |
USER_LOGGED_IN = False
|
|
@@ -33,6 +35,9 @@ USER_DATABASE_UPDATE_SCHEDULER = CommitScheduler(
|
|
| 33 |
path_in_repo="data",
|
| 34 |
every=3,
|
| 35 |
)
|
|
|
|
|
|
|
|
|
|
| 36 |
def create_new_user(authenticator, users):
|
| 37 |
|
| 38 |
try:
|
|
@@ -54,8 +59,9 @@ def forgot_password(authenticator, users):
|
|
| 54 |
# Random password should be transferred to user securely
|
| 55 |
except Exception as e:
|
| 56 |
st.error(e)
|
| 57 |
-
with
|
| 58 |
-
|
|
|
|
| 59 |
def update_account_details(authenticator, users):
|
| 60 |
if st.session_state["authentication_status"]:
|
| 61 |
try:
|
|
@@ -63,8 +69,9 @@ def update_account_details(authenticator, users):
|
|
| 63 |
st.success('Entries updated successfully')
|
| 64 |
except Exception as e:
|
| 65 |
st.error(e)
|
| 66 |
-
with
|
| 67 |
-
|
|
|
|
| 68 |
def reset_password(authenticator, users):
|
| 69 |
if st.session_state["authentication_status"]:
|
| 70 |
try:
|
|
@@ -72,8 +79,9 @@ def reset_password(authenticator, users):
|
|
| 72 |
st.success('Password modified successfully')
|
| 73 |
except Exception as e:
|
| 74 |
st.error(e)
|
| 75 |
-
with
|
| 76 |
-
|
|
|
|
| 77 |
def user_login_create():
|
| 78 |
global AUTHENTICATOR
|
| 79 |
global TBYB_LOGO
|
|
|
|
| 13 |
from PIL import Image
|
| 14 |
import os
|
| 15 |
from huggingface_hub import CommitScheduler, login
|
| 16 |
+
from datasets import load_dataset
|
| 17 |
|
| 18 |
login(token=os.environ.get("HF_TOKEN"), write_permission=True)
|
| 19 |
|
| 20 |
+
|
| 21 |
AUTHENTICATOR = None
|
| 22 |
TBYB_LOGO = Image.open('./assets/TBYB_logo_light.png')
|
| 23 |
USER_LOGGED_IN = False
|
|
|
|
| 35 |
path_in_repo="data",
|
| 36 |
every=3,
|
| 37 |
)
|
| 38 |
+
|
| 39 |
+
storedUserDatabase = load_dataset("JVice/try-before-you-bias-data",data_files=data/user_database.yaml)
|
| 40 |
+
st.write(storedUserDatabase)
|
| 41 |
def create_new_user(authenticator, users):
|
| 42 |
|
| 43 |
try:
|
|
|
|
| 59 |
# Random password should be transferred to user securely
|
| 60 |
except Exception as e:
|
| 61 |
st.error(e)
|
| 62 |
+
with USER_DATABASE_UPDATE_SCHEDULER.lock:
|
| 63 |
+
with open(USER_DATABASE_PATH, 'w') as file:
|
| 64 |
+
yaml.dump(users, file, default_flow_style=False)
|
| 65 |
def update_account_details(authenticator, users):
|
| 66 |
if st.session_state["authentication_status"]:
|
| 67 |
try:
|
|
|
|
| 69 |
st.success('Entries updated successfully')
|
| 70 |
except Exception as e:
|
| 71 |
st.error(e)
|
| 72 |
+
with USER_DATABASE_UPDATE_SCHEDULER.lock:
|
| 73 |
+
with open(USER_DATABASE_PATH, 'w') as file:
|
| 74 |
+
yaml.dump(users, file, default_flow_style=False)
|
| 75 |
def reset_password(authenticator, users):
|
| 76 |
if st.session_state["authentication_status"]:
|
| 77 |
try:
|
|
|
|
| 79 |
st.success('Password modified successfully')
|
| 80 |
except Exception as e:
|
| 81 |
st.error(e)
|
| 82 |
+
with USER_DATABASE_UPDATE_SCHEDULER.lock:
|
| 83 |
+
with open(USER_DATABASE_PATH, 'w') as file:
|
| 84 |
+
yaml.dump(users, file, default_flow_style=False)
|
| 85 |
def user_login_create():
|
| 86 |
global AUTHENTICATOR
|
| 87 |
global TBYB_LOGO
|