Update helpers/get_credentials.py
Browse files- helpers/get_credentials.py +27 -2
helpers/get_credentials.py
CHANGED
@@ -28,7 +28,7 @@ __version__ = "0.0.1"
|
|
28 |
import os
|
29 |
import sys
|
30 |
|
31 |
-
def
|
32 |
"""
|
33 |
Function that loads HF credentials from env file.
|
34 |
The function exits the app if HF token is missing.
|
@@ -60,4 +60,29 @@ def get_credentials():
|
|
60 |
except:
|
61 |
print('Please include your HF_URL in the .env file')
|
62 |
return hf_token, default_hf_url
|
63 |
-
return hf_token, hf_url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
import os
|
29 |
import sys
|
30 |
|
31 |
+
def get_hf_credentials():
|
32 |
"""
|
33 |
Function that loads HF credentials from env file.
|
34 |
The function exits the app if HF token is missing.
|
|
|
60 |
except:
|
61 |
print('Please include your HF_URL in the .env file')
|
62 |
return hf_token, default_hf_url
|
63 |
+
return hf_token, hf_url
|
64 |
+
|
65 |
+
def get_replicate_credentials():
|
66 |
+
"""
|
67 |
+
Function that loads Replicate credentials from env file.
|
68 |
+
The function exits the app if Replicate token is missing.
|
69 |
+
|
70 |
+
Args:
|
71 |
+
None.
|
72 |
+
|
73 |
+
Returns:
|
74 |
+
repl_token: personal Replicate token.
|
75 |
+
|
76 |
+
Raises:
|
77 |
+
ValueError when repl_token
|
78 |
+
values is missing or incorrect.
|
79 |
+
"""
|
80 |
+
try:
|
81 |
+
repl_token = os.environ.get('REPLICATE_TOKEN')
|
82 |
+
if not repl_token or repl_token == '<include-token-here>':
|
83 |
+
raise ValueError
|
84 |
+
except:
|
85 |
+
print('Please include your REPLICATE_TOKEN in the .env file')
|
86 |
+
sys.exit(1)
|
87 |
+
|
88 |
+
return repl_token
|