krama-forecast 1.0.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.
- krama_forecast-1.0.0/LICENSE +95 -0
- krama_forecast-1.0.0/PKG-INFO +144 -0
- krama_forecast-1.0.0/README.md +107 -0
- krama_forecast-1.0.0/krama/__init__.py +21 -0
- krama_forecast-1.0.0/krama/cli.py +89 -0
- krama_forecast-1.0.0/krama/client.py +314 -0
- krama_forecast-1.0.0/krama/py.typed +0 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/PKG-INFO +144 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/SOURCES.txt +14 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/dependency_links.txt +1 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/entry_points.txt +2 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/requires.txt +9 -0
- krama_forecast-1.0.0/krama_forecast.egg-info/top_level.txt +1 -0
- krama_forecast-1.0.0/pyproject.toml +76 -0
- krama_forecast-1.0.0/setup.cfg +4 -0
- krama_forecast-1.0.0/tests/test_client.py +307 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity.
|
|
19
|
+
|
|
20
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
21
|
+
exercising permissions granted by this License.
|
|
22
|
+
|
|
23
|
+
"Source" form shall mean the preferred form for making modifications.
|
|
24
|
+
|
|
25
|
+
"Object" form shall mean any form resulting from mechanical
|
|
26
|
+
transformation or translation of a Source form.
|
|
27
|
+
|
|
28
|
+
"Work" shall mean the work of authorship made available under the License.
|
|
29
|
+
|
|
30
|
+
"Derivative Works" shall mean any work that is based on the Work.
|
|
31
|
+
|
|
32
|
+
"Contribution" shall mean any work of authorship submitted to the
|
|
33
|
+
Licensor for inclusion in the Work.
|
|
34
|
+
|
|
35
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
36
|
+
whom a Contribution has been received by the Licensor.
|
|
37
|
+
|
|
38
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
39
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
40
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
41
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
42
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
43
|
+
Work and such Derivative Works in Source or Object form.
|
|
44
|
+
|
|
45
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
46
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
47
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
48
|
+
patent license to make, have made, use, offer to sell, sell,
|
|
49
|
+
import, and otherwise transfer the Work.
|
|
50
|
+
|
|
51
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
52
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
53
|
+
modifications, and in Source or Object form, provided that You
|
|
54
|
+
meet the following conditions:
|
|
55
|
+
|
|
56
|
+
(a) You must give any other recipients of the Work or
|
|
57
|
+
Derivative Works a copy of this License; and
|
|
58
|
+
|
|
59
|
+
(b) You must cause any modified files to carry prominent notices
|
|
60
|
+
stating that You changed the files; and
|
|
61
|
+
|
|
62
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
63
|
+
that You distribute, all copyright, patent, trademark, and
|
|
64
|
+
attribution notices from the Source form of the Work; and
|
|
65
|
+
|
|
66
|
+
(d) If the Work includes a "NOTICE" text file, You must include
|
|
67
|
+
a readable copy of the attribution notices contained within
|
|
68
|
+
such NOTICE file.
|
|
69
|
+
|
|
70
|
+
5. Submission of Contributions.
|
|
71
|
+
|
|
72
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
73
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
74
|
+
|
|
75
|
+
7. Disclaimer of Warranty. The Work is provided on an "AS IS" BASIS,
|
|
76
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
|
|
77
|
+
|
|
78
|
+
8. Limitation of Liability. In no event shall any Contributor be
|
|
79
|
+
liable for any damages.
|
|
80
|
+
|
|
81
|
+
9. Accepting Warranty or Additional Liability.
|
|
82
|
+
|
|
83
|
+
Copyright 2026 Anagatam Technologies
|
|
84
|
+
|
|
85
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
86
|
+
you may not use this file except in compliance with the License.
|
|
87
|
+
You may obtain a copy of the License at
|
|
88
|
+
|
|
89
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
90
|
+
|
|
91
|
+
Unless required by applicable law or agreed to in writing, software
|
|
92
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
93
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
94
|
+
See the License for the specific language governing permissions and
|
|
95
|
+
limitations under the License.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: krama-forecast
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK & CLI for the Krama Forecasting SaaS API (https://krama.anagatam.workers.dev) — by Anagatam Technologies
|
|
5
|
+
Author: Anagatam Technologies
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Anagatam/Krama
|
|
8
|
+
Project-URL: Documentation, https://krama-forecast.readthedocs.io/en/latest/
|
|
9
|
+
Project-URL: Repository, https://github.com/Anagatam/Krama
|
|
10
|
+
Project-URL: Issues, https://github.com/Anagatam/Krama/issues
|
|
11
|
+
Project-URL: PyPI, https://pypi.org/project/krama-forecast/
|
|
12
|
+
Project-URL: Changelog, https://github.com/Anagatam/Krama/blob/main/CHANGELOG.md
|
|
13
|
+
Keywords: time-series,forecasting,prophet,trend-decomposition,seasonality,changepoint-detection,bayesian-inference,fourier-decomposition,cross-validation,quantitative-finance,institutional-grade,audit-trail
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: pandas>=2.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
33
|
+
Requires-Dist: httpx>=0.27; extra == "dev"
|
|
34
|
+
Provides-Extra: saas
|
|
35
|
+
Requires-Dist: httpx>=0.27; extra == "saas"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
<h1 align="center">Krama</h1>
|
|
39
|
+
<p align="center">
|
|
40
|
+
<strong>Institutional Time-Series Forecasting SaaS Platform, Python SDK & CLI</strong><br>
|
|
41
|
+
<em>Regularized structural decomposition, 8 forecasting engines, split-conformal intervals, and SHA-256 audit trails.</em>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
<p align="center">
|
|
45
|
+
<a href="https://krama.anagatam.workers.dev"><strong>Cloud Portal</strong></a> ·
|
|
46
|
+
<a href="https://krama-forecast.readthedocs.io/en/latest/"><strong>Documentation</strong></a> ·
|
|
47
|
+
<a href="https://krama.anagatam.workers.dev/docs"><strong>Swagger / OpenAPI</strong></a> ·
|
|
48
|
+
<a href="https://pypi.org/project/krama-forecast/"><strong>PyPI</strong></a> ·
|
|
49
|
+
<a href="https://github.com/Anagatam/Krama/blob/main/DISCLAIMER.md"><strong>Disclaimer</strong></a>
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<p align="center">
|
|
53
|
+
<a href="https://github.com/Anagatam/Krama/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"></a>
|
|
54
|
+
<a href="https://github.com/Anagatam/Krama/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Anagatam/Krama/ci.yml?branch=main&label=CI" alt="CI Status"></a>
|
|
55
|
+
<a href="https://codecov.io/gh/Anagatam/Krama"><img src="https://codecov.io/gh/Anagatam/Krama/graph/badge.svg" alt="Codecov"></a>
|
|
56
|
+
<a href="https://krama-forecast.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/krama-forecast/badge/?version=latest" alt="ReadTheDocs"></a>
|
|
57
|
+
<a href="https://pypi.org/project/krama-forecast/"><img src="https://img.shields.io/pypi/v/krama-forecast?color=orange&label=pypi" alt="PyPI"></a>
|
|
58
|
+
<a href="https://pypi.org/project/krama-forecast/"><img src="https://img.shields.io/pypi/pyversions/krama-forecast" alt="Python"></a>
|
|
59
|
+
<a href="https://peps.python.org/pep-0561/"><img src="https://img.shields.io/badge/types-PEP%20561-blue.svg" alt="PEP 561 Typed"></a>
|
|
60
|
+
</p>
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
**Krama** provides a hosted multi-tenant forecasting engine on Cloudflare Workers + D1 alongside a zero-dependency-overhead Python client SDK (`KramaClient`), CLI (`krama`), and interactive Developer API Portal.
|
|
65
|
+
|
|
66
|
+
## Quick Start
|
|
67
|
+
|
|
68
|
+
### 1. Install the Python SDK & CLI
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install krama-forecast
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2. Forecast with Python
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import pandas as pd
|
|
78
|
+
from krama import KramaClient
|
|
79
|
+
|
|
80
|
+
df = pd.DataFrame({
|
|
81
|
+
"ds": ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-04"],
|
|
82
|
+
"y": [102.4, 108.1, 115.6, 119.2],
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
with KramaClient(api_key="krm_live_your_key") as client:
|
|
86
|
+
res = client.forecast(df, periods=14, model_type="krama", robust=True, interval_width=0.90)
|
|
87
|
+
print(pd.DataFrame(res["forecast"]).head())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 3. Forecast from the CLI
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
export KRAMA_API_KEY="krm_live_your_key"
|
|
94
|
+
krama forecast sales.csv --periods 14 --model-type krama --robust --output forecast.csv
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Core Capabilities
|
|
100
|
+
|
|
101
|
+
| Capability | Endpoint | SDK Method |
|
|
102
|
+
| :--- | :--- | :--- |
|
|
103
|
+
| **Single-Series Conformal Forecast** | `POST /v1/forecast` | `client.forecast(...)` |
|
|
104
|
+
| **Multi-Series Batch Forecast** | `POST /v1/global/forecast` | `client.global_forecast(...)` |
|
|
105
|
+
| **MinT Hierarchical Reconciliation** | `POST /v1/hierarchical/forecast` | `client.hierarchical_forecast(...)` |
|
|
106
|
+
| **MAD Residual Anomaly Scan** | `POST /v1/detect/anomalies` | `client.detect_anomalies(...)` |
|
|
107
|
+
| **PELT / BinSeg Structural Breaks** | `POST /v1/detect/changepoints` | `client.detect_changepoints(...)` |
|
|
108
|
+
| **Rolling & Expanding Cross-Validation** | `POST /v1/backtest` | `client.backtest(...)` |
|
|
109
|
+
| **Datasets & Saved Models** | `POST /v1/datasets`, `POST /v1/models/train` | `client.upload_dataset(...)`, `client.train_model(...)` |
|
|
110
|
+
| **Scoped API Keys & Rotation** | `POST /v1/api-keys`, `/rotate` | `client.create_api_key(...)`, `client.rotate_api_key(...)` |
|
|
111
|
+
| **Usage, Per-Key Stats & Audit Ledger** | `GET /v1/usage`, `GET /v1/audit` | `client.get_usage()`, `client.export_audit()` |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Repository Structure
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
├── krama/ # Official thin Python SDK (KramaClient) & CLI (krama)
|
|
119
|
+
├── tests/ # SDK & CLI pytest suite
|
|
120
|
+
├── krama-web/ # React + TypeScript Developer Portal & Documentation SPA
|
|
121
|
+
├── docs/ # ReadTheDocs (Material for MkDocs) documentation pages
|
|
122
|
+
├── .readthedocs.yaml # ReadTheDocs v2 build configuration
|
|
123
|
+
├── mkdocs.yml # MkDocs configuration
|
|
124
|
+
├── codecov.yml # Codecov coverage thresholds & path filters
|
|
125
|
+
└── .github/ # CI/CD workflows, issue & PR templates
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Documentation & Links
|
|
131
|
+
|
|
132
|
+
- **Cloud Portal & Playground**: [https://krama.anagatam.workers.dev](https://krama.anagatam.workers.dev)
|
|
133
|
+
- **ReadTheDocs**: [https://krama-forecast.readthedocs.io/en/latest/](https://krama-forecast.readthedocs.io/en/latest/)
|
|
134
|
+
- **Interactive OpenAPI / Swagger**: [https://krama.anagatam.workers.dev/docs](https://krama.anagatam.workers.dev/docs)
|
|
135
|
+
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md) · **Security**: [SECURITY.md](SECURITY.md) · **Changelog**: [CHANGELOG.md](CHANGELOG.md) · **Code of Conduct**: [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## License & Disclaimer
|
|
140
|
+
|
|
141
|
+
**Apache License 2.0** — Copyright © 2026 [Anagatam Technologies](https://github.com/Anagatam). All rights reserved.
|
|
142
|
+
|
|
143
|
+
> [!CAUTION]
|
|
144
|
+
> **Not investment advice.** Krama is a mathematical forecasting platform for engineering, research, and planning use only. See [DISCLAIMER.md](DISCLAIMER.md) for regulatory compliance details.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<h1 align="center">Krama</h1>
|
|
2
|
+
<p align="center">
|
|
3
|
+
<strong>Institutional Time-Series Forecasting SaaS Platform, Python SDK & CLI</strong><br>
|
|
4
|
+
<em>Regularized structural decomposition, 8 forecasting engines, split-conformal intervals, and SHA-256 audit trails.</em>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://krama.anagatam.workers.dev"><strong>Cloud Portal</strong></a> ·
|
|
9
|
+
<a href="https://krama-forecast.readthedocs.io/en/latest/"><strong>Documentation</strong></a> ·
|
|
10
|
+
<a href="https://krama.anagatam.workers.dev/docs"><strong>Swagger / OpenAPI</strong></a> ·
|
|
11
|
+
<a href="https://pypi.org/project/krama-forecast/"><strong>PyPI</strong></a> ·
|
|
12
|
+
<a href="https://github.com/Anagatam/Krama/blob/main/DISCLAIMER.md"><strong>Disclaimer</strong></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<a href="https://github.com/Anagatam/Krama/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License"></a>
|
|
17
|
+
<a href="https://github.com/Anagatam/Krama/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Anagatam/Krama/ci.yml?branch=main&label=CI" alt="CI Status"></a>
|
|
18
|
+
<a href="https://codecov.io/gh/Anagatam/Krama"><img src="https://codecov.io/gh/Anagatam/Krama/graph/badge.svg" alt="Codecov"></a>
|
|
19
|
+
<a href="https://krama-forecast.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/krama-forecast/badge/?version=latest" alt="ReadTheDocs"></a>
|
|
20
|
+
<a href="https://pypi.org/project/krama-forecast/"><img src="https://img.shields.io/pypi/v/krama-forecast?color=orange&label=pypi" alt="PyPI"></a>
|
|
21
|
+
<a href="https://pypi.org/project/krama-forecast/"><img src="https://img.shields.io/pypi/pyversions/krama-forecast" alt="Python"></a>
|
|
22
|
+
<a href="https://peps.python.org/pep-0561/"><img src="https://img.shields.io/badge/types-PEP%20561-blue.svg" alt="PEP 561 Typed"></a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
**Krama** provides a hosted multi-tenant forecasting engine on Cloudflare Workers + D1 alongside a zero-dependency-overhead Python client SDK (`KramaClient`), CLI (`krama`), and interactive Developer API Portal.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Install the Python SDK & CLI
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install krama-forecast
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Forecast with Python
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
import pandas as pd
|
|
41
|
+
from krama import KramaClient
|
|
42
|
+
|
|
43
|
+
df = pd.DataFrame({
|
|
44
|
+
"ds": ["2026-01-01", "2026-01-02", "2026-01-03", "2026-01-04"],
|
|
45
|
+
"y": [102.4, 108.1, 115.6, 119.2],
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
with KramaClient(api_key="krm_live_your_key") as client:
|
|
49
|
+
res = client.forecast(df, periods=14, model_type="krama", robust=True, interval_width=0.90)
|
|
50
|
+
print(pd.DataFrame(res["forecast"]).head())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. Forecast from the CLI
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
export KRAMA_API_KEY="krm_live_your_key"
|
|
57
|
+
krama forecast sales.csv --periods 14 --model-type krama --robust --output forecast.csv
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Core Capabilities
|
|
63
|
+
|
|
64
|
+
| Capability | Endpoint | SDK Method |
|
|
65
|
+
| :--- | :--- | :--- |
|
|
66
|
+
| **Single-Series Conformal Forecast** | `POST /v1/forecast` | `client.forecast(...)` |
|
|
67
|
+
| **Multi-Series Batch Forecast** | `POST /v1/global/forecast` | `client.global_forecast(...)` |
|
|
68
|
+
| **MinT Hierarchical Reconciliation** | `POST /v1/hierarchical/forecast` | `client.hierarchical_forecast(...)` |
|
|
69
|
+
| **MAD Residual Anomaly Scan** | `POST /v1/detect/anomalies` | `client.detect_anomalies(...)` |
|
|
70
|
+
| **PELT / BinSeg Structural Breaks** | `POST /v1/detect/changepoints` | `client.detect_changepoints(...)` |
|
|
71
|
+
| **Rolling & Expanding Cross-Validation** | `POST /v1/backtest` | `client.backtest(...)` |
|
|
72
|
+
| **Datasets & Saved Models** | `POST /v1/datasets`, `POST /v1/models/train` | `client.upload_dataset(...)`, `client.train_model(...)` |
|
|
73
|
+
| **Scoped API Keys & Rotation** | `POST /v1/api-keys`, `/rotate` | `client.create_api_key(...)`, `client.rotate_api_key(...)` |
|
|
74
|
+
| **Usage, Per-Key Stats & Audit Ledger** | `GET /v1/usage`, `GET /v1/audit` | `client.get_usage()`, `client.export_audit()` |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Repository Structure
|
|
79
|
+
|
|
80
|
+
```text
|
|
81
|
+
├── krama/ # Official thin Python SDK (KramaClient) & CLI (krama)
|
|
82
|
+
├── tests/ # SDK & CLI pytest suite
|
|
83
|
+
├── krama-web/ # React + TypeScript Developer Portal & Documentation SPA
|
|
84
|
+
├── docs/ # ReadTheDocs (Material for MkDocs) documentation pages
|
|
85
|
+
├── .readthedocs.yaml # ReadTheDocs v2 build configuration
|
|
86
|
+
├── mkdocs.yml # MkDocs configuration
|
|
87
|
+
├── codecov.yml # Codecov coverage thresholds & path filters
|
|
88
|
+
└── .github/ # CI/CD workflows, issue & PR templates
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Documentation & Links
|
|
94
|
+
|
|
95
|
+
- **Cloud Portal & Playground**: [https://krama.anagatam.workers.dev](https://krama.anagatam.workers.dev)
|
|
96
|
+
- **ReadTheDocs**: [https://krama-forecast.readthedocs.io/en/latest/](https://krama-forecast.readthedocs.io/en/latest/)
|
|
97
|
+
- **Interactive OpenAPI / Swagger**: [https://krama.anagatam.workers.dev/docs](https://krama.anagatam.workers.dev/docs)
|
|
98
|
+
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md) · **Security**: [SECURITY.md](SECURITY.md) · **Changelog**: [CHANGELOG.md](CHANGELOG.md) · **Code of Conduct**: [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## License & Disclaimer
|
|
103
|
+
|
|
104
|
+
**Apache License 2.0** — Copyright © 2026 [Anagatam Technologies](https://github.com/Anagatam). All rights reserved.
|
|
105
|
+
|
|
106
|
+
> [!CAUTION]
|
|
107
|
+
> **Not investment advice.** Krama is a mathematical forecasting platform for engineering, research, and planning use only. See [DISCLAIMER.md](DISCLAIMER.md) for regulatory compliance details.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Krama — Official Python Client SDK
|
|
3
|
+
Copyright © 2026 Anagatam Technologies. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Apache-2.0 License | https://github.com/Anagatam/Krama
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "1.0.0"
|
|
9
|
+
__author__ = "Anagatam Technologies"
|
|
10
|
+
__license__ = "Apache-2.0"
|
|
11
|
+
|
|
12
|
+
from krama.client import DEFAULT_BASE_URL, KramaApiError, KramaClient
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"KramaClient",
|
|
16
|
+
"KramaApiError",
|
|
17
|
+
"DEFAULT_BASE_URL",
|
|
18
|
+
"__version__",
|
|
19
|
+
"__author__",
|
|
20
|
+
"__license__",
|
|
21
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Krama CLI — Thin API Command-Line Interface for Krama Cloud Forecasting
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
import pandas as pd
|
|
13
|
+
|
|
14
|
+
from krama import DEFAULT_BASE_URL, KramaClient, __version__
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _cmd_forecast(args: argparse.Namespace) -> int:
|
|
18
|
+
api_key = args.api_key or os.environ.get("KRAMA_API_KEY")
|
|
19
|
+
if not api_key:
|
|
20
|
+
print("Error: Provide --api-key or set KRAMA_API_KEY environment variable.", file=sys.stderr)
|
|
21
|
+
return 1
|
|
22
|
+
|
|
23
|
+
df = pd.read_csv(args.input)
|
|
24
|
+
ds_col = args.ds_col or ("ds" if "ds" in df.columns else df.columns[0])
|
|
25
|
+
y_col = args.y_col or ("y" if "y" in df.columns else df.columns[1])
|
|
26
|
+
norm = df[[ds_col, y_col]].rename(columns={ds_col: "ds", y_col: "y"})
|
|
27
|
+
|
|
28
|
+
client = KramaClient(base_url=args.base_url, api_key=api_key)
|
|
29
|
+
result = client.forecast(
|
|
30
|
+
df=norm,
|
|
31
|
+
periods=args.periods,
|
|
32
|
+
model_type=args.model_type,
|
|
33
|
+
robust=args.robust,
|
|
34
|
+
config={"growth": args.growth, "seasonality_mode": args.seasonality_mode},
|
|
35
|
+
)
|
|
36
|
+
out_df = pd.DataFrame(result.get("forecast", []))
|
|
37
|
+
|
|
38
|
+
if args.output:
|
|
39
|
+
out_df.to_csv(args.output, index=False)
|
|
40
|
+
print(f"Saved {len(out_df)} forecasted rows to {args.output}")
|
|
41
|
+
else:
|
|
42
|
+
print(out_df.to_string(index=False))
|
|
43
|
+
|
|
44
|
+
if args.audit_json:
|
|
45
|
+
with open(args.audit_json, "w", encoding="utf-8") as fh:
|
|
46
|
+
json.dump(result, fh, indent=2)
|
|
47
|
+
return 0
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
51
|
+
parser = argparse.ArgumentParser(
|
|
52
|
+
prog="krama",
|
|
53
|
+
description="Krama — Official Cloud Forecasting API CLI",
|
|
54
|
+
)
|
|
55
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
56
|
+
|
|
57
|
+
p_ver = sub.add_parser("version", help="Print Krama SDK version")
|
|
58
|
+
p_ver.set_defaults(func=lambda _args: print(json.dumps({"krama": __version__})) or 0)
|
|
59
|
+
|
|
60
|
+
p_fc = sub.add_parser("forecast", help="Run a cloud forecast via Krama API key")
|
|
61
|
+
p_fc.add_argument("input", help="Path to CSV file")
|
|
62
|
+
p_fc.add_argument("--api-key", default=None, help="Krama API key (or set KRAMA_API_KEY)")
|
|
63
|
+
p_fc.add_argument("--base-url", default=DEFAULT_BASE_URL, help="Krama API base URL")
|
|
64
|
+
p_fc.add_argument("--periods", type=int, default=30)
|
|
65
|
+
p_fc.add_argument("--model-type", default="krama")
|
|
66
|
+
p_fc.add_argument("--ds-col", default=None)
|
|
67
|
+
p_fc.add_argument("--y-col", default=None)
|
|
68
|
+
p_fc.add_argument("--growth", default="linear", choices=("linear", "logistic", "flat"))
|
|
69
|
+
p_fc.add_argument(
|
|
70
|
+
"--seasonality-mode",
|
|
71
|
+
default="additive",
|
|
72
|
+
choices=("additive", "multiplicative"),
|
|
73
|
+
)
|
|
74
|
+
p_fc.add_argument("--robust", action="store_true")
|
|
75
|
+
p_fc.add_argument("--output", default=None, help="Output CSV path")
|
|
76
|
+
p_fc.add_argument("--audit-json", default=None, help="Optional response JSON path")
|
|
77
|
+
p_fc.set_defaults(func=_cmd_forecast)
|
|
78
|
+
|
|
79
|
+
return parser
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def main(argv: list[str] | None = None) -> int:
|
|
83
|
+
parser = build_parser()
|
|
84
|
+
args = parser.parse_args(argv)
|
|
85
|
+
return int(args.func(args) or 0)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if __name__ == "__main__":
|
|
89
|
+
sys.exit(main())
|