subspacecomputing 0.1.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Beausoft Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ # Fichiers à inclure dans la distribution PyPI
2
+
3
+ include README.md
4
+ include LICENSE
5
+ include pyproject.toml
6
+ recursive-include subspacecomputing *.py
7
+ recursive-exclude * __pycache__
8
+ recursive-exclude * *.py[co]
9
+ recursive-exclude * .git*
10
+
@@ -0,0 +1,258 @@
1
+ Metadata-Version: 2.4
2
+ Name: subspacecomputing
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Subspace Computing Engine API (by Beausoft)
5
+ Home-page: https://www.subspacecomputing.com/developer
6
+ Author: Beausoft
7
+ Author-email: Beausoft <contact@beausoft.ca>
8
+ Project-URL: Documentation, https://www.subspacecomputing.com/developer
9
+ Project-URL: Homepage, https://www.subspacecomputing.com/developer
10
+ Project-URL: Support, https://www.subspacecomputing.com/developer
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: requests>=2.31.0
15
+ Provides-Extra: pandas
16
+ Requires-Dist: pandas>=2.0.0; extra == "pandas"
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
19
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
20
+ Requires-Dist: black>=23.0.0; extra == "dev"
21
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
22
+ Requires-Dist: fastapi>=0.100.0; extra == "dev"
23
+ Dynamic: author
24
+ Dynamic: home-page
25
+ Dynamic: license-file
26
+ Dynamic: requires-python
27
+
28
+ # Subspace Computing Engine - Python SDK
29
+
30
+ Python SDK for the Subspace Computing Engine API (by Beausoft).
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install subspacecomputing
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Initialization
41
+
42
+ ```python
43
+ from subspacecomputing import BSCE
44
+
45
+ # Initialize the client (defaults to production URL)
46
+ bsce = BSCE(api_key='your-api-key-here')
47
+
48
+ # For local testing or custom environments (optional)
49
+ # bsce = BSCE(api_key='your-api-key-here', base_url='http://localhost:8000')
50
+ ```
51
+
52
+ ### Simple Projection (1 scenario)
53
+
54
+ ```python
55
+ # Create a simple SP Model
56
+ spec = {
57
+ 'scenarios': 1, # Must be 1 for /project
58
+ 'steps': 12,
59
+ 'variables': [
60
+ {
61
+ 'name': 'capital',
62
+ 'init': 1000.0,
63
+ 'formula': 'capital[t-1] * 1.05' # 5% growth per period
64
+ }
65
+ ]
66
+ }
67
+
68
+ # Run the projection
69
+ result = bsce.project(spec)
70
+
71
+ # Display results
72
+ print(f"Final capital: {result['final_values']['capital']}")
73
+ print(f"Trajectory: {result['trajectory']['capital']}")
74
+ ```
75
+
76
+ ### Monte Carlo Simulation (Multiple scenarios)
77
+
78
+ ```python
79
+ # SP Model with random variables
80
+ spec = {
81
+ 'scenarios': 1000, # 1000 Monte Carlo scenarios
82
+ 'steps': 12,
83
+ 'variables': [
84
+ {
85
+ 'name': 'taux',
86
+ 'dist': 'uniform',
87
+ 'params': {'min': 0.03, 'max': 0.07},
88
+ 'per': 'scenario'
89
+ },
90
+ {
91
+ 'name': 'capital',
92
+ 'init': 1000.0,
93
+ 'formula': 'capital[t-1] * (1 + taux)'
94
+ }
95
+ ]
96
+ }
97
+
98
+ # Run the simulation
99
+ result = bsce.simulate(spec)
100
+
101
+ # Analyze results
102
+ print(f"Mean final capital: {result['last_mean']['capital']}")
103
+ print(f"Median: {result['statistics']['capital']['median']}")
104
+ print(f"P5: {result['statistics']['capital']['percentiles']['5']}")
105
+ print(f"P95: {result['statistics']['capital']['percentiles']['95']}")
106
+ ```
107
+
108
+ ### Batch Mode (Multiple Entities)
109
+
110
+ ```python
111
+ # SP Model template
112
+ template = {
113
+ 'scenarios': 1,
114
+ 'steps': '65 - batch_params.age', # Dynamic steps
115
+ 'variables': [
116
+ {
117
+ 'name': 'age_actuel',
118
+ 'init': 'batch_params.age'
119
+ },
120
+ {
121
+ 'name': 'salaire',
122
+ 'init': 'batch_params.salary',
123
+ 'formula': 'salaire[t-1] * 1.03' # 3% annual increase
124
+ },
125
+ {
126
+ 'name': 'capital_retraite',
127
+ 'init': 0.0,
128
+ 'formula': 'capital_retraite[t-1] * 1.05 + salaire[t] * 0.10'
129
+ }
130
+ ]
131
+ }
132
+
133
+ # Entity data
134
+ batch_params = [
135
+ {'entity_id': 'emp_001', 'age': 45, 'salary': 60000},
136
+ {'entity_id': 'emp_002', 'age': 50, 'salary': 80000},
137
+ {'entity_id': 'emp_003', 'age': 35, 'salary': 50000}
138
+ ]
139
+
140
+ # Global aggregations (optional)
141
+ aggregations = [
142
+ {
143
+ 'name': 'capital_total',
144
+ 'formula': 'sum(capital_retraite[t_final])'
145
+ },
146
+ {
147
+ 'name': 'moyenne_capital',
148
+ 'formula': 'mean(capital_retraite[t_final])'
149
+ }
150
+ ]
151
+
152
+ # Run batch
153
+ result = bsce.project_batch(
154
+ template=template,
155
+ batch_params=batch_params,
156
+ aggregations=aggregations
157
+ )
158
+
159
+ # Analyze results
160
+ for entity in result['entities']:
161
+ print(f"{entity['_entity_id']}: Capital = {entity['final_values']['capital_retraite']}")
162
+
163
+ print(f"Total capital: {result['aggregations']['capital_total']}")
164
+ print(f"Average: {result['aggregations']['moyenne_capital']}")
165
+ ```
166
+
167
+ ### Validation
168
+
169
+ ```python
170
+ # Validate an SP Model before execution
171
+ validation = bsce.validate(spec)
172
+
173
+ if validation['is_valid']:
174
+ print("✅ SP Model is valid")
175
+ if validation.get('warnings'):
176
+ print(f"⚠️ Warnings: {validation['warnings']}")
177
+ else:
178
+ print(f"❌ Errors: {validation['errors']}")
179
+ ```
180
+
181
+ ### Utilities
182
+
183
+ ```python
184
+ # Get examples
185
+ examples = bsce.get_examples()
186
+ print(f"Available examples: {len(examples['examples'])}")
187
+
188
+ # Check usage
189
+ usage = bsce.get_usage()
190
+ print(f"Simulations used: {usage['usage']['simulations_used']}/{usage['usage']['simulations_limit']}")
191
+
192
+ # Get plans
193
+ plans = bsce.get_plans()
194
+ for plan in plans['plans']:
195
+ print(f"{plan['name']}: ${plan['price_monthly']}/month")
196
+ ```
197
+
198
+ ### Error Handling
199
+
200
+ ```python
201
+ from subspacecomputing import (
202
+ BSCE,
203
+ QuotaExceededError,
204
+ RateLimitError,
205
+ AuthenticationError,
206
+ ValidationError,
207
+ BSCEError
208
+ )
209
+
210
+ try:
211
+ result = bsce.simulate(spec)
212
+ except QuotaExceededError as e:
213
+ print(f"Monthly quota exceeded: {e}")
214
+ except RateLimitError as e:
215
+ print(f"Rate limit exceeded: {e}")
216
+ print(f"Retry after: {e.response.headers.get('Retry-After')} seconds")
217
+ except AuthenticationError as e:
218
+ print(f"Invalid API key: {e}")
219
+ except ValidationError as e:
220
+ print(f"Validation error: {e.detail}")
221
+ except BSCEError as e:
222
+ print(f"API error: {e}")
223
+ ```
224
+
225
+ ### Rate Limit and Quota Information
226
+
227
+ After making a request, you can check your rate limit and quota status:
228
+
229
+ ```python
230
+ # Make a request
231
+ result = bsce.project(spec)
232
+
233
+ # Check rate limit info
234
+ rate_limit = bsce.get_rate_limit_info()
235
+ if rate_limit:
236
+ print(f"Rate limit: {rate_limit['remaining']}/{rate_limit['limit']} remaining")
237
+
238
+ # Check quota info
239
+ quota = bsce.get_quota_info()
240
+ if quota:
241
+ print(f"Quota: {quota['used']}/{quota['limit']} used, {quota['remaining']} remaining")
242
+ ```
243
+
244
+ ## Documentation
245
+
246
+ Check out the full documentation at https://www.subspacecomputing.com/developer
247
+
248
+ API reference is available at https://api.subspacecomputing.com/docs
249
+
250
+ For support, reach out to contact@beausoft.ca
251
+
252
+ ## License
253
+
254
+ MIT License. Check the LICENSE file for details.
255
+
256
+ ## Copyright
257
+
258
+ © 2025 Beausoft Inc. All Rights Reserved
@@ -0,0 +1,231 @@
1
+ # Subspace Computing Engine - Python SDK
2
+
3
+ Python SDK for the Subspace Computing Engine API (by Beausoft).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install subspacecomputing
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialization
14
+
15
+ ```python
16
+ from subspacecomputing import BSCE
17
+
18
+ # Initialize the client (defaults to production URL)
19
+ bsce = BSCE(api_key='your-api-key-here')
20
+
21
+ # For local testing or custom environments (optional)
22
+ # bsce = BSCE(api_key='your-api-key-here', base_url='http://localhost:8000')
23
+ ```
24
+
25
+ ### Simple Projection (1 scenario)
26
+
27
+ ```python
28
+ # Create a simple SP Model
29
+ spec = {
30
+ 'scenarios': 1, # Must be 1 for /project
31
+ 'steps': 12,
32
+ 'variables': [
33
+ {
34
+ 'name': 'capital',
35
+ 'init': 1000.0,
36
+ 'formula': 'capital[t-1] * 1.05' # 5% growth per period
37
+ }
38
+ ]
39
+ }
40
+
41
+ # Run the projection
42
+ result = bsce.project(spec)
43
+
44
+ # Display results
45
+ print(f"Final capital: {result['final_values']['capital']}")
46
+ print(f"Trajectory: {result['trajectory']['capital']}")
47
+ ```
48
+
49
+ ### Monte Carlo Simulation (Multiple scenarios)
50
+
51
+ ```python
52
+ # SP Model with random variables
53
+ spec = {
54
+ 'scenarios': 1000, # 1000 Monte Carlo scenarios
55
+ 'steps': 12,
56
+ 'variables': [
57
+ {
58
+ 'name': 'taux',
59
+ 'dist': 'uniform',
60
+ 'params': {'min': 0.03, 'max': 0.07},
61
+ 'per': 'scenario'
62
+ },
63
+ {
64
+ 'name': 'capital',
65
+ 'init': 1000.0,
66
+ 'formula': 'capital[t-1] * (1 + taux)'
67
+ }
68
+ ]
69
+ }
70
+
71
+ # Run the simulation
72
+ result = bsce.simulate(spec)
73
+
74
+ # Analyze results
75
+ print(f"Mean final capital: {result['last_mean']['capital']}")
76
+ print(f"Median: {result['statistics']['capital']['median']}")
77
+ print(f"P5: {result['statistics']['capital']['percentiles']['5']}")
78
+ print(f"P95: {result['statistics']['capital']['percentiles']['95']}")
79
+ ```
80
+
81
+ ### Batch Mode (Multiple Entities)
82
+
83
+ ```python
84
+ # SP Model template
85
+ template = {
86
+ 'scenarios': 1,
87
+ 'steps': '65 - batch_params.age', # Dynamic steps
88
+ 'variables': [
89
+ {
90
+ 'name': 'age_actuel',
91
+ 'init': 'batch_params.age'
92
+ },
93
+ {
94
+ 'name': 'salaire',
95
+ 'init': 'batch_params.salary',
96
+ 'formula': 'salaire[t-1] * 1.03' # 3% annual increase
97
+ },
98
+ {
99
+ 'name': 'capital_retraite',
100
+ 'init': 0.0,
101
+ 'formula': 'capital_retraite[t-1] * 1.05 + salaire[t] * 0.10'
102
+ }
103
+ ]
104
+ }
105
+
106
+ # Entity data
107
+ batch_params = [
108
+ {'entity_id': 'emp_001', 'age': 45, 'salary': 60000},
109
+ {'entity_id': 'emp_002', 'age': 50, 'salary': 80000},
110
+ {'entity_id': 'emp_003', 'age': 35, 'salary': 50000}
111
+ ]
112
+
113
+ # Global aggregations (optional)
114
+ aggregations = [
115
+ {
116
+ 'name': 'capital_total',
117
+ 'formula': 'sum(capital_retraite[t_final])'
118
+ },
119
+ {
120
+ 'name': 'moyenne_capital',
121
+ 'formula': 'mean(capital_retraite[t_final])'
122
+ }
123
+ ]
124
+
125
+ # Run batch
126
+ result = bsce.project_batch(
127
+ template=template,
128
+ batch_params=batch_params,
129
+ aggregations=aggregations
130
+ )
131
+
132
+ # Analyze results
133
+ for entity in result['entities']:
134
+ print(f"{entity['_entity_id']}: Capital = {entity['final_values']['capital_retraite']}")
135
+
136
+ print(f"Total capital: {result['aggregations']['capital_total']}")
137
+ print(f"Average: {result['aggregations']['moyenne_capital']}")
138
+ ```
139
+
140
+ ### Validation
141
+
142
+ ```python
143
+ # Validate an SP Model before execution
144
+ validation = bsce.validate(spec)
145
+
146
+ if validation['is_valid']:
147
+ print("✅ SP Model is valid")
148
+ if validation.get('warnings'):
149
+ print(f"⚠️ Warnings: {validation['warnings']}")
150
+ else:
151
+ print(f"❌ Errors: {validation['errors']}")
152
+ ```
153
+
154
+ ### Utilities
155
+
156
+ ```python
157
+ # Get examples
158
+ examples = bsce.get_examples()
159
+ print(f"Available examples: {len(examples['examples'])}")
160
+
161
+ # Check usage
162
+ usage = bsce.get_usage()
163
+ print(f"Simulations used: {usage['usage']['simulations_used']}/{usage['usage']['simulations_limit']}")
164
+
165
+ # Get plans
166
+ plans = bsce.get_plans()
167
+ for plan in plans['plans']:
168
+ print(f"{plan['name']}: ${plan['price_monthly']}/month")
169
+ ```
170
+
171
+ ### Error Handling
172
+
173
+ ```python
174
+ from subspacecomputing import (
175
+ BSCE,
176
+ QuotaExceededError,
177
+ RateLimitError,
178
+ AuthenticationError,
179
+ ValidationError,
180
+ BSCEError
181
+ )
182
+
183
+ try:
184
+ result = bsce.simulate(spec)
185
+ except QuotaExceededError as e:
186
+ print(f"Monthly quota exceeded: {e}")
187
+ except RateLimitError as e:
188
+ print(f"Rate limit exceeded: {e}")
189
+ print(f"Retry after: {e.response.headers.get('Retry-After')} seconds")
190
+ except AuthenticationError as e:
191
+ print(f"Invalid API key: {e}")
192
+ except ValidationError as e:
193
+ print(f"Validation error: {e.detail}")
194
+ except BSCEError as e:
195
+ print(f"API error: {e}")
196
+ ```
197
+
198
+ ### Rate Limit and Quota Information
199
+
200
+ After making a request, you can check your rate limit and quota status:
201
+
202
+ ```python
203
+ # Make a request
204
+ result = bsce.project(spec)
205
+
206
+ # Check rate limit info
207
+ rate_limit = bsce.get_rate_limit_info()
208
+ if rate_limit:
209
+ print(f"Rate limit: {rate_limit['remaining']}/{rate_limit['limit']} remaining")
210
+
211
+ # Check quota info
212
+ quota = bsce.get_quota_info()
213
+ if quota:
214
+ print(f"Quota: {quota['used']}/{quota['limit']} used, {quota['remaining']} remaining")
215
+ ```
216
+
217
+ ## Documentation
218
+
219
+ Check out the full documentation at https://www.subspacecomputing.com/developer
220
+
221
+ API reference is available at https://api.subspacecomputing.com/docs
222
+
223
+ For support, reach out to contact@beausoft.ca
224
+
225
+ ## License
226
+
227
+ MIT License. Check the LICENSE file for details.
228
+
229
+ ## Copyright
230
+
231
+ © 2025 Beausoft Inc. All Rights Reserved
@@ -0,0 +1,44 @@
1
+ # pyproject.toml pour le SDK Python (configuration moderne)
2
+
3
+ [build-system]
4
+ requires = ["setuptools>=61.0", "wheel"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [project]
8
+ name = "subspacecomputing"
9
+ version = "0.1.0"
10
+ description = "Python SDK for Subspace Computing Engine API (by Beausoft)"
11
+ authors = [{name = "Beausoft", email = "contact@beausoft.ca"}]
12
+ readme = "README.md"
13
+ requires-python = ">=3.10"
14
+ dependencies = [
15
+ "requests>=2.31.0",
16
+ ]
17
+
18
+ [project.optional-dependencies]
19
+ pandas = ["pandas>=2.0.0"]
20
+ dev = [
21
+ "pytest>=7.0.0",
22
+ "pytest-cov>=4.0.0",
23
+ "black>=23.0.0",
24
+ "ruff>=0.1.0",
25
+ "fastapi>=0.100.0", # Pour tests d'intégration
26
+ ]
27
+
28
+ [project.urls]
29
+ Documentation = "https://www.subspacecomputing.com/developer"
30
+ Homepage = "https://www.subspacecomputing.com/developer"
31
+ Support = "https://www.subspacecomputing.com/developer"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["."]
35
+ include = ["subspacecomputing*"]
36
+
37
+ [tool.black]
38
+ line-length = 100
39
+ target-version = ['py310']
40
+
41
+ [tool.ruff]
42
+ line-length = 100
43
+ target-version = "py310"
44
+
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ """
2
+ Setup.py pour le SDK Python Beausoft Subspace Computing Engine.
3
+ """
4
+
5
+ from setuptools import setup, find_packages
6
+
7
+ # Lire le README pour la description longue
8
+ try:
9
+ with open("README.md", "r", encoding="utf-8") as fh:
10
+ long_description = fh.read()
11
+ except FileNotFoundError:
12
+ long_description = "Python SDK for Subspace Computing Engine API (by Beausoft)"
13
+
14
+ setup(
15
+ name="subspacecomputing",
16
+ version="0.1.0",
17
+ description="Python SDK for Subspace Computing Engine API (by Beausoft)",
18
+ long_description=long_description,
19
+ long_description_content_type="text/markdown",
20
+ author="Beausoft",
21
+ author_email="contact@beausoft.ca",
22
+ url="https://www.subspacecomputing.com/developer",
23
+ packages=find_packages(),
24
+ install_requires=[
25
+ "requests>=2.31.0",
26
+ ],
27
+ python_requires=">=3.10",
28
+ classifiers=[
29
+ "Development Status :: 3 - Alpha",
30
+ "Intended Audience :: Developers",
31
+ "Topic :: Software Development :: Libraries :: Python Modules",
32
+ "License :: OSI Approved :: MIT License",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.10",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ ],
38
+ keywords="actuarial, finance, simulation, monte-carlo, projection, subspace",
39
+ project_urls={
40
+ "Documentation": "https://www.subspacecomputing.com/developer",
41
+ "Homepage": "https://www.subspacecomputing.com/developer",
42
+ "Support": "https://www.subspacecomputing.com/developer",
43
+ },
44
+ )
45
+
@@ -0,0 +1,24 @@
1
+ """
2
+ Subspace Computing Engine - Python SDK
3
+
4
+ Python SDK for the Subspace Computing Engine API (by Beausoft).
5
+ """
6
+
7
+ from .client import BSCE
8
+ from .errors import (
9
+ BSCEError,
10
+ QuotaExceededError,
11
+ RateLimitError,
12
+ AuthenticationError,
13
+ ValidationError,
14
+ )
15
+
16
+ __version__ = "0.1.0"
17
+ __all__ = [
18
+ "BSCE",
19
+ "BSCEError",
20
+ "QuotaExceededError",
21
+ "RateLimitError",
22
+ "AuthenticationError",
23
+ "ValidationError",
24
+ ]