sweatstack 0.11.1__tar.gz → 0.13.0__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.
Files changed (30) hide show
  1. sweatstack-0.13.0/.gitignore +10 -0
  2. sweatstack-0.13.0/.python-version +1 -0
  3. sweatstack-0.13.0/DEVELOPMENT.md +13 -0
  4. sweatstack-0.13.0/PKG-INFO +117 -0
  5. sweatstack-0.13.0/README.md +98 -0
  6. sweatstack-0.13.0/pyproject.toml +40 -0
  7. {sweatstack-0.11.1 → sweatstack-0.13.0/src}/sweatstack/cli.py +2 -2
  8. sweatstack-0.13.0/src/sweatstack/client.py +597 -0
  9. sweatstack-0.13.0/src/sweatstack/constants.py +1 -0
  10. {sweatstack-0.11.1 → sweatstack-0.13.0/src}/sweatstack/jupyterlab_oauth2_startup.py +5 -0
  11. sweatstack-0.13.0/src/sweatstack/openapi_schemas.py +368 -0
  12. sweatstack-0.13.0/src/sweatstack/py.typed +0 -0
  13. sweatstack-0.13.0/src/sweatstack/schemas.py +3 -0
  14. sweatstack-0.13.0/src/sweatstack/streamlit.py +116 -0
  15. sweatstack-0.13.0/src/sweatstack/utils.py +13 -0
  16. sweatstack-0.13.0/uv.lock +2081 -0
  17. sweatstack-0.11.1/.gitignore +0 -13
  18. sweatstack-0.11.1/PKG-INFO +0 -359
  19. sweatstack-0.11.1/README.md +0 -333
  20. sweatstack-0.11.1/pyproject.toml +0 -44
  21. sweatstack-0.11.1/script.py +0 -25
  22. sweatstack-0.11.1/sweatstack/Sweat Stack examples/Getting started.ipynb +0 -28784
  23. sweatstack-0.11.1/sweatstack/client.py +0 -577
  24. sweatstack-0.11.1/sweatstack/plotting.py +0 -251
  25. sweatstack-0.11.1/sweatstack/schemas.py +0 -229
  26. sweatstack-0.11.1/test2.py +0 -96
  27. {sweatstack-0.11.1 → sweatstack-0.13.0}/Makefile +0 -0
  28. {sweatstack-0.11.1 → sweatstack-0.13.0/src}/sweatstack/__init__.py +0 -0
  29. {sweatstack-0.11.1 → sweatstack-0.13.0/src}/sweatstack/ipython_init.py +0 -0
  30. {sweatstack-0.11.1 → sweatstack-0.13.0/src}/sweatstack/sweatshell.py +0 -0
