sweatstack 0.27.0__py3-none-any.whl → 0.28.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sweatstack/streamlit.py CHANGED
@@ -88,6 +88,11 @@ class StreamlitAuth:
88
88
 
89
89
  return authorization_url
90
90
 
91
+ def _set_api_key(self, api_key):
92
+ self.api_key = api_key
93
+ st.session_state["sweatstack_api_key"] = api_key
94
+ self.client = Client(self.api_key, streamlit_compatible=True)
95
+
91
96
  def _exchange_token(self, code):
92
97
  token_data = {
93
98
  "grant_type": "authorization_code",
@@ -107,10 +112,7 @@ class StreamlitAuth:
107
112
  raise Exception(f"SweatStack Python login failed. Please try again.") from e
108
113
  token_response = response.json()
109
114
 
110
- self.api_key = token_response.get("access_token")
111
- st.session_state["sweatstack_api_key"] = self.api_key
112
-
113
- self.client = Client(self.api_key, streamlit_compatible=True)
115
+ self._set_api_key(token_response.get("access_token"))
114
116
 
115
117
  return
116
118
 
@@ -128,4 +130,21 @@ class StreamlitAuth:
128
130
  st.query_params.clear()
129
131
  st.rerun()
130
132
  else:
131
- self._show_sweatstack_login()
133
+ self._show_sweatstack_login()
134
+
135
+ def switch_user(self):
136
+ self.switch_back()
137
+ other_users = self.client.get_users()
138
+ selected_user = st.selectbox(
139
+ "Select a user",
140
+ other_users,
141
+ format_func=lambda user: user.display_name,
142
+ )
143
+ self.client.switch_user(selected_user)
144
+ self._set_api_key(self.client.api_key)
145
+
146
+ return selected_user
147
+
148
+ def switch_back(self):
149
+ self.client.switch_back()
150
+ self._set_api_key(self.client.api_key)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sweatstack
3
- Version: 0.27.0
3
+ Version: 0.28.0
4
4
  Summary: The official Python client for SweatStack
5
5
  Author-email: Aart Goossens <aart@gssns.io>
6
6
  Requires-Python: >=3.9
@@ -7,11 +7,11 @@ sweatstack/jupyterlab_oauth2_startup.py,sha256=eZ6xi0Sa4hO4vUanimq0SqjduHtiywCUR
7
7
  sweatstack/openapi_schemas.py,sha256=XlgiL7qkfcfoDHcQrIm9e5hvhY98onC0QmZWG69bl-s,13441
8
8
  sweatstack/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  sweatstack/schemas.py,sha256=CArM9jgrJDBUT-ZIIiGN_insqaEGV43MX134Ezf4jyA,103
10
- sweatstack/streamlit.py,sha256=zBPIC29OvgqvuKNlezgLOTwgvS-Cbg885QFwuW4NMRk,4968
10
+ sweatstack/streamlit.py,sha256=z4xggT1igrTLQCPMQeCBbXUnC2w35dFSH3NSQRVrZgc,5527
11
11
  sweatstack/sweatshell.py,sha256=MYLNcWbOdceqKJ3S0Pe8dwHXEeYsGJNjQoYUXpMTftA,333
12
12
  sweatstack/utils.py,sha256=HtR1NNCKus59vfgfaCSFS-tHA11mtdcuUx5lS6ZX58g,1773
13
13
  sweatstack/Sweat Stack examples/Getting started.ipynb,sha256=k2hiSffWecoQ0VxjdpDcgFzBXDQiYEebhnAYlu8cgX8,6335204
14
- sweatstack-0.27.0.dist-info/METADATA,sha256=YKWKjaX0UYaqA3ODVWZKlOqba4z-xKF0PI5TS8z3P7E,775
15
- sweatstack-0.27.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- sweatstack-0.27.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
- sweatstack-0.27.0.dist-info/RECORD,,
14
+ sweatstack-0.28.0.dist-info/METADATA,sha256=o6fVjDMx337xaw9ujyRtRtfWIaNTdIU4FjrAMe9zMjw,775
15
+ sweatstack-0.28.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ sweatstack-0.28.0.dist-info/entry_points.txt,sha256=kCzOUQI3dqbTpEYqtgYDeiKFaqaA7BMlV6D24BMzCFU,208
17
+ sweatstack-0.28.0.dist-info/RECORD,,