sweatstack 0.13.2__tar.gz → 0.14.1__tar.gz
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-0.13.2 → sweatstack-0.14.1}/PKG-INFO +1 -2
- {sweatstack-0.13.2 → sweatstack-0.14.1}/pyproject.toml +1 -2
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/streamlit.py +8 -34
- {sweatstack-0.13.2 → sweatstack-0.14.1}/uv.lock +1 -15
- {sweatstack-0.13.2 → sweatstack-0.14.1}/.gitignore +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/.python-version +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/DEVELOPMENT.md +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/Makefile +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/README.md +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/__init__.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/cli.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/client.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/constants.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/ipython_init.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/jupyterlab_oauth2_startup.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/openapi_schemas.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/py.typed +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/schemas.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/sweatshell.py +0 -0
- {sweatstack-0.13.2 → sweatstack-0.14.1}/src/sweatstack/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sweatstack
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.1
|
|
4
4
|
Summary: The official Python client for SweatStack
|
|
5
5
|
Author-email: Aart Goossens <aart@gssns.io>
|
|
6
6
|
Requires-Python: >=3.12
|
|
@@ -13,7 +13,6 @@ Requires-Dist: ipython>=8.31.0; extra == 'jupyterlab'
|
|
|
13
13
|
Requires-Dist: jupyterlab>=4.3.4; extra == 'jupyterlab'
|
|
14
14
|
Requires-Dist: matplotlib; extra == 'jupyterlab'
|
|
15
15
|
Provides-Extra: streamlit
|
|
16
|
-
Requires-Dist: streamlit-cookies-controller>=0.0.4; extra == 'streamlit'
|
|
17
16
|
Requires-Dist: streamlit>=1.42.0; extra == 'streamlit'
|
|
18
17
|
Description-Content-Type: text/markdown
|
|
19
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sweatstack"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.14.1"
|
|
4
4
|
description = "The official Python client for SweatStack"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -22,7 +22,6 @@ jupyterlab = [
|
|
|
22
22
|
]
|
|
23
23
|
streamlit = [
|
|
24
24
|
"streamlit>=1.42.0",
|
|
25
|
-
"streamlit-cookies-controller>=0.0.4",
|
|
26
25
|
]
|
|
27
26
|
|
|
28
27
|
[build-system]
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
import base64
|
|
3
1
|
import os
|
|
4
|
-
import secrets
|
|
5
2
|
import urllib.parse
|
|
6
3
|
|
|
7
4
|
try:
|
|
@@ -13,59 +10,42 @@ except ImportError:
|
|
|
13
10
|
"pip install 'sweatstack[streamlit]'\n\n"
|
|
14
11
|
)
|
|
15
12
|
import httpx
|
|
16
|
-
from streamlit_cookies_controller import CookieController
|
|
17
13
|
from sweatstack import Client
|
|
18
14
|
|
|
19
15
|
from .constants import DEFAULT_URL
|
|
20
16
|
|
|
21
17
|
|
|
22
|
-
cookie_controller = CookieController()
|
|
23
|
-
|
|
24
|
-
|
|
25
18
|
class StreamlitAuth:
|
|
26
|
-
def __init__(self,
|
|
19
|
+
def __init__(self, client_id=None, client_secret=None, scope=None, redirect_uri=None):
|
|
27
20
|
"""
|
|
28
21
|
Args:
|
|
29
|
-
set_env_var: Whether to set the SWEATSTACK_API_KEY environment variable. Default is False.
|
|
30
22
|
client_id: The client ID to use. If not provided, the SWEATSTACK_CLIENT_ID environment variable will be used.
|
|
31
23
|
client_secret: The client secret to use. If not provided, the SWEATSTACK_CLIENT_SECRET environment variable will be used.
|
|
32
24
|
scope: The scope to use. If not provided, the SWEATSTACK_SCOPE environment variable will be used.
|
|
33
25
|
redirect_uri: The redirect URI to use. If not provided, the SWEATSTACK_REDIRECT_URI environment variable will be used.
|
|
34
26
|
"""
|
|
35
|
-
self.set_env_var = set_env_var
|
|
36
27
|
self.client_id = client_id or os.environ.get("SWEATSTACK_CLIENT_ID")
|
|
37
28
|
self.client_secret = client_secret or os.environ.get("SWEATSTACK_CLIENT_SECRET")
|
|
38
29
|
self.scope = scope or os.environ.get("SWEATSTACK_SCOPE")
|
|
39
30
|
self.redirect_uri = redirect_uri or os.environ.get("SWEATSTACK_REDIRECT_URI")
|
|
40
31
|
|
|
41
|
-
self.api_key =
|
|
32
|
+
self.api_key = st.session_state.get("sweatstack_api_key")
|
|
42
33
|
self.client = Client(self.api_key)
|
|
43
34
|
|
|
44
|
-
if self.api_key and self.set_env_var:
|
|
45
|
-
os.environ["SWEATSTACK_API_KEY"] = self.api_key
|
|
46
|
-
|
|
47
35
|
def _show_sweatstack_logout(self):
|
|
48
36
|
if st.button("Logout"):
|
|
49
37
|
self.api_key = None
|
|
50
38
|
self.client = Client()
|
|
51
|
-
|
|
52
|
-
if self.set_env_var:
|
|
53
|
-
os.environ.pop("SWEATSTACK_API_KEY")
|
|
39
|
+
st.session_state.pop("sweatstack_api_key")
|
|
54
40
|
st.rerun()
|
|
55
41
|
|
|
56
42
|
def _show_sweatstack_login(self):
|
|
57
43
|
st.link_button("Login", self._get_authorization_url_implicit())
|
|
58
44
|
|
|
59
45
|
def _get_authorization_url_implicit(self):
|
|
60
|
-
code_verifier = secrets.token_urlsafe(32)
|
|
61
|
-
cookie_controller.set("code_verifier", code_verifier)
|
|
62
|
-
code_challenge = hashlib.sha256(code_verifier.encode("ascii")).digest()
|
|
63
|
-
code_challenge = base64.urlsafe_b64encode(code_challenge).rstrip(b"=").decode("ascii")
|
|
64
|
-
|
|
65
46
|
params = {
|
|
66
47
|
"client_id": self.client_id,
|
|
67
48
|
"redirect_uri": self.redirect_uri,
|
|
68
|
-
"code_challenge": code_challenge,
|
|
69
49
|
"scope": "data:read",
|
|
70
50
|
}
|
|
71
51
|
path = "/oauth/authorize"
|
|
@@ -73,17 +53,15 @@ class StreamlitAuth:
|
|
|
73
53
|
|
|
74
54
|
return authorization_url
|
|
75
55
|
|
|
76
|
-
|
|
77
|
-
def _exchange_token_implicit(self, code):
|
|
78
|
-
code_verifier = cookie_controller.get("code_verifier")
|
|
56
|
+
def _exchange_token(self, code):
|
|
79
57
|
token_data = {
|
|
80
58
|
"grant_type": "authorization_code",
|
|
81
59
|
"client_id": self.client_id,
|
|
60
|
+
"client_secret": self.client_secret,
|
|
82
61
|
"code": code,
|
|
83
|
-
"code_verifier": code_verifier
|
|
84
62
|
}
|
|
85
63
|
response = httpx.post(
|
|
86
|
-
f"{DEFAULT_URL}/oauth/token",
|
|
64
|
+
f"{DEFAULT_URL}/api/v1/oauth/token",
|
|
87
65
|
data=token_data,
|
|
88
66
|
)
|
|
89
67
|
try:
|
|
@@ -93,14 +71,10 @@ class StreamlitAuth:
|
|
|
93
71
|
token_response = response.json()
|
|
94
72
|
|
|
95
73
|
self.api_key = token_response.get("access_token")
|
|
96
|
-
|
|
97
|
-
if self.set_env_var:
|
|
98
|
-
os.environ["SWEATSTACK_API_KEY"] = self.api_key
|
|
74
|
+
st.session_state["sweatstack_api_key"] = self.api_key
|
|
99
75
|
|
|
100
76
|
self.client = Client(self.api_key)
|
|
101
77
|
|
|
102
|
-
cookie_controller.remove("code_verifier")
|
|
103
|
-
|
|
104
78
|
return
|
|
105
79
|
|
|
106
80
|
def is_authenticated(self):
|
|
@@ -110,7 +84,7 @@ class StreamlitAuth:
|
|
|
110
84
|
if self.is_authenticated():
|
|
111
85
|
self._show_sweatstack_logout()
|
|
112
86
|
elif code := st.query_params.get("code"):
|
|
113
|
-
self.
|
|
87
|
+
self._exchange_token(code)
|
|
114
88
|
st.query_params.clear()
|
|
115
89
|
st.rerun()
|
|
116
90
|
else:
|
|
@@ -1855,21 +1855,9 @@ wheels = [
|
|
|
1855
1855
|
{ url = "https://files.pythonhosted.org/packages/ad/dc/69068179e09488d0833a970d06e8bf40e35669a7bddb8a3caadc13b7dff4/streamlit-1.42.0-py2.py3-none-any.whl", hash = "sha256:edf333fd3525b7c64b19e1156b483a1a93cbdb09a3a06f26478388d68f971090", size = 9560180 },
|
|
1856
1856
|
]
|
|
1857
1857
|
|
|
1858
|
-
[[package]]
|
|
1859
|
-
name = "streamlit-cookies-controller"
|
|
1860
|
-
version = "0.0.4"
|
|
1861
|
-
source = { registry = "https://pypi.org/simple" }
|
|
1862
|
-
dependencies = [
|
|
1863
|
-
{ name = "streamlit" },
|
|
1864
|
-
]
|
|
1865
|
-
sdist = { url = "https://files.pythonhosted.org/packages/b0/c8/7caf505d62faeb8c0f6e6b74b554e1c2b0c3ca46c0a39250445c574a5a18/streamlit-cookies-controller-0.0.4.tar.gz", hash = "sha256:f5df2543de858f1585dcb6e90f58f38aafbf313ee8e237c64663b2d9761583cc", size = 406305 }
|
|
1866
|
-
wheels = [
|
|
1867
|
-
{ url = "https://files.pythonhosted.org/packages/02/c6/3bbdfecf5009943bcb62d37e3fd4b3fe45e87137e449a50e3025170bc9f7/streamlit_cookies_controller-0.0.4-py3-none-any.whl", hash = "sha256:f97fec6acdeee9cb9e16da25c3fc91d404b5b0ddced87c1d9fa9c62f65ca3251", size = 409303 },
|
|
1868
|
-
]
|
|
1869
|
-
|
|
1870
1858
|
[[package]]
|
|
1871
1859
|
name = "sweatstack"
|
|
1872
|
-
version = "0.
|
|
1860
|
+
version = "0.13.2"
|
|
1873
1861
|
source = { editable = "." }
|
|
1874
1862
|
dependencies = [
|
|
1875
1863
|
{ name = "httpx" },
|
|
@@ -1886,7 +1874,6 @@ jupyterlab = [
|
|
|
1886
1874
|
]
|
|
1887
1875
|
streamlit = [
|
|
1888
1876
|
{ name = "streamlit" },
|
|
1889
|
-
{ name = "streamlit-cookies-controller" },
|
|
1890
1877
|
]
|
|
1891
1878
|
|
|
1892
1879
|
[package.dev-dependencies]
|
|
@@ -1904,7 +1891,6 @@ requires-dist = [
|
|
|
1904
1891
|
{ name = "pyarrow", specifier = ">=19.0.0" },
|
|
1905
1892
|
{ name = "pydantic", specifier = ">=2.10.5" },
|
|
1906
1893
|
{ name = "streamlit", marker = "extra == 'streamlit'", specifier = ">=1.42.0" },
|
|
1907
|
-
{ name = "streamlit-cookies-controller", marker = "extra == 'streamlit'", specifier = ">=0.0.4" },
|
|
1908
1894
|
]
|
|
1909
1895
|
|
|
1910
1896
|
[package.metadata.requires-dev]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|