@@ -0,0 +1,10 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,13 @@
1
+ # Development
2
+
3
+
4
+
5
+ ## Running locally
6
+
7
+ Point your terminal to some other directory (to not clutter this one with `Untitled` files) and then run:
8
+
9
+ ```bash
10
+ uvx --with-editable "path/to/sweatstack-python[jupyterlab]" jupyter lab
11
+ ```
12
+
13
+ This will start a JupyterLab instance.
@@ -0,0 +1,117 @@
1
+ Metadata-Version: 2.4
2
+ Name: sweatstack
3
+ Version: 0.13.0
4
+ Summary: The official Python client for SweatStack
5
+ Author-email: Aart Goossens <aart@gssns.io>
6
+ Requires-Python: >=3.12
7
+ Requires-Dist: httpx>=0.28.1
8
+ Requires-Dist: pandas>=2.2.3
9
+ Requires-Dist: pyarrow>=19.0.0
10
+ Requires-Dist: pydantic>=2.10.5
11
+ Provides-Extra: jupyterlab
12
+ Requires-Dist: ipython>=8.31.0; extra == 'jupyterlab'
13
+ Requires-Dist: jupyterlab>=4.3.4; extra == 'jupyterlab'
14
+ Requires-Dist: matplotlib; extra == 'jupyterlab'
15
+ Provides-Extra: streamlit
16
+ Requires-Dist: streamlit-cookies-controller>=0.0.4; extra == 'streamlit'
17
+ Requires-Dist: streamlit>=1.42.0; extra == 'streamlit'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # SweatStack Python client library
21
+
22
+
23
+ # Quickstart
24
+
25
+ ```
26
+ uv pip install sweatstack
27
+ ```
28
+
29
+ ```python
30
+ import sweatstack as ss
31
+
32
+ ss.login()
33
+
34
+ ss.list_activities()
35
+ ```
36
+
37
+
38
+ # Authentication
39
+
40
+ SweatStack supports three authentication methods:
41
+
42
+ ### 1. Browser-Based OAuth2 Authentication
43
+ ```python
44
+ ss.login() # Opens your default browser for authentication
45
+ ```
46
+
47
+ ### 2. Direct API Key Authentication
48
+ ```python
49
+ client = ss.Client(api_key="your-api-key")
50
+ ```
51
+
52
+ ### 3. Environment Variable
53
+ Set the `SWEATSTACK_API_KEY` environment variable:
54
+ ```bash
55
+ export SWEATSTACK_API_KEY="your-api-key"
56
+ ```
57
+
58
+ SweatStack follows this priority order:
59
+
60
+ 1. Browser-based OAuth2 (`ss.login()`)
61
+ 2. Direct API key via `Client` constructor
62
+ 3. `SWEATSTACK_API_KEY` environment variable
63
+
64
+ For example, calling `ss.login()` or `client.login()` will override any existing API key authentication, including those set through the constructor or environment variables.
65
+
66
+
67
+ ## Interfaces: Singleton vs Class-based
68
+
69
+ This library provides both a singleton interface and a class-based interface.
70
+
71
+ Singleton interface:
72
+ ```python
73
+ import sweatstack as ss
74
+
75
+ activities = ss.list_activities()
76
+ ```
77
+
78
+ Class-based interface:
79
+ ```python
80
+ from sweatstack import Client
81
+
82
+ client = Client()
83
+ activities = client.list_activities()
84
+ ```
85
+
86
+ Although both interfaces are feature-equivalent, they serve different purposes:
87
+ - The singleton interface is the default and recommended interface. It is intended for most use cases and is the easiest to use.
88
+ - The class-based interface is intended for more advanced use cases, such as when you need to authenticate multiple users at the same time or in multi-threaded applications.
89
+
90
+
91
+ ## Streamlit integration
92
+
93
+ The `sweatstack.streamlit` module provides a Streamlit integration for SweatStack. This requires the optional `streamlit` dependency that can be installed with:
94
+ ```
95
+ uv pip install 'sweatstack[streamlit]'
96
+ ```
97
+
98
+ The `StreamlitAuth` class is a Streamlit component that handles the OAuth2 authentication flow. It provides a `st.authenticate()` function that can be used to authenticate the user.
99
+
100
+ Example usage:
101
+
102
+ ```python
103
+ from sweatstack.streamlit import StreamlitAuth
104
+
105
+ auth = StreamlitAuth()
106
+
107
+ with st.sidebar:
108
+ st.authenticate()
109
+
110
+ if not auth.is_authenticated():
111
+ st.write("User is not authenticated")
112
+ st.stop()
113
+
114
+ st.write("User is authenticated")
115
+
116
+ auth.client.get_latest_activity()
117
+ ```
@@ -0,0 +1,98 @@
1
+ # SweatStack Python client library
2
+
3
+
4
+ # Quickstart
5
+
6
+ ```
7
+ uv pip install sweatstack
8
+ ```
9
+
10
+ ```python
11
+ import sweatstack as ss
12
+
13
+ ss.login()
14
+
15
+ ss.list_activities()
16
+ ```
17
+
18
+
19
+ # Authentication
20
+
21
+ SweatStack supports three authentication methods:
22
+
23
+ ### 1. Browser-Based OAuth2 Authentication
24
+ ```python
25
+ ss.login() # Opens your default browser for authentication
26
+ ```
27
+
28
+ ### 2. Direct API Key Authentication
29
+ ```python
30
+ client = ss.Client(api_key="your-api-key")
31
+ ```
32
+
33
+ ### 3. Environment Variable
34
+ Set the `SWEATSTACK_API_KEY` environment variable:
35
+ ```bash
36
+ export SWEATSTACK_API_KEY="your-api-key"
37
+ ```
38
+
39
+ SweatStack follows this priority order:
40
+
41
+ 1. Browser-based OAuth2 (`ss.login()`)
42
+ 2. Direct API key via `Client` constructor
43
+ 3. `SWEATSTACK_API_KEY` environment variable
44
+
45
+ For example, calling `ss.login()` or `client.login()` will override any existing API key authentication, including those set through the constructor or environment variables.
46
+
47
+
48
+ ## Interfaces: Singleton vs Class-based
49
+
50
+ This library provides both a singleton interface and a class-based interface.
51
+
52
+ Singleton interface:
53
+ ```python
54
+ import sweatstack as ss
55
+
56
+ activities = ss.list_activities()
57
+ ```
58
+
59
+ Class-based interface:
60
+ ```python
61
+ from sweatstack import Client
62
+
63
+ client = Client()
64
+ activities = client.list_activities()
65
+ ```
66
+
67
+ Although both interfaces are feature-equivalent, they serve different purposes:
68
+ - The singleton interface is the default and recommended interface. It is intended for most use cases and is the easiest to use.
69
+ - The class-based interface is intended for more advanced use cases, such as when you need to authenticate multiple users at the same time or in multi-threaded applications.
70
+
71
+
72
+ ## Streamlit integration
73
+
74
+ The `sweatstack.streamlit` module provides a Streamlit integration for SweatStack. This requires the optional `streamlit` dependency that can be installed with:
75
+ ```
76
+ uv pip install 'sweatstack[streamlit]'
77
+ ```
78
+
79
+ The `StreamlitAuth` class is a Streamlit component that handles the OAuth2 authentication flow. It provides a `st.authenticate()` function that can be used to authenticate the user.
80
+
81
+ Example usage:
82
+
83
+ ```python
84
+ from sweatstack.streamlit import StreamlitAuth
85
+
86
+ auth = StreamlitAuth()
87
+
88
+ with st.sidebar:
89
+ st.authenticate()
90
+
91
+ if not auth.is_authenticated():
92
+ st.write("User is not authenticated")
93
+ st.stop()
94
+
95
+ st.write("User is authenticated")
96
+
97
+ auth.client.get_latest_activity()
98
+ ```
@@ -0,0 +1,40 @@
1
+ [project]
2
+ name = "sweatstack"
3
+ version = "0.13.0"
4
+ description = "The official Python client for SweatStack"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Aart Goossens", email = "aart@gssns.io" }
8
+ ]
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "httpx>=0.28.1",
12
+ "pandas>=2.2.3",
13
+ "pyarrow>=19.0.0",
14
+ "pydantic>=2.10.5",
15
+ ]
16
+
17
+ [project.optional-dependencies]
18
+ jupyterlab = [
19
+ "ipython>=8.31.0",
20
+ "jupyterlab>=4.3.4",
21
+ "matplotlib",
22
+ ]
23
+ streamlit = [
24
+ "streamlit>=1.42.0",
25
+ "streamlit-cookies-controller>=0.0.4",
26
+ ]
27
+
28
+ [build-system]
29
+ requires = ["hatchling"]
30
+ build-backend = "hatchling.build"
31
+
32
+ [dependency-groups]
33
+ dev = [
34
+ "datamodel-code-generator>=0.26.5",
35
+ ]
36
+
37
+ [project.scripts]
38
+ generate-response-models = "sweatstack.cli:generate_response_models"
39
+ sweatshell = "sweatstack.sweatshell:run_ipython"
40
+ sweatlab = "sweatstack.jupyterlab_oauth2_startup:start_jupyterlab_with_oauth"
@@ -6,10 +6,10 @@ from datamodel_code_generator import DataModelType
6
6
 
7
7
 
8
8
  def generate_response_models():
9
- response = httpx.get("http://localhost:2400/openapi.json")
9
+ response = httpx.get("http://localhost:8080/openapi.json")
10
10
  response.raise_for_status()
11
11
  output_directory = Path(__file__).parent
12
- output = Path(output_directory / "schemas.py")
12
+ output = Path(output_directory / "openapi_schemas.py")
13
13
  output.unlink(missing_ok=True)
14
14
  generate(
15
15
  response.text,