Spaces:
Runtime error
Runtime error
Commit
·
51cf589
1
Parent(s):
a40e4e2
Update app.py
Browse files
app.py
CHANGED
@@ -45,21 +45,6 @@ class UxState(str, Enum):
|
|
45 |
CAPTCHA = "captcha"
|
46 |
TRAIN = "train"
|
47 |
|
48 |
-
# Command-line arguments to control some stuff for easier local testing.
|
49 |
-
# Eventually may want to move everything into functions and have a
|
50 |
-
# if __name__ == "main" setup instead of everything inline.
|
51 |
-
parser = argparse.ArgumentParser()
|
52 |
-
parser.add_argument(
|
53 |
-
"--dry-run", action="store_true",
|
54 |
-
help="Skip sending train request to backend server.",
|
55 |
-
)
|
56 |
-
parser.add_argument(
|
57 |
-
"--train-endpoint-url", default=None,
|
58 |
-
help="URL of backend server to send train request to. If None, use hardcoded banana setup.",
|
59 |
-
)
|
60 |
-
cli_args = parser.parse_args()
|
61 |
-
|
62 |
-
|
63 |
def setup_session_state():
|
64 |
if "key" not in st.session_state:
|
65 |
st.session_state["key"] = uuid.uuid4().hex
|
@@ -257,21 +242,10 @@ def verify_captcha(captcha_id, captcha_response):
|
|
257 |
return {"error": "Failed to verify captcha"}
|
258 |
|
259 |
def train_model(model_inputs):
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
if cli_args.train_endpoint_url is None:
|
266 |
-
# Use banana backend
|
267 |
-
api_key = "03cdd72e-5c04-4207-bd6a-fd5712c1740e"
|
268 |
-
model_key = "1a3b4ce5-164f-4efb-9f4a-c2ad3a930d0b"
|
269 |
-
st.markdown(str(model_inputs))
|
270 |
-
_ = banana.run(api_key, model_key, model_inputs)
|
271 |
-
else:
|
272 |
-
# Send request directly to specified url
|
273 |
-
_ = requests.post(cli_args.train_endpoint_url, json=model_inputs)
|
274 |
-
|
275 |
|
276 |
def run_login():
|
277 |
user_email_input = st.empty()
|
|
|
45 |
CAPTCHA = "captcha"
|
46 |
TRAIN = "train"
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
def setup_session_state():
|
49 |
if "key" not in st.session_state:
|
50 |
st.session_state["key"] = uuid.uuid4().hex
|
|
|
242 |
return {"error": "Failed to verify captcha"}
|
243 |
|
244 |
def train_model(model_inputs):
|
245 |
+
api_key = os.environ.get('API_KEY')
|
246 |
+
model_key = os.environ.get('MODEL_KEY')
|
247 |
+
st.markdown(str(model_inputs))
|
248 |
+
_ = banana.run(api_key, model_key, model_inputs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
|
250 |
def run_login():
|
251 |
user_email_input = st.empty()
|