Minimalist time-series forecasting toolkit for coding agents
Project description
tsagentkit
Minimalist time-series forecasting toolkit for coding agents.
tsagentkit provides:
- a fixed panel data contract
- zero-config TSFM ensemble forecasting
- a small set of pipeline primitives for agent customization
- explicit TSFM model lifecycle control via
ModelCache
For architecture details and design rationale, see docs/DESIGN.md.
Install
pip install tsagentkit
Data Contract
Input data must include these required columns:
unique_id: series identifierds: timestampy: target value
Custom column remapping is not supported. Required columns must be non-null.
import pandas as pd
# Valid input schema (minimal)
raw_df = pd.DataFrame({
"unique_id": ["A"] * 30,
"ds": pd.date_range("2025-01-01", periods=30, freq="D"),
"y": range(30),
})
Quick Start
from tsagentkit import forecast
result = forecast(raw_df, h=7, freq="D")
print(result.df.head())
Standard Pipeline API
from tsagentkit import ForecastConfig, run_forecast
config = ForecastConfig(h=7, freq="D", ensemble_method="median")
result = run_forecast(raw_df, config)
print(result.df.head())
Building-Block Pipeline
from tsagentkit import (
ForecastConfig,
validate,
build_dataset,
make_plan,
fit_all,
predict_all,
ensemble,
)
config = ForecastConfig(h=7, freq="D")
df = validate(raw_df)
dataset = build_dataset(df, config)
models = make_plan(tsfm_only=True)
artifacts = fit_all(models, dataset)
predictions = predict_all(models, artifacts, dataset, h=config.h)
ensemble_df = ensemble(predictions, method=config.ensemble_method, quantiles=config.quantiles)
print(ensemble_df.head())
Performance
tsagentkit runs parallel model fitting and prediction by default. Large panels (>50k rows) automatically use streaming ensemble to reduce memory usage.
# Opt-out if needed (e.g., memory-constrained environments)
result = forecast(raw_df, h=7, parallel_fit=False, parallel_predict=False)
Model Cache Lifecycle
ModelCache manages loaded TSFM instances and avoids expensive reloads.
from tsagentkit import ModelCache, forecast
from tsagentkit.models.registry import REGISTRY
# Optional preload
models = [m for m in REGISTRY.values() if m.is_tsfm]
ModelCache.preload(models)
# Reuses cached models across calls
result = forecast(raw_df, h=7)
# Explicit release
ModelCache.unload() # all models
# ModelCache.unload("chronos") # one model
# Optional inspection
print(ModelCache.list_loaded())
ModelCache.unload() semantics:
- releases all
tsagentkit-owned model references - calls adapter unload hooks when available
- triggers best-effort backend cleanup (
gc.collect, CUDA/MPS cache clear) - cannot reclaim memory still referenced by external user code
Public API
Top-level (from tsagentkit import ...):
forecast,run_forecastForecastConfig,ForecastResult,RunResultTSDataset,CovariateSetvalidate,build_dataset,make_plan,fit_all,predict_all,ensembleModelCacheREGISTRY,ModelSpec,list_modelsLengthAdjustment,adjust_context_length,validate_prediction_lengthget_effective_limits,check_data_compatibilityresolve_devicecheck_healthTSAgentKitError,EContract,ENoTSFM,EInsufficient,ETemporal
Inspection API (from tsagentkit.inspect import ...):
list_modelscheck_health,HealthReport
Errors
Core error types:
EContract: input contract violationsENoTSFM: TSFM registry invariant violation (internal misconfiguration)EInsufficient: not enough successful model outputsETemporal: temporal integrity violations
from tsagentkit import EContract, forecast
try:
result = forecast(raw_df, h=7)
except EContract as e:
print(e.code, e.hint)
raise
Developer Commands
uv sync --all-extras
uv run pytest
uv run mypy src/tsagentkit
uv run ruff format src/
# Real TSFM smoke tests (live adapters)
TSFM_RUN_REAL=1 uv run pytest tests/ci/test_real_tsfm_smoke_gate.py tests/ci/test_standard_pipeline_real_smoke.py
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tsagentkit-2.0.3.tar.gz.
File metadata
- Download URL: tsagentkit-2.0.3.tar.gz
- Upload date:
- Size: 344.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c174a0a5e419e4fa975d9c1c829fa9593de6032d2408b6b168b257f0dd2f53
|
|
| MD5 |
b020489a6bbe25947151e7795061f1ab
|
|
| BLAKE2b-256 |
c6f7eddc30325e0e193b381839a06b908f526ee66770002d3fc690ea2a012e40
|
Provenance
The following attestation bundles were made for tsagentkit-2.0.3.tar.gz:
Publisher:
workflow.yml on LeonEthan/tsagentkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsagentkit-2.0.3.tar.gz -
Subject digest:
39c174a0a5e419e4fa975d9c1c829fa9593de6032d2408b6b168b257f0dd2f53 - Sigstore transparency entry: 972968692
- Sigstore integration time:
-
Permalink:
LeonEthan/tsagentkit@9ba9aa0411babfe9bc26ab77b732708a2d63a20b -
Branch / Tag:
refs/tags/v2.0.3 - Owner: https://github.com/LeonEthan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9ba9aa0411babfe9bc26ab77b732708a2d63a20b -
Trigger Event:
push
-
Statement type:
File details
Details for the file tsagentkit-2.0.3-py3-none-any.whl.
File metadata
- Download URL: tsagentkit-2.0.3-py3-none-any.whl
- Upload date:
- Size: 53.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5752159c43dba5e1db425aa621afcce007baaa89f55ddb93065b483ea6e6bea9
|
|
| MD5 |
f20df7b293437b536a2e45d89017c6f1
|
|
| BLAKE2b-256 |
81cb8321285a3f3f70963193b11fcb304380948d8efd85ef3ec5696148599bb4
|
Provenance
The following attestation bundles were made for tsagentkit-2.0.3-py3-none-any.whl:
Publisher:
workflow.yml on LeonEthan/tsagentkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsagentkit-2.0.3-py3-none-any.whl -
Subject digest:
5752159c43dba5e1db425aa621afcce007baaa89f55ddb93065b483ea6e6bea9 - Sigstore transparency entry: 972968707
- Sigstore integration time:
-
Permalink:
LeonEthan/tsagentkit@9ba9aa0411babfe9bc26ab77b732708a2d63a20b -
Branch / Tag:
refs/tags/v2.0.3 - Owner: https://github.com/LeonEthan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@9ba9aa0411babfe9bc26ab77b732708a2d63a20b -
Trigger Event:
push
-
Statement type: