spamkit-api 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.
Files changed (64) hide show
  1. spamkit_api-0.1.0/.dockerignore +11 -0
  2. spamkit_api-0.1.0/.github/workflows/ci.yml +34 -0
  3. spamkit_api-0.1.0/.gitignore +15 -0
  4. spamkit_api-0.1.0/Dockerfile +36 -0
  5. spamkit_api-0.1.0/LICENSE +661 -0
  6. spamkit_api-0.1.0/PKG-INFO +245 -0
  7. spamkit_api-0.1.0/PRD.md +629 -0
  8. spamkit_api-0.1.0/README.md +223 -0
  9. spamkit_api-0.1.0/THIRD_PARTY_NOTICES.md +14 -0
  10. spamkit_api-0.1.0/bench/eval_public.py +142 -0
  11. spamkit_api-0.1.0/bench/fetch_public_data.py +18 -0
  12. spamkit_api-0.1.0/bench/load_test.py +76 -0
  13. spamkit_api-0.1.0/contract/fixtures.json +73 -0
  14. spamkit_api-0.1.0/dist-site/brand/favicon.svg +7 -0
  15. spamkit_api-0.1.0/dist-site/brand/siftkit-logo-white.svg +7 -0
  16. spamkit_api-0.1.0/dist-site/brand/siftkit-logo.svg +7 -0
  17. spamkit_api-0.1.0/dist-site/brand/siftkit-mark.svg +6 -0
  18. spamkit_api-0.1.0/dist-site/index.html +1414 -0
  19. spamkit_api-0.1.0/docker-compose.yml +18 -0
  20. spamkit_api-0.1.0/docs/BENCHMARKS.md +35 -0
  21. spamkit_api-0.1.0/examples/fastapi-app/main.py +37 -0
  22. spamkit_api-0.1.0/examples/node-server/server.mjs +49 -0
  23. spamkit_api-0.1.0/pyproject.toml +44 -0
  24. spamkit_api-0.1.0/sdk/typescript/LICENSE +661 -0
  25. spamkit_api-0.1.0/sdk/typescript/README.md +54 -0
  26. spamkit_api-0.1.0/sdk/typescript/package-lock.json +1491 -0
  27. spamkit_api-0.1.0/sdk/typescript/package.json +39 -0
  28. spamkit_api-0.1.0/sdk/typescript/src/index.ts +234 -0
  29. spamkit_api-0.1.0/sdk/typescript/test/client.test.ts +120 -0
  30. spamkit_api-0.1.0/sdk/typescript/test/contract.test.ts +56 -0
  31. spamkit_api-0.1.0/sdk/typescript/tsconfig.json +14 -0
  32. spamkit_api-0.1.0/site/brand/favicon.svg +7 -0
  33. spamkit_api-0.1.0/site/brand/siftkit-logo-white.svg +7 -0
  34. spamkit_api-0.1.0/site/brand/siftkit-logo.svg +7 -0
  35. spamkit_api-0.1.0/site/brand/siftkit-mark.svg +6 -0
  36. spamkit_api-0.1.0/site/compare/ember-4k.png +0 -0
  37. spamkit_api-0.1.0/site/compare/forest-4k.png +0 -0
  38. spamkit_api-0.1.0/site/compare/index.html +170 -0
  39. spamkit_api-0.1.0/site/compare/ocean-4k.png +0 -0
  40. spamkit_api-0.1.0/site/compare/plum-4k.png +0 -0
  41. spamkit_api-0.1.0/site/compare/rose-4k.png +0 -0
  42. spamkit_api-0.1.0/site/index.html +1414 -0
  43. spamkit_api-0.1.0/src/spamkit/__init__.py +27 -0
  44. spamkit_api-0.1.0/src/spamkit/app.py +314 -0
  45. spamkit_api-0.1.0/src/spamkit/classifier.py +122 -0
  46. spamkit_api-0.1.0/src/spamkit/cli.py +199 -0
  47. spamkit_api-0.1.0/src/spamkit/client.py +174 -0
  48. spamkit_api-0.1.0/src/spamkit/errors.py +40 -0
  49. spamkit_api-0.1.0/src/spamkit/evaluation.py +180 -0
  50. spamkit_api-0.1.0/src/spamkit/observability.py +86 -0
  51. spamkit_api-0.1.0/src/spamkit/schemas.py +121 -0
  52. spamkit_api-0.1.0/src/spamkit/settings.py +67 -0
  53. spamkit_api-0.1.0/src/spamkit/verdict.py +46 -0
  54. spamkit_api-0.1.0/tests/conftest.py +43 -0
  55. spamkit_api-0.1.0/tests/test_api.py +187 -0
  56. spamkit_api-0.1.0/tests/test_cli.py +43 -0
  57. spamkit_api-0.1.0/tests/test_client.py +110 -0
  58. spamkit_api-0.1.0/tests/test_contract.py +34 -0
  59. spamkit_api-0.1.0/tests/test_evaluation.py +79 -0
  60. spamkit_api-0.1.0/tests/test_model_integration.py +36 -0
  61. spamkit_api-0.1.0/tests/test_robustness.py +140 -0
  62. spamkit_api-0.1.0/tests/test_robustness_real_model.py +86 -0
  63. spamkit_api-0.1.0/tests/test_settings.py +35 -0
  64. spamkit_api-0.1.0/tests/test_verdict.py +29 -0
@@ -0,0 +1,11 @@
1
+ .venv
2
+ .git
3
+ .github
4
+ models
5
+ sdk/typescript/node_modules
6
+ sdk/typescript/dist
7
+ tests
8
+ examples
9
+ **/__pycache__
10
+ **/*.egg-info
11
+ .pytest_cache
@@ -0,0 +1,34 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ python:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-python@v5
13
+ with:
14
+ python-version: "3.12"
15
+ - name: Install CPU torch and package
16
+ run: |
17
+ pip install --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple "torch>=2.2"
18
+ pip install -e ".[server,dev]"
19
+ # Model integration tests skip unless the model was fetched; the rest run without it.
20
+ - run: pytest -q
21
+
22
+ typescript:
23
+ runs-on: ubuntu-latest
24
+ defaults:
25
+ run:
26
+ working-directory: sdk/typescript
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-node@v4
30
+ with:
31
+ node-version: "22"
32
+ - run: npm ci
33
+ - run: npm run typecheck
34
+ - run: npm test
@@ -0,0 +1,15 @@
1
+ .venv/
2
+ models/
3
+ __pycache__/
4
+ *.egg-info/
5
+ .pytest_cache/
6
+ sdk/typescript/node_modules/
7
+ sdk/typescript/dist/
8
+ .env
9
+ data/
10
+
11
+ # wrangler files
12
+ .wrangler
13
+ .dev.vars*
14
+ !.dev.vars.example
15
+ !.env.example
@@ -0,0 +1,36 @@
1
+ # Single-node CPU image. The model is fetched at build time at a pinned revision,
2
+ # so the running container makes no network calls.
3
+ FROM python:3.12-slim-bookworm
4
+
5
+ ENV PYTHONDONTWRITEBYTECODE=1 \
6
+ PYTHONUNBUFFERED=1 \
7
+ PIP_NO_CACHE_DIR=1 \
8
+ XDG_CACHE_HOME=/tmp
9
+
10
+ RUN useradd --create-home --uid 10001 spamkit
11
+
12
+ WORKDIR /app
13
+
14
+ # CPU-only torch keeps the image small; the server extra then finds torch already satisfied.
15
+ RUN pip install --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple "torch>=2.2"
16
+
17
+ COPY pyproject.toml README.md THIRD_PARTY_NOTICES.md ./
18
+ COPY src ./src
19
+ RUN pip install ".[server]"
20
+
21
+ RUN spamkit fetch-model --dest /opt/models/spamton \
22
+ && cp /app/THIRD_PARTY_NOTICES.md /opt/models/THIRD_PARTY_NOTICES.md
23
+
24
+ ENV SPAMKIT_MODEL_DIR=/opt/models/spamton \
25
+ SPAMKIT_HOST=0.0.0.0 \
26
+ SPAMKIT_PORT=8080 \
27
+ HF_HUB_OFFLINE=1 \
28
+ TRANSFORMERS_OFFLINE=1
29
+
30
+ USER spamkit
31
+ EXPOSE 8080
32
+
33
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
34
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/readyz', timeout=4)"
35
+
36
+ CMD ["spamkit", "serve"]