Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions docs/guides/artifact-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,9 @@ Update artifact data.

Delete artifact (fails if artifact has children).

### POST /api/v1/artifacts/$tree
### GET /api/v1/artifacts/{id}/$tree

Get artifact tree structure.

**Request:**
```json
{
"root_id": "01ARTIFACT456...",
"max_depth": 3
}
```
Get artifact tree structure rooted at the given artifact (no request body).

**Response:**
```json
Expand Down Expand Up @@ -615,9 +607,7 @@ CHILD_ID=$(curl -s -X POST http://localhost:9090/api/v1/artifacts \
}' | jq -r '.id')

# Get tree
curl -X POST http://localhost:9090/api/v1/artifacts/\$tree \
-H "Content-Type: application/json" \
-d '{"root_id": "'$ROOT_ID'"}' | jq
curl http://localhost:9090/api/v1/artifacts/$ROOT_ID/\$tree | jq
```

---
Expand Down
8 changes: 4 additions & 4 deletions docs/guides/configuration-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ Enable artifact operations when building the service:
```python
app = (
ServiceBuilder(info=info)
.with_config(MLConfig, enable_artifact_operations=True)
.with_artifacts(hierarchy=hierarchy)
.with_config(MLConfig)
.with_artifacts(hierarchy=hierarchy, enable_config_linking=True)
.build()
)
```
Expand Down Expand Up @@ -486,11 +486,11 @@ class WeatherModelConfig(BaseConfig):
app = (
ServiceBuilder(info=ServiceInfo(id="weather-model-service", display_name="Weather Model Service"))
.with_health()
.with_config(WeatherModelConfig, enable_artifact_operations=True)
.with_config(WeatherModelConfig)
.with_artifacts(hierarchy=ArtifactHierarchy(
name="weather_models",
level_labels={0: "ml_training_workspace", 1: "ml_prediction"}
))
), enable_config_linking=True)
.build()
)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/dataframe.md
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ high_sales = df.filter(lambda r: r['sales'] > 1000)
summary = high_sales.groupby('region').count()

# Chain with other operations
df.groupby('product').sum('sales').sort('sales_sum', reverse=True).head(5)
df.groupby('product').sum('sales').sort('sales_sum', ascending=False).head(5)
```

**Design notes:**
Expand Down
15 changes: 9 additions & 6 deletions docs/guides/ml-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Chapkit provides a complete ML workflow system for training models and making pr
from chapkit.artifact import ArtifactHierarchy

from chapkit import BaseConfig
from chapkit.api import MLServiceBuilder, MLServiceInfo
from chapkit.api import MLServiceBuilder, MLServiceInfo, AssessedStatus, ModelMetadata, PeriodType
from chapkit.ml import FunctionalModelRunner
import pandas as pd
from sklearn.linear_model import LinearRegression
Expand All @@ -34,7 +34,12 @@ runner = FunctionalModelRunner(on_train=on_train, on_predict=on_predict)

app = (
MLServiceBuilder(
info=MLServiceInfo(id="my-ml-service", display_name="My ML Service"),
info=MLServiceInfo(
id="my-ml-service",
display_name="My ML Service",
model_metadata=ModelMetadata(author="ML Team", author_assessed_status=AssessedStatus.green),
period_type=PeriodType.monthly,
),
config_schema=ModelConfig,
hierarchy=ArtifactHierarchy(name="ml", level_labels={0: "ml_training_workspace", 1: "ml_prediction"}),
runner=runner,
Expand Down Expand Up @@ -403,7 +408,6 @@ MLServiceBuilder(
config_schema=YourConfig,
hierarchy=hierarchy,
runner=runner,
max_concurrency=5, # Limit concurrent jobs (default: unlimited)
database_url="ml.db", # Persistent storage (default: in-memory)
)
```
Expand Down Expand Up @@ -729,7 +733,7 @@ All tabular data uses the `DataFrame` schema:

**Python Usage:**
```python
from servicekit.data import DataFrame
from chapkit.data import DataFrame

# Create from DataFrame
df = pd.DataFrame({"a": [1, 2], "b": [3, 4]})
Expand Down Expand Up @@ -1316,7 +1320,6 @@ MLServiceBuilder(
config_schema=config_schema,
hierarchy=hierarchy,
runner=runner,
max_concurrency=3, # Limit concurrent training jobs
)
```

Expand Down Expand Up @@ -1708,7 +1711,7 @@ curl http://localhost:9090/api/v1/jobs/$JOB_ID | jq '.error'
**Solution:**
```python
# Limit concurrent jobs
MLServiceBuilder(..., max_concurrency=2)
MLServiceBuilder(...)

# Implement artifact cleanup
async def cleanup_old_artifacts(app):
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/mlproject-runner.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ chapkit mlproject run . # same
chapkit mlproject run /path/to/my_mlproject
```

This parses the `MLproject` file, translates the entry-point commands to chapkit's workspace conventions, builds a FastAPI service with `/api/v1/ml/$train` and `/$predict` endpoints, and serves on `127.0.0.1:8000` by default. Override host/port with `--host` and `--port`.
This parses the `MLproject` file, translates the entry-point commands to chapkit's workspace conventions, builds a FastAPI service with `/api/v1/ml/$train` and `/$predict` endpoints, and serves on `127.0.0.1:9090` by default. Override host/port with `--host` and `--port`.

A minimal R MLproject like `dhis2-chap/minimalist_example_r`:

Expand Down
14 changes: 10 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Build production-ready ML services with train/predict workflows, artifact storag
from geojson_pydantic import FeatureCollection

from chapkit import BaseConfig
from chapkit.api import MLServiceBuilder, MLServiceInfo
from chapkit.api import MLServiceBuilder, MLServiceInfo, AssessedStatus, ModelMetadata, PeriodType
from chapkit.artifact import ArtifactHierarchy
from chapkit.data import DataFrame
from chapkit.ml import FunctionalModelRunner
Expand Down Expand Up @@ -55,7 +55,12 @@ async def predict(

app = (
MLServiceBuilder(
info=MLServiceInfo(id="disease-prediction-service", display_name="Disease Prediction Service"),
info=MLServiceInfo(
id="disease-prediction-service",
display_name="Disease Prediction Service",
model_metadata=ModelMetadata(author="ML Team", author_assessed_status=AssessedStatus.green),
period_type=PeriodType.monthly,
),
config_schema=MyMLConfig,
hierarchy=ArtifactHierarchy(
name="ml",
Expand All @@ -69,8 +74,9 @@ app = (
```

**What you get:**
- `POST /api/v1/ml/train` - Train models with versioning
- `POST /api/v1/ml/predict` - Make predictions
- `POST /api/v1/ml/$train` - Train models with versioning
- `POST /api/v1/ml/$predict` - Make predictions
- `POST /api/v1/ml/$validate` - Validate model configurations
- `GET /api/v1/configs` - Manage model configurations
- `GET /api/v1/artifacts` - Browse trained models and predictions
- `GET /api/v1/jobs` - Monitor training/prediction jobs
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "chapkit"
version = "0.29.0.dev0"
version = "0.29.0"
description = "ML and data service modules built on servicekit - config, artifacts, and ML workflows"
readme = "README.md"
authors = [{ name = "Morten Hansen", email = "morten@dhis2.org" }]
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading