Spaces:
Running
Commit
β’
3cfa4b5
1
Parent(s):
8b5ae1b
feat: implement basic auth UI
Browse files- .gitignore +2 -1
- components/__pycache__/auth.cpython-38.pyc +0 -0
- components/__pycache__/custodian.cpython-38.pyc +0 -0
- components/__pycache__/header.cpython-38.pyc +0 -0
- components/__pycache__/navigator.cpython-38.pyc +0 -0
- components/__pycache__/viewport.cpython-38.pyc +0 -0
- components/custodian.py +42 -0
- components/{core.py β header.py} +2 -4
- components/navigator.py +1 -3
- components/viewport.py +0 -1
- main.py +8 -15
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
__pycache__/*
|
2 |
-
conceptarium/*
|
|
1 |
__pycache__/*
|
2 |
+
conceptarium/*
|
3 |
+
records/custodian.json
|
components/__pycache__/auth.cpython-38.pyc
ADDED
Binary file (601 Bytes). View file
|
components/__pycache__/custodian.cpython-38.pyc
ADDED
Binary file (1.55 kB). View file
|
components/__pycache__/header.cpython-38.pyc
ADDED
Binary file (548 Bytes). View file
|
components/__pycache__/navigator.cpython-38.pyc
CHANGED
Binary files a/components/__pycache__/navigator.cpython-38.pyc and b/components/__pycache__/navigator.cpython-38.pyc differ
|
components/__pycache__/viewport.cpython-38.pyc
CHANGED
Binary files a/components/__pycache__/viewport.cpython-38.pyc and b/components/__pycache__/viewport.cpython-38.pyc differ
|
components/custodian.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import streamlit_authenticator as stauth
|
3 |
+
import os
|
4 |
+
import json
|
5 |
+
|
6 |
+
|
7 |
+
def paint():
|
8 |
+
with st.sidebar:
|
9 |
+
st.markdown('#### π custodian')
|
10 |
+
|
11 |
+
if not os.path.exists('records/custodian.json'):
|
12 |
+
st.warning('This appears to be a fresh conceptarium instance. Please create a custodian account.')
|
13 |
+
|
14 |
+
username = st.text_input('Username')
|
15 |
+
password = st.text_input('Password', type='password')
|
16 |
+
|
17 |
+
if st.button('create account'):
|
18 |
+
password = stauth.hasher([password]).generate()[0]
|
19 |
+
token = stauth.hasher([password + 'token']).generate()[0]
|
20 |
+
json.dump({
|
21 |
+
'username': username,
|
22 |
+
'password': password,
|
23 |
+
'token': token
|
24 |
+
}, open('records/custodian.json', 'w'))
|
25 |
+
st.balloons()
|
26 |
+
else:
|
27 |
+
st.warning('If you\'re the custodian of this conceptarium, please log into your account to access your stored thoughts.')
|
28 |
+
custodian = json.load(open('records/custodian.json'))
|
29 |
+
authenticator = stauth.authenticate([custodian['username']], [custodian['username']] , [custodian['password']],
|
30 |
+
'custodian_cookie', 'conceptarium', cookie_expiry_days=30)
|
31 |
+
name, authentication_status = authenticator.login('login', 'sidebar')
|
32 |
+
|
33 |
+
print(name, authentication_status)
|
34 |
+
|
35 |
+
if st.session_state['authentication_status']:
|
36 |
+
st.markdown('')
|
37 |
+
st.markdown('##### token')
|
38 |
+
st.code(custodian['token'], language='text')
|
39 |
+
elif st.session_state['authentication_status'] == False:
|
40 |
+
st.error('Username/password is incorrect')
|
41 |
+
elif st.session_state['authentication_status'] == None:
|
42 |
+
st.warning('Please enter your username and password')
|
components/{core.py β header.py}
RENAMED
@@ -1,11 +1,9 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
|
4 |
-
def
|
5 |
st.markdown('### π‘ conceptarium')
|
6 |
-
|
7 |
-
|
8 |
-
def footer_section():
|
9 |
hide_streamlit_style = '''
|
10 |
<style>
|
11 |
#MainMenu {visibility: hidden;}
|
1 |
import streamlit as st
|
2 |
|
3 |
|
4 |
+
def paint():
|
5 |
st.markdown('### π‘ conceptarium')
|
6 |
+
|
|
|
|
|
7 |
hide_streamlit_style = '''
|
8 |
<style>
|
9 |
#MainMenu {visibility: hidden;}
|
components/navigator.py
CHANGED
@@ -25,7 +25,6 @@ def load_imagery_shift():
|
|
25 |
|
26 |
|
27 |
def paint():
|
28 |
-
print('go')
|
29 |
model = load_model()
|
30 |
modality = st.selectbox('modality', ['language', 'imagery'],
|
31 |
['language', 'imagery'].index(st.session_state.get('navigator_modality', 'language')))
|
@@ -56,6 +55,5 @@ def paint():
|
|
56 |
st.session_state['navigator_modality'] = modality
|
57 |
st.session_state['navigator_embedding'] = embedding
|
58 |
st.session_state['navigator_input'] = input
|
59 |
-
|
60 |
-
# st.experimental_rerun()
|
61 |
|
25 |
|
26 |
|
27 |
def paint():
|
|
|
28 |
model = load_model()
|
29 |
modality = st.selectbox('modality', ['language', 'imagery'],
|
30 |
['language', 'imagery'].index(st.session_state.get('navigator_modality', 'language')))
|
55 |
st.session_state['navigator_modality'] = modality
|
56 |
st.session_state['navigator_embedding'] = embedding
|
57 |
st.session_state['navigator_input'] = input
|
58 |
+
|
|
|
59 |
|
components/viewport.py
CHANGED
@@ -26,7 +26,6 @@ def load_thoughts():
|
|
26 |
|
27 |
|
28 |
def paint(cols):
|
29 |
-
# print('on viewport:', st.session_state['ranker_noise'])
|
30 |
if st.session_state.get('navigator_embedding', None) is not None:
|
31 |
thoughts = load_thoughts()
|
32 |
results = util.semantic_search(
|
26 |
|
27 |
|
28 |
def paint(cols):
|
|
|
29 |
if st.session_state.get('navigator_embedding', None) is not None:
|
30 |
thoughts = load_thoughts()
|
31 |
results = util.semantic_search(
|
main.py
CHANGED
@@ -1,30 +1,23 @@
|
|
1 |
import streamlit as st
|
2 |
-
from components import
|
3 |
-
import streamlit.components.v1 as components
|
4 |
|
5 |
st.set_page_config(
|
6 |
page_title='π‘ conceptarium',
|
7 |
layout='wide')
|
8 |
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
core.footer_section()
|
13 |
|
14 |
-
|
15 |
-
left_section = [navigator, ranker]
|
16 |
-
right_section = [inspector]
|
17 |
-
|
18 |
-
|
19 |
-
for component in left_section:
|
20 |
with cols[0]:
|
21 |
with st.expander(component.get_name(), True):
|
22 |
component.paint()
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
for component in right_section:
|
27 |
with cols[-1]:
|
28 |
with st.expander(component.get_name(), True):
|
29 |
component.paint()
|
30 |
-
|
|
1 |
import streamlit as st
|
2 |
+
from components import custodian, header, inspector, navigator, viewport, ranker
|
|
|
3 |
|
4 |
st.set_page_config(
|
5 |
page_title='π‘ conceptarium',
|
6 |
layout='wide')
|
7 |
|
8 |
+
custodian.paint()
|
9 |
+
header.paint()
|
10 |
|
11 |
+
cols = st.columns(5)
|
|
|
12 |
|
13 |
+
for component in [navigator, ranker]:
|
|
|
|
|
|
|
|
|
|
|
14 |
with cols[0]:
|
15 |
with st.expander(component.get_name(), True):
|
16 |
component.paint()
|
17 |
|
18 |
+
for component in [inspector]:
|
|
|
|
|
19 |
with cols[-1]:
|
20 |
with st.expander(component.get_name(), True):
|
21 |
component.paint()
|
22 |
+
|
23 |
+
viewport.paint(cols[1:-1])
|