chapkit 0.4.5__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.
- chapkit-0.4.5/PKG-INFO +196 -0
- chapkit-0.4.5/README.md +169 -0
- chapkit-0.4.5/pyproject.toml +161 -0
- chapkit-0.4.5/src/chapkit/__init__.py +97 -0
- chapkit-0.4.5/src/chapkit/alembic_helpers.py +138 -0
- chapkit-0.4.5/src/chapkit/api/__init__.py +64 -0
- chapkit-0.4.5/src/chapkit/api/dependencies.py +32 -0
- chapkit-0.4.5/src/chapkit/api/service_builder.py +348 -0
- chapkit-0.4.5/src/chapkit/artifact/__init__.py +18 -0
- chapkit-0.4.5/src/chapkit/artifact/manager.py +132 -0
- chapkit-0.4.5/src/chapkit/artifact/models.py +36 -0
- chapkit-0.4.5/src/chapkit/artifact/repository.py +48 -0
- chapkit-0.4.5/src/chapkit/artifact/router.py +126 -0
- chapkit-0.4.5/src/chapkit/artifact/schemas.py +67 -0
- chapkit-0.4.5/src/chapkit/cli/__init__.py +5 -0
- chapkit-0.4.5/src/chapkit/cli/__main__.py +6 -0
- chapkit-0.4.5/src/chapkit/cli/cli.py +31 -0
- chapkit-0.4.5/src/chapkit/cli/init.py +151 -0
- chapkit-0.4.5/src/chapkit/cli/templates/.gitignore +152 -0
- chapkit-0.4.5/src/chapkit/cli/templates/Dockerfile.jinja2 +80 -0
- chapkit-0.4.5/src/chapkit/cli/templates/README.md.jinja2 +132 -0
- chapkit-0.4.5/src/chapkit/cli/templates/compose.monitoring.yml.jinja2 +88 -0
- chapkit-0.4.5/src/chapkit/cli/templates/compose.yml.jinja2 +30 -0
- chapkit-0.4.5/src/chapkit/cli/templates/main.py.jinja2 +135 -0
- chapkit-0.4.5/src/chapkit/cli/templates/monitoring/grafana/dashboards/chapkit-service-metrics.json +1232 -0
- chapkit-0.4.5/src/chapkit/cli/templates/monitoring/grafana/provisioning/dashboards/dashboard.yml +13 -0
- chapkit-0.4.5/src/chapkit/cli/templates/monitoring/grafana/provisioning/datasources/prometheus.yml +25 -0
- chapkit-0.4.5/src/chapkit/cli/templates/monitoring/prometheus/prometheus.yml.jinja2 +13 -0
- chapkit-0.4.5/src/chapkit/cli/templates/pyproject.toml.jinja2 +17 -0
- chapkit-0.4.5/src/chapkit/config/__init__.py +20 -0
- chapkit-0.4.5/src/chapkit/config/manager.py +63 -0
- chapkit-0.4.5/src/chapkit/config/models.py +60 -0
- chapkit-0.4.5/src/chapkit/config/repository.py +76 -0
- chapkit-0.4.5/src/chapkit/config/router.py +112 -0
- chapkit-0.4.5/src/chapkit/config/schemas.py +63 -0
- chapkit-0.4.5/src/chapkit/ml/__init__.py +29 -0
- chapkit-0.4.5/src/chapkit/ml/manager.py +231 -0
- chapkit-0.4.5/src/chapkit/ml/router.py +114 -0
- chapkit-0.4.5/src/chapkit/ml/runner.py +260 -0
- chapkit-0.4.5/src/chapkit/ml/schemas.py +98 -0
- chapkit-0.4.5/src/chapkit/py.typed +0 -0
- chapkit-0.4.5/src/chapkit/scheduler.py +154 -0
- chapkit-0.4.5/src/chapkit/task/__init__.py +20 -0
- chapkit-0.4.5/src/chapkit/task/manager.py +300 -0
- chapkit-0.4.5/src/chapkit/task/models.py +20 -0
- chapkit-0.4.5/src/chapkit/task/registry.py +46 -0
- chapkit-0.4.5/src/chapkit/task/repository.py +31 -0
- chapkit-0.4.5/src/chapkit/task/router.py +115 -0
- chapkit-0.4.5/src/chapkit/task/schemas.py +28 -0
- chapkit-0.4.5/src/chapkit/task/validation.py +76 -0
chapkit-0.4.5/PKG-INFO
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: chapkit
|
|
3
|
+
Version: 0.4.5
|
|
4
|
+
Summary: ML and data service modules built on servicekit - config, artifacts, tasks, and ML workflows
|
|
5
|
+
Keywords: ml,machine-learning,data-science,artifacts,tasks,config,servicekit
|
|
6
|
+
Author: Morten Hansen
|
|
7
|
+
Author-email: Morten Hansen <morten@dhis2.org>
|
|
8
|
+
License: AGPL-3.0-or-later
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Framework :: FastAPI
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Dist: geojson-pydantic>=2.1.0
|
|
18
|
+
Requires-Dist: typer>=0.20.0
|
|
19
|
+
Requires-Dist: jinja2>=3.1.6
|
|
20
|
+
Requires-Dist: servicekit>=0.3.5
|
|
21
|
+
Requires-Python: >=3.13
|
|
22
|
+
Project-URL: Documentation, https://dhis2-chap.github.io/chapkit
|
|
23
|
+
Project-URL: Homepage, https://github.com/dhis2-chap/chapkit
|
|
24
|
+
Project-URL: Issues, https://github.com/dhis2-chap/chapkit/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/dhis2-chap/chapkit
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Chapkit
|
|
29
|
+
|
|
30
|
+
[](https://github.com/dhis2-chap/chapkit/actions/workflows/ci.yml)
|
|
31
|
+
[](https://codecov.io/gh/dhis2-chap/chapkit)
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
34
|
+
[](https://dhis2-chap.github.io/chapkit/)
|
|
35
|
+
|
|
36
|
+
> ML service modules built on servicekit - config, artifact, task, and ML workflows
|
|
37
|
+
|
|
38
|
+
Chapkit provides domain-specific modules for building machine learning services on top of servicekit's core framework. Includes artifact storage, task execution, configuration management, and ML train/predict workflows.
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
- **Artifact Module**: Hierarchical storage for models, data, and experiment tracking with parent-child relationships
|
|
43
|
+
- **Task Module**: Reusable command templates for shell and Python task execution with parameter injection
|
|
44
|
+
- **Config Module**: Key-value configuration with JSON data and Pydantic validation
|
|
45
|
+
- **ML Module**: Train/predict workflows with artifact-based model storage and timing metadata
|
|
46
|
+
- **Config-Artifact Linking**: Connect configurations to artifact hierarchies for experiment tracking
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install chapkit
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Chapkit automatically installs servicekit as a dependency.
|
|
55
|
+
|
|
56
|
+
## CLI Usage
|
|
57
|
+
|
|
58
|
+
Quickly scaffold a new ML service project using `uvx`:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uvx chapkit@git+https://github.com/dhis2-chap/chapkit init <project-name>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Example:
|
|
65
|
+
```bash
|
|
66
|
+
uvx chapkit@git+https://github.com/dhis2-chap/chapkit init my-ml-service
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Options:
|
|
70
|
+
- `--path <directory>` - Target directory (default: current directory)
|
|
71
|
+
- `--monitoring` - Include Prometheus and Grafana monitoring stack
|
|
72
|
+
|
|
73
|
+
This creates a ready-to-run ML service with configuration, artifacts, and ML endpoints pre-configured.
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from chapkit import ArtifactHierarchy, BaseConfig
|
|
79
|
+
from chapkit.api import ServiceBuilder, ServiceInfo
|
|
80
|
+
|
|
81
|
+
class MyConfig(BaseConfig):
|
|
82
|
+
model_name: str
|
|
83
|
+
threshold: float
|
|
84
|
+
|
|
85
|
+
app = (
|
|
86
|
+
ServiceBuilder(info=ServiceInfo(display_name="ML Service"))
|
|
87
|
+
.with_health()
|
|
88
|
+
.with_config(MyConfig)
|
|
89
|
+
.with_artifacts(hierarchy=ArtifactHierarchy(name="ml", level_labels={0: "model"}))
|
|
90
|
+
.with_jobs()
|
|
91
|
+
.build()
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Modules
|
|
96
|
+
|
|
97
|
+
### Config
|
|
98
|
+
|
|
99
|
+
Key-value configuration storage with Pydantic schema validation:
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from chapkit import BaseConfig, ConfigManager
|
|
103
|
+
|
|
104
|
+
class AppConfig(BaseConfig):
|
|
105
|
+
api_url: str
|
|
106
|
+
timeout: int = 30
|
|
107
|
+
|
|
108
|
+
# Automatic validation and CRUD endpoints
|
|
109
|
+
app.with_config(AppConfig)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Artifacts
|
|
113
|
+
|
|
114
|
+
Hierarchical storage for models, data, and experiment tracking:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from chapkit import ArtifactHierarchy, ArtifactManager, ArtifactIn
|
|
118
|
+
|
|
119
|
+
hierarchy = ArtifactHierarchy(
|
|
120
|
+
name="ml_pipeline",
|
|
121
|
+
level_labels={0: "experiment", 1: "model", 2: "evaluation"}
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
# Store pandas DataFrames, models, any Python object
|
|
125
|
+
artifact = await artifact_manager.save(
|
|
126
|
+
ArtifactIn(data=trained_model, parent_id=experiment_id)
|
|
127
|
+
)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### ML
|
|
131
|
+
|
|
132
|
+
Train and predict workflows with automatic model storage:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from chapkit.ml import FunctionalModelRunner
|
|
136
|
+
import pandas as pd
|
|
137
|
+
|
|
138
|
+
async def train_model(config: MyConfig, data: pd.DataFrame, geo=None):
|
|
139
|
+
"""Train your model - returns trained model object."""
|
|
140
|
+
from sklearn.linear_model import LinearRegression
|
|
141
|
+
model = LinearRegression()
|
|
142
|
+
model.fit(data[["feature1", "feature2"]], data["target"])
|
|
143
|
+
return model
|
|
144
|
+
|
|
145
|
+
async def predict(config: MyConfig, model, historic: pd.DataFrame, future: pd.DataFrame, geo=None):
|
|
146
|
+
"""Make predictions - returns DataFrame with predictions."""
|
|
147
|
+
predictions = model.predict(future[["feature1", "feature2"]])
|
|
148
|
+
future["predictions"] = predictions
|
|
149
|
+
return future
|
|
150
|
+
|
|
151
|
+
# Wrap functions in runner
|
|
152
|
+
runner = FunctionalModelRunner(on_train=train_model, on_predict=predict)
|
|
153
|
+
app.with_ml(runner=runner)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Architecture
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
chapkit/
|
|
160
|
+
├── config/ # Configuration module
|
|
161
|
+
├── ml/ # ML train/predict workflows
|
|
162
|
+
└── api/ # ServiceBuilder with ML integration
|
|
163
|
+
└── service_builder.py # .with_config(), .with_ml()
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Chapkit extends servicekit's `BaseServiceBuilder` with ML-specific features and uses servicekit's artifact and task modules.
|
|
167
|
+
|
|
168
|
+
## Examples
|
|
169
|
+
|
|
170
|
+
See the `examples/` directory:
|
|
171
|
+
|
|
172
|
+
- `quickstart.py` - Complete ML service
|
|
173
|
+
- `config_artifact_api.py` - Config with artifact linking
|
|
174
|
+
- `ml_basic.py`, `ml_class.py` - ML workflow patterns
|
|
175
|
+
|
|
176
|
+
## Documentation
|
|
177
|
+
|
|
178
|
+
See `docs/` for comprehensive guides:
|
|
179
|
+
|
|
180
|
+
- ML workflow guide
|
|
181
|
+
|
|
182
|
+
## Testing
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
make test # Run tests
|
|
186
|
+
make lint # Run linter
|
|
187
|
+
make coverage # Test coverage
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
AGPL-3.0-or-later
|
|
193
|
+
|
|
194
|
+
## Related Projects
|
|
195
|
+
|
|
196
|
+
- **[servicekit](https://github.com/winterop-com/servicekit)** - Core framework foundation (FastAPI, SQLAlchemy, CRUD, auth, etc.) ([docs](https://winterop-com.github.io/servicekit))
|
chapkit-0.4.5/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Chapkit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/dhis2-chap/chapkit/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/dhis2-chap/chapkit)
|
|
5
|
+
[](https://www.python.org/downloads/)
|
|
6
|
+
[](https://www.gnu.org/licenses/agpl-3.0)
|
|
7
|
+
[](https://dhis2-chap.github.io/chapkit/)
|
|
8
|
+
|
|
9
|
+
> ML service modules built on servicekit - config, artifact, task, and ML workflows
|
|
10
|
+
|
|
11
|
+
Chapkit provides domain-specific modules for building machine learning services on top of servicekit's core framework. Includes artifact storage, task execution, configuration management, and ML train/predict workflows.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Artifact Module**: Hierarchical storage for models, data, and experiment tracking with parent-child relationships
|
|
16
|
+
- **Task Module**: Reusable command templates for shell and Python task execution with parameter injection
|
|
17
|
+
- **Config Module**: Key-value configuration with JSON data and Pydantic validation
|
|
18
|
+
- **ML Module**: Train/predict workflows with artifact-based model storage and timing metadata
|
|
19
|
+
- **Config-Artifact Linking**: Connect configurations to artifact hierarchies for experiment tracking
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install chapkit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Chapkit automatically installs servicekit as a dependency.
|
|
28
|
+
|
|
29
|
+
## CLI Usage
|
|
30
|
+
|
|
31
|
+
Quickly scaffold a new ML service project using `uvx`:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uvx chapkit@git+https://github.com/dhis2-chap/chapkit init <project-name>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Example:
|
|
38
|
+
```bash
|
|
39
|
+
uvx chapkit@git+https://github.com/dhis2-chap/chapkit init my-ml-service
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Options:
|
|
43
|
+
- `--path <directory>` - Target directory (default: current directory)
|
|
44
|
+
- `--monitoring` - Include Prometheus and Grafana monitoring stack
|
|
45
|
+
|
|
46
|
+
This creates a ready-to-run ML service with configuration, artifacts, and ML endpoints pre-configured.
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from chapkit import ArtifactHierarchy, BaseConfig
|
|
52
|
+
from chapkit.api import ServiceBuilder, ServiceInfo
|
|
53
|
+
|
|
54
|
+
class MyConfig(BaseConfig):
|
|
55
|
+
model_name: str
|
|
56
|
+
threshold: float
|
|
57
|
+
|
|
58
|
+
app = (
|
|
59
|
+
ServiceBuilder(info=ServiceInfo(display_name="ML Service"))
|
|
60
|
+
.with_health()
|
|
61
|
+
.with_config(MyConfig)
|
|
62
|
+
.with_artifacts(hierarchy=ArtifactHierarchy(name="ml", level_labels={0: "model"}))
|
|
63
|
+
.with_jobs()
|
|
64
|
+
.build()
|
|
65
|
+
)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Modules
|
|
69
|
+
|
|
70
|
+
### Config
|
|
71
|
+
|
|
72
|
+
Key-value configuration storage with Pydantic schema validation:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from chapkit import BaseConfig, ConfigManager
|
|
76
|
+
|
|
77
|
+
class AppConfig(BaseConfig):
|
|
78
|
+
api_url: str
|
|
79
|
+
timeout: int = 30
|
|
80
|
+
|
|
81
|
+
# Automatic validation and CRUD endpoints
|
|
82
|
+
app.with_config(AppConfig)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Artifacts
|
|
86
|
+
|
|
87
|
+
Hierarchical storage for models, data, and experiment tracking:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from chapkit import ArtifactHierarchy, ArtifactManager, ArtifactIn
|
|
91
|
+
|
|
92
|
+
hierarchy = ArtifactHierarchy(
|
|
93
|
+
name="ml_pipeline",
|
|
94
|
+
level_labels={0: "experiment", 1: "model", 2: "evaluation"}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Store pandas DataFrames, models, any Python object
|
|
98
|
+
artifact = await artifact_manager.save(
|
|
99
|
+
ArtifactIn(data=trained_model, parent_id=experiment_id)
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### ML
|
|
104
|
+
|
|
105
|
+
Train and predict workflows with automatic model storage:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
from chapkit.ml import FunctionalModelRunner
|
|
109
|
+
import pandas as pd
|
|
110
|
+
|
|
111
|
+
async def train_model(config: MyConfig, data: pd.DataFrame, geo=None):
|
|
112
|
+
"""Train your model - returns trained model object."""
|
|
113
|
+
from sklearn.linear_model import LinearRegression
|
|
114
|
+
model = LinearRegression()
|
|
115
|
+
model.fit(data[["feature1", "feature2"]], data["target"])
|
|
116
|
+
return model
|
|
117
|
+
|
|
118
|
+
async def predict(config: MyConfig, model, historic: pd.DataFrame, future: pd.DataFrame, geo=None):
|
|
119
|
+
"""Make predictions - returns DataFrame with predictions."""
|
|
120
|
+
predictions = model.predict(future[["feature1", "feature2"]])
|
|
121
|
+
future["predictions"] = predictions
|
|
122
|
+
return future
|
|
123
|
+
|
|
124
|
+
# Wrap functions in runner
|
|
125
|
+
runner = FunctionalModelRunner(on_train=train_model, on_predict=predict)
|
|
126
|
+
app.with_ml(runner=runner)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Architecture
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
chapkit/
|
|
133
|
+
├── config/ # Configuration module
|
|
134
|
+
├── ml/ # ML train/predict workflows
|
|
135
|
+
└── api/ # ServiceBuilder with ML integration
|
|
136
|
+
└── service_builder.py # .with_config(), .with_ml()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Chapkit extends servicekit's `BaseServiceBuilder` with ML-specific features and uses servicekit's artifact and task modules.
|
|
140
|
+
|
|
141
|
+
## Examples
|
|
142
|
+
|
|
143
|
+
See the `examples/` directory:
|
|
144
|
+
|
|
145
|
+
- `quickstart.py` - Complete ML service
|
|
146
|
+
- `config_artifact_api.py` - Config with artifact linking
|
|
147
|
+
- `ml_basic.py`, `ml_class.py` - ML workflow patterns
|
|
148
|
+
|
|
149
|
+
## Documentation
|
|
150
|
+
|
|
151
|
+
See `docs/` for comprehensive guides:
|
|
152
|
+
|
|
153
|
+
- ML workflow guide
|
|
154
|
+
|
|
155
|
+
## Testing
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
make test # Run tests
|
|
159
|
+
make lint # Run linter
|
|
160
|
+
make coverage # Test coverage
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
AGPL-3.0-or-later
|
|
166
|
+
|
|
167
|
+
## Related Projects
|
|
168
|
+
|
|
169
|
+
- **[servicekit](https://github.com/winterop-com/servicekit)** - Core framework foundation (FastAPI, SQLAlchemy, CRUD, auth, etc.) ([docs](https://winterop-com.github.io/servicekit))
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "chapkit"
|
|
3
|
+
version = "0.4.5"
|
|
4
|
+
description = "ML and data service modules built on servicekit - config, artifacts, tasks, and ML workflows"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [{ name = "Morten Hansen", email = "morten@dhis2.org" }]
|
|
7
|
+
license = { text = "AGPL-3.0-or-later" }
|
|
8
|
+
requires-python = ">=3.13"
|
|
9
|
+
keywords = [
|
|
10
|
+
"ml",
|
|
11
|
+
"machine-learning",
|
|
12
|
+
"data-science",
|
|
13
|
+
"artifacts",
|
|
14
|
+
"tasks",
|
|
15
|
+
"config",
|
|
16
|
+
"servicekit",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Framework :: FastAPI",
|
|
25
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"geojson-pydantic>=2.1.0",
|
|
30
|
+
"typer>=0.20.0",
|
|
31
|
+
"jinja2>=3.1.6",
|
|
32
|
+
"servicekit>=0.3.5",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/dhis2-chap/chapkit"
|
|
37
|
+
Repository = "https://github.com/dhis2-chap/chapkit"
|
|
38
|
+
Issues = "https://github.com/dhis2-chap/chapkit/issues"
|
|
39
|
+
Documentation = "https://dhis2-chap.github.io/chapkit"
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
chapkit = "chapkit.cli.cli:main"
|
|
43
|
+
|
|
44
|
+
[dependency-groups]
|
|
45
|
+
dev = [
|
|
46
|
+
"coverage[toml]>=7.6.0",
|
|
47
|
+
"mypy>=1.18.2",
|
|
48
|
+
"pandas-stubs>=2.2.3.250101",
|
|
49
|
+
"pytest>=8.4.2",
|
|
50
|
+
"pytest-cov>=5.0.0",
|
|
51
|
+
"pytest-asyncio>=1.2.0",
|
|
52
|
+
"ruff>=0.14.0",
|
|
53
|
+
"pyright>=1.1.407",
|
|
54
|
+
"scikit-learn>=1.7.2",
|
|
55
|
+
"mkdocs>=1.6.0",
|
|
56
|
+
"mkdocs-material>=9.5.0",
|
|
57
|
+
"mkdocstrings[python]>=0.26.0",
|
|
58
|
+
"types-pyyaml>=6.0.12.20250915",
|
|
59
|
+
"pandas>=2.3.3",
|
|
60
|
+
"polars>=1.34.0",
|
|
61
|
+
"xarray>=2025.10.1",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[build-system]
|
|
65
|
+
requires = ["uv_build>=0.9.0,<0.10.0"]
|
|
66
|
+
build-backend = "uv_build"
|
|
67
|
+
|
|
68
|
+
[tool.ruff]
|
|
69
|
+
target-version = "py313"
|
|
70
|
+
line-length = 120
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint]
|
|
73
|
+
fixable = ["ALL"]
|
|
74
|
+
select = ["E", "W", "F", "I", "D"]
|
|
75
|
+
ignore = ["D203", "D213"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff.lint.pydocstyle]
|
|
78
|
+
convention = "google"
|
|
79
|
+
|
|
80
|
+
[tool.ruff.lint.per-file-ignores]
|
|
81
|
+
"tests/**/*.py" = ["D"]
|
|
82
|
+
"alembic/**/*.py" = ["D"]
|
|
83
|
+
"**/__init__.py" = ["D104"]
|
|
84
|
+
"src/**/*.py" = ["D102", "D105", "D107"]
|
|
85
|
+
"examples/**/*.py" = []
|
|
86
|
+
|
|
87
|
+
[tool.ruff.format]
|
|
88
|
+
quote-style = "double"
|
|
89
|
+
indent-style = "space"
|
|
90
|
+
skip-magic-trailing-comma = false
|
|
91
|
+
docstring-code-format = true
|
|
92
|
+
docstring-code-line-length = "dynamic"
|
|
93
|
+
|
|
94
|
+
[tool.pytest.ini_options]
|
|
95
|
+
asyncio_mode = "auto"
|
|
96
|
+
testpaths = ["tests"]
|
|
97
|
+
norecursedirs = ["examples", ".git", ".venv", "__pycache__"]
|
|
98
|
+
filterwarnings = [
|
|
99
|
+
"ignore:Pydantic serializer warnings:UserWarning",
|
|
100
|
+
"ignore:Remove.*format_exc_info.*:UserWarning",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[tool.coverage.run]
|
|
104
|
+
branch = true
|
|
105
|
+
dynamic_context = "test_function"
|
|
106
|
+
relative_files = true
|
|
107
|
+
source = ["chapkit"]
|
|
108
|
+
|
|
109
|
+
[tool.coverage.report]
|
|
110
|
+
exclude_also = ["if TYPE_CHECKING:"]
|
|
111
|
+
precision = 2
|
|
112
|
+
show_missing = true
|
|
113
|
+
skip_covered = true
|
|
114
|
+
|
|
115
|
+
[tool.mypy]
|
|
116
|
+
python_version = "3.13"
|
|
117
|
+
warn_return_any = true
|
|
118
|
+
warn_unused_configs = true
|
|
119
|
+
disallow_untyped_defs = true
|
|
120
|
+
check_untyped_defs = true
|
|
121
|
+
no_implicit_optional = true
|
|
122
|
+
warn_unused_ignores = true
|
|
123
|
+
strict_equality = true
|
|
124
|
+
mypy_path = ["src", "typings"]
|
|
125
|
+
|
|
126
|
+
[[tool.mypy.overrides]]
|
|
127
|
+
module = "tests.*"
|
|
128
|
+
disallow_untyped_defs = false
|
|
129
|
+
|
|
130
|
+
[[tool.mypy.overrides]]
|
|
131
|
+
module = "servicekit.*"
|
|
132
|
+
ignore_missing_imports = true
|
|
133
|
+
disallow_any_unimported = false
|
|
134
|
+
|
|
135
|
+
[[tool.mypy.overrides]]
|
|
136
|
+
module = [
|
|
137
|
+
"chapkit.artifact.*",
|
|
138
|
+
"chapkit.config.*",
|
|
139
|
+
"chapkit.task.*",
|
|
140
|
+
"examples.*",
|
|
141
|
+
]
|
|
142
|
+
warn_return_any = false
|
|
143
|
+
|
|
144
|
+
[[tool.mypy.overrides]]
|
|
145
|
+
module = "examples.custom_migrations.*"
|
|
146
|
+
ignore_missing_imports = true
|
|
147
|
+
ignore_errors = true
|
|
148
|
+
|
|
149
|
+
[tool.pyright]
|
|
150
|
+
include = ["src", "tests", "examples", "alembic"]
|
|
151
|
+
pythonVersion = "3.13"
|
|
152
|
+
typeCheckingMode = "strict"
|
|
153
|
+
useLibraryCodeForTypes = true
|
|
154
|
+
reportPrivateUsage = false
|
|
155
|
+
reportUnusedFunction = false
|
|
156
|
+
reportUnknownMemberType = false
|
|
157
|
+
reportUnknownArgumentType = false
|
|
158
|
+
reportUnknownParameterType = false
|
|
159
|
+
reportUnknownVariableType = false
|
|
160
|
+
reportMissingTypeArgument = false
|
|
161
|
+
reportMissingTypeStubs = false
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""Chapkit - ML/data service modules built on servicekit."""
|
|
2
|
+
|
|
3
|
+
# CLI feature
|
|
4
|
+
# Scheduler feature
|
|
5
|
+
# Artifact feature
|
|
6
|
+
from .artifact import (
|
|
7
|
+
Artifact,
|
|
8
|
+
ArtifactHierarchy,
|
|
9
|
+
ArtifactIn,
|
|
10
|
+
ArtifactManager,
|
|
11
|
+
ArtifactOut,
|
|
12
|
+
ArtifactRepository,
|
|
13
|
+
ArtifactRouter,
|
|
14
|
+
ArtifactTreeNode,
|
|
15
|
+
)
|
|
16
|
+
from .cli import app as cli_app
|
|
17
|
+
|
|
18
|
+
# Config feature
|
|
19
|
+
from .config import (
|
|
20
|
+
BaseConfig,
|
|
21
|
+
Config,
|
|
22
|
+
ConfigIn,
|
|
23
|
+
ConfigManager,
|
|
24
|
+
ConfigOut,
|
|
25
|
+
ConfigRepository,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# ML feature
|
|
29
|
+
from .ml import (
|
|
30
|
+
FunctionalModelRunner,
|
|
31
|
+
MLManager,
|
|
32
|
+
MLRouter,
|
|
33
|
+
ModelRunnerProtocol,
|
|
34
|
+
PredictionArtifactData,
|
|
35
|
+
PredictRequest,
|
|
36
|
+
PredictResponse,
|
|
37
|
+
TrainedModelArtifactData,
|
|
38
|
+
TrainRequest,
|
|
39
|
+
TrainResponse,
|
|
40
|
+
)
|
|
41
|
+
from .scheduler import ChapkitJobRecord, ChapkitJobScheduler
|
|
42
|
+
|
|
43
|
+
# Task feature
|
|
44
|
+
from .task import (
|
|
45
|
+
Task,
|
|
46
|
+
TaskIn,
|
|
47
|
+
TaskManager,
|
|
48
|
+
TaskOut,
|
|
49
|
+
TaskRegistry,
|
|
50
|
+
TaskRepository,
|
|
51
|
+
TaskRouter,
|
|
52
|
+
validate_and_disable_orphaned_tasks,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
__all__ = [
|
|
56
|
+
# CLI
|
|
57
|
+
"cli_app",
|
|
58
|
+
# Scheduler
|
|
59
|
+
"ChapkitJobRecord",
|
|
60
|
+
"ChapkitJobScheduler",
|
|
61
|
+
# Artifact
|
|
62
|
+
"Artifact",
|
|
63
|
+
"ArtifactHierarchy",
|
|
64
|
+
"ArtifactIn",
|
|
65
|
+
"ArtifactManager",
|
|
66
|
+
"ArtifactOut",
|
|
67
|
+
"ArtifactRepository",
|
|
68
|
+
"ArtifactRouter",
|
|
69
|
+
"ArtifactTreeNode",
|
|
70
|
+
# Config
|
|
71
|
+
"BaseConfig",
|
|
72
|
+
"Config",
|
|
73
|
+
"ConfigIn",
|
|
74
|
+
"ConfigManager",
|
|
75
|
+
"ConfigOut",
|
|
76
|
+
"ConfigRepository",
|
|
77
|
+
# ML
|
|
78
|
+
"FunctionalModelRunner",
|
|
79
|
+
"MLManager",
|
|
80
|
+
"MLRouter",
|
|
81
|
+
"ModelRunnerProtocol",
|
|
82
|
+
"PredictionArtifactData",
|
|
83
|
+
"PredictRequest",
|
|
84
|
+
"PredictResponse",
|
|
85
|
+
"TrainedModelArtifactData",
|
|
86
|
+
"TrainRequest",
|
|
87
|
+
"TrainResponse",
|
|
88
|
+
# Task
|
|
89
|
+
"Task",
|
|
90
|
+
"TaskIn",
|
|
91
|
+
"TaskManager",
|
|
92
|
+
"TaskOut",
|
|
93
|
+
"TaskRegistry",
|
|
94
|
+
"TaskRepository",
|
|
95
|
+
"TaskRouter",
|
|
96
|
+
"validate_and_disable_orphaned_tasks",
|
|
97
|
+
]
|