sinapsis-infra 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 (74) hide show
  1. sinapsis_infra-0.1.0/.github/workflows/ci.yml +57 -0
  2. sinapsis_infra-0.1.0/.gitignore +7 -0
  3. sinapsis_infra-0.1.0/CONTRIBUTING.md +287 -0
  4. sinapsis_infra-0.1.0/PKG-INFO +555 -0
  5. sinapsis_infra-0.1.0/README.md +537 -0
  6. sinapsis_infra-0.1.0/examples/bank-reconciliation/Dockerfile +11 -0
  7. sinapsis_infra-0.1.0/examples/bank-reconciliation/pyproject.toml +13 -0
  8. sinapsis_infra-0.1.0/examples/base-extension/Dockerfile +7 -0
  9. sinapsis_infra-0.1.0/examples/base-extension/app.py +7 -0
  10. sinapsis_infra-0.1.0/examples/metadata/easyocr/pyproject.toml +12 -0
  11. sinapsis_infra-0.1.0/examples/pyproject.toml +26 -0
  12. sinapsis_infra-0.1.0/examples/schema2/applications/bank-reconciliation/pyproject.toml +36 -0
  13. sinapsis_infra-0.1.0/examples/schema2/catalog.json +25 -0
  14. sinapsis_infra-0.1.0/examples/schema2/packages/python/sinapsis-chatbots/pyproject.toml +26 -0
  15. sinapsis_infra-0.1.0/pyproject.toml +114 -0
  16. sinapsis_infra-0.1.0/scripts/acceptance.py +127 -0
  17. sinapsis_infra-0.1.0/scripts/generate_catalog.py +20 -0
  18. sinapsis_infra-0.1.0/src/sinapsis_infra/__init__.py +1 -0
  19. sinapsis_infra-0.1.0/src/sinapsis_infra/__main__.py +6 -0
  20. sinapsis_infra-0.1.0/src/sinapsis_infra/cli.py +361 -0
  21. sinapsis_infra-0.1.0/src/sinapsis_infra/core/__init__.py +1 -0
  22. sinapsis_infra-0.1.0/src/sinapsis_infra/core/commands.py +76 -0
  23. sinapsis_infra-0.1.0/src/sinapsis_infra/core/constants.py +29 -0
  24. sinapsis_infra-0.1.0/src/sinapsis_infra/core/errors.py +21 -0
  25. sinapsis_infra-0.1.0/src/sinapsis_infra/core/models.py +195 -0
  26. sinapsis_infra-0.1.0/src/sinapsis_infra/hardware/__init__.py +1 -0
  27. sinapsis_infra-0.1.0/src/sinapsis_infra/hardware/cuda-policy.toml +38 -0
  28. sinapsis_infra-0.1.0/src/sinapsis_infra/hardware/cuda.py +168 -0
  29. sinapsis_infra-0.1.0/src/sinapsis_infra/hardware/detection.py +238 -0
  30. sinapsis_infra-0.1.0/src/sinapsis_infra/projects/__init__.py +1 -0
  31. sinapsis_infra-0.1.0/src/sinapsis_infra/projects/application.py +107 -0
  32. sinapsis_infra-0.1.0/src/sinapsis_infra/projects/discovery.py +218 -0
  33. sinapsis_infra-0.1.0/src/sinapsis_infra/projects/examples.py +272 -0
  34. sinapsis_infra-0.1.0/src/sinapsis_infra/projects/metadata.py +126 -0
  35. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/__init__.py +1 -0
  36. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/backends/__init__.py +1 -0
  37. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/backends/dispatch.py +28 -0
  38. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/backends/docker.py +209 -0
  39. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/backends/docker_sdk.py +279 -0
  40. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/backends/venv.py +124 -0
  41. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/execution.py +52 -0
  42. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/manager.py +55 -0
  43. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/planner.py +664 -0
  44. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/recipes.py +220 -0
  45. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/resolution.py +294 -0
  46. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/storage.py +245 -0
  47. sinapsis_infra-0.1.0/src/sinapsis_infra/provisioning/verification.py +342 -0
  48. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/__init__.py +1 -0
  49. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/environment.py +20 -0
  50. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/__init__.py +1 -0
  51. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/bindings.py +322 -0
  52. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/cli.py +47 -0
  53. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/native.py +279 -0
  54. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/provider.py +61 -0
  55. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/llama_cpp/verification.py +33 -0
  56. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/media.py +32 -0
  57. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/providers.py +156 -0
  58. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/registry.py +50 -0
  59. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/spec.py +25 -0
  60. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/tensorrt.py +37 -0
  61. sinapsis_infra-0.1.0/src/sinapsis_infra/runtimes/torch.py +32 -0
  62. sinapsis_infra-0.1.0/tests/test_application_discovery.py +221 -0
  63. sinapsis_infra-0.1.0/tests/test_backends.py +106 -0
  64. sinapsis_infra-0.1.0/tests/test_binding_installer.py +145 -0
  65. sinapsis_infra-0.1.0/tests/test_cuda_profiles.py +332 -0
  66. sinapsis_infra-0.1.0/tests/test_docker_sdk.py +169 -0
  67. sinapsis_infra-0.1.0/tests/test_m4_integration.py +91 -0
  68. sinapsis_infra-0.1.0/tests/test_m4_profiles.py +203 -0
  69. sinapsis_infra-0.1.0/tests/test_native_integration.py +25 -0
  70. sinapsis_infra-0.1.0/tests/test_planner.py +131 -0
  71. sinapsis_infra-0.1.0/tests/test_recipe_ownership.py +64 -0
  72. sinapsis_infra-0.1.0/tests/test_runtime_registry.py +61 -0
  73. sinapsis_infra-0.1.0/tests/test_storage_metadata.py +97 -0
  74. sinapsis_infra-0.1.0/uv.lock +336 -0
@@ -0,0 +1,57 @@
1
+ name: Infrastructure CI
2
+ on:
3
+ push:
4
+ pull_request:
5
+ permissions:
6
+ contents: read
7
+ jobs:
8
+ tests:
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os: [ubuntu-latest, macos-latest, windows-latest]
13
+ runs-on: ${{ matrix.os }}
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: '3.13'
19
+ - uses: astral-sh/setup-uv@v6
20
+ with:
21
+ version: '0.10.0'
22
+ - run: uv sync --group dev --python 3.13
23
+ - run: uv run pytest -q
24
+ static-analysis:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: actions/setup-python@v5
29
+ with:
30
+ python-version: '3.13'
31
+ - uses: astral-sh/setup-uv@v6
32
+ with:
33
+ version: '0.10.0'
34
+ - run: uv sync --group dev --python 3.13
35
+ - run: uv run ruff check .
36
+ - run: uv run ruff format --check .
37
+ - run: uv run pyright
38
+ docker-smoke:
39
+ runs-on: ubuntu-latest
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+ - uses: actions/setup-python@v5
43
+ with:
44
+ python-version: '3.13'
45
+ - uses: astral-sh/setup-uv@v6
46
+ with:
47
+ version: '0.10.0'
48
+ - uses: docker/setup-buildx-action@v3
49
+ - run: uv sync --no-dev --python 3.13
50
+ - run: uv run sinx-infra provision --backend=docker --acceleration=cpu --name=ci
51
+ - run: uv run sinx-infra verify ci
52
+ - run: uv run sinx-infra provision --backend=docker --acceleration=cpu --name=ci --no-build
53
+ - shell: bash
54
+ run: |
55
+ BASE=$(uv run sinx-infra inspect ci --format=json | python -c 'import json,sys; print(json.load(sys.stdin)["artifact"])')
56
+ docker buildx build --load --build-arg SINX_BASE_IMAGE="$BASE" -t sinx-ci-demo examples/base-extension
57
+ docker run --rm sinx-ci-demo
@@ -0,0 +1,7 @@
1
+ .venv/
2
+ __pycache__/
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ *.egg-info/
6
+ /dist/
7
+ /build/
@@ -0,0 +1,287 @@
1
+ # Contributing to Sinapsis Infra
2
+
3
+ This guide covers local development, source organisation, runtime extensions,
4
+ code quality, testing and release validation. For installation and usage, see the
5
+ [README](README.md).
6
+
7
+ <p align="center">
8
+ <a href="#development-setup">Development Setup</a> &bull;
9
+ <a href="#architecture">Architecture</a> &bull;
10
+ <a href="#extending-sinapsis-infra">Extending Infra</a> &bull;
11
+ <a href="#code-quality">Code Quality</a> &bull;
12
+ <a href="#testing">Testing</a> &bull;
13
+ <a href="#release-process">Release</a> &bull;
14
+ <a href="#license">License</a>
15
+ </p>
16
+
17
+ ## Development setup
18
+
19
+ From a repository checkout, install Python 3.13 and uv, then run:
20
+
21
+ ```sh
22
+ uv sync --group dev --python 3.13
23
+ uv run sinx-infra doctor
24
+ ```
25
+
26
+ ## Architecture
27
+
28
+ ### Directory structure and dependency boundaries
29
+
30
+ `sinapsis-infra` has two deliberately separate execution paths: `install` modifies
31
+ an existing unmanaged venv, while `plan` and `provision` create reproducible,
32
+ managed environments. Both reuse common hardware detection and runtime policy.
33
+
34
+ ```text
35
+ src/sinapsis_infra/
36
+ ├── __init__.py
37
+ ├── __main__.py
38
+ ├── cli.py # top-level argument parsing and dispatch
39
+ ├── core/
40
+ │ ├── commands.py # runner protocol and subprocess execution
41
+ │ ├── constants.py
42
+ │ ├── errors.py
43
+ │ └── models.py # shared requests, plans, hardware and capabilities
44
+ ├── hardware/
45
+ │ ├── detection.py # platform, GPU, Python and Docker probes
46
+ │ ├── cuda.py # compatibility and CUDA family selection
47
+ │ └── cuda-policy.toml # packaged, curated compatibility matrix
48
+ ├── projects/
49
+ │ ├── application.py # application and service coordination
50
+ │ ├── discovery.py # local projects and remote catalog
51
+ │ ├── examples.py # example and variant declarations
52
+ │ └── metadata.py # package metadata parsing
53
+ ├── provisioning/
54
+ │ ├── manager.py # provisioning orchestration
55
+ │ ├── planner.py # resolve immutable plans
56
+ │ ├── resolution.py # requirements and locks
57
+ │ ├── recipes.py # build recipes and constraints
58
+ │ ├── verification.py # managed profile verification orchestration
59
+ │ ├── storage.py # state, persistence and locks
60
+ │ ├── execution.py # run commands inside ready profiles
61
+ │ └── backends/
62
+ │ ├── docker.py # build, cache and verify Docker images
63
+ │ ├── docker_sdk.py # Docker SDK adapter
64
+ │ ├── venv.py # create and verify native environments
65
+ │ └── dispatch.py # backend verification selection
66
+ └── runtimes/
67
+ ├── registry.py # explicit in-place installer registry
68
+ ├── environment.py # unmanaged venv ownership guard
69
+ ├── spec.py # shared managed provider contract
70
+ ├── providers.py # managed provider composition and acceleration policy
71
+ ├── torch.py # PyTorch distribution policy
72
+ ├── tensorrt.py # TensorRT distribution policy
73
+ ├── media.py # ONNX and media/system libraries
74
+ └── llama_cpp/
75
+ ├── bindings.py # in-place Python bindings candidate selection/install
76
+ ├── native.py # native server release resolution/build
77
+ ├── provider.py # managed bindings/server requirements and CMake settings
78
+ ├── verification.py # shared bindings and native server probes
79
+ └── cli.py # bindings-specific arguments and adapter
80
+ ```
81
+
82
+ Each directory is a Python package. The tree omits repetitive `__init__.py` files.
83
+ `core` must remain independent of higher-level packages. `hardware` uses core
84
+ contracts. Runtime modules reuse these two layers, without requiring the managed
85
+ provisioning implementation. Managed provisioning consumes runtime policies and
86
+ probes; projects coordinate managed provisioning. The top-level CLI composes
87
+ these responsibilities.
88
+
89
+ ### Module ownership
90
+
91
+ | Change | Owner |
92
+ | --- | --- |
93
+ | New CUDA family or compute compatibility | `hardware/cuda-policy.toml`, `hardware/cuda.py` |
94
+ | New hardware detection | `hardware/detection.py` and, if needed, `core/models.py` |
95
+ | New llama.cpp binding wheel, source flags or installation behavior | `runtimes/llama_cpp/bindings.py`, `provider.py` |
96
+ | New llama.cpp native release format | `runtimes/llama_cpp/native.py` |
97
+ | llama.cpp verification | `runtimes/llama_cpp/verification.py` |
98
+ | New runtime installation target | New package under `runtimes/`, one entry in `runtimes/registry.py` |
99
+ | Docker or venv behavior | `provisioning/backends/` |
100
+ | Managed requirements, recipes or profile identity | `provisioning/` and relevant runtime provider |
101
+ | Example declarations or catalog discovery | `projects/` |
102
+
103
+ ### Provisioning lifecycle
104
+
105
+ - `install` detects the host, selects runtime candidates and installs into an
106
+ existing unmanaged Python environment. Runtime-specific checks determine
107
+ whether the installation is usable. Do not modify system Python or a managed
108
+ profile through this workflow.
109
+ - `plan` resolves requested capabilities, compatibility policies and dependencies
110
+ into a managed plan. `provision` creates or reuses a Docker image or virtual
111
+ environment and verifies it before registering a ready profile.
112
+ - Project metadata and service definitions coordinate application provisioning;
113
+ service installation is separate from service startup.
114
+
115
+ Keep runtime selection and checks independent of backend execution and managed
116
+ state. See `provisioning/manager.py`, `planner.py` and `storage.py` for the managed
117
+ workflow, and `runtimes/registry.py` for in-place installer dispatch.
118
+
119
+ ## Extending Sinapsis Infra
120
+
121
+ ### Adding an in-place runtime installer
122
+
123
+ 1. Create `runtimes/<runtime>/` with `__init__.py`, implementation and CLI adapter.
124
+ Keep external downloads, versions, package constraints and runtime-specific
125
+ verification inside that package. Reuse `core.commands.Runner`, hardware
126
+ detection and applicable accelerator policies. Use the shared environment
127
+ guard before modifying an existing Python environment.
128
+ 2. Provide a `configure_parser(parser)` function for runtime-specific arguments,
129
+ and an `execute_install(args, runner, host)` function returning a JSON-compatible
130
+ `dict[str, object]`. Use `InfraError` subclasses for operational failures.
131
+ 3. Register it in `runtimes/registry.py` using `Installer(help, configure, execute)`.
132
+ The main CLI automatically discovers its subcommand and options from this explicit
133
+ registry. No runtime-specific changes to the top-level parser/dispatcher are needed.
134
+ 4. Add tests with an injected fake runner and hardware snapshots. Cover dry-run,
135
+ unsupported hardware, candidate order, failures and verification. Dry-run must not
136
+ install packages, create services or modify state.
137
+
138
+ For example, once implemented, an Ollama adapter would be registered as:
139
+
140
+ ```python
141
+ from sinapsis_infra.runtimes.ollama import cli as ollama_cli
142
+
143
+ # Add to the existing INSTALLERS mapping:
144
+ "ollama": Installer(
145
+ "Install Ollama",
146
+ ollama_cli.configure_parser,
147
+ ollama_cli.execute_install,
148
+ ),
149
+ ```
150
+
151
+ This illustrative entry is not registered today. Do not import an unimplemented
152
+ provider. Ollama may require native service management; vLLM may require pinned
153
+ Python/CUDA/PyTorch combinations. Their implementation should not be forced into
154
+ llama.cpp-specific assumptions. The registry governs CLI dispatch, not a universal
155
+ installation strategy.
156
+
157
+ Installer-specific flags follow the runtime name. Inspect the registered commands
158
+ with `sinx-infra install --help` and runtime options with
159
+ `sinx-infra install llama-cpp-python --help`.
160
+
161
+ ### Adding a managed runtime provider
162
+
163
+ If a new runtime must
164
+ also be supported by `plan`/`provision`, add an appropriate capability in
165
+ `core/models.py`, provider spec and verification, then integrate with
166
+ `runtimes/providers.py`, managed resolution, recipes and backend handling as needed.
167
+ These existing managed paths still contain capability-specific orchestration
168
+ (e.g. llama.cpp native artifacts); the in-place registry does not automatically
169
+ register a managed provider. Do not add speculative capability enums or stubs before
170
+ an actual provider is implemented.
171
+
172
+ ### Adding a provisioning backend
173
+
174
+ Use `provisioning/backends/` for backend-specific build, execution and verification
175
+ logic. Review the shared backend models, planner, recipes, dispatch, storage and
176
+ verification contracts when adding a backend. The current Docker and venv
177
+ implementations provide examples; a new backend requires managed workflow
178
+ integration, not just a registry entry for an in-place installer.
179
+
180
+ ### Updating CUDA compatibility policies
181
+
182
+ Keep CUDA family definitions and provider availability in
183
+ `hardware/cuda-policy.toml`, and compatibility logic in `hardware/cuda.py`.
184
+ The policy is distributed as package data. Review upstream references in the
185
+ [README](README.md#upstream-compatibility-references), verify actual artifacts,
186
+ and test driver and GPU architecture boundaries before changing candidates.
187
+ Do not assume that every upstream CUDA family is supported by every provider.
188
+
189
+ ### Runtime verification
190
+
191
+ Keep runtime-specific checks with the runtime implementation. Managed profile
192
+ verification belongs in `provisioning/verification.py` and the corresponding
193
+ backend. Distinguish package import and device capability checks from actual
194
+ model-level inference. Cover failed checks and fallback behaviour in tests.
195
+
196
+ ## Code quality
197
+
198
+ The project uses Ruff with Google-style docstrings and strict Pyright checking.
199
+ Follow the configuration in `pyproject.toml` and use typed interfaces for shared
200
+ contracts. Keep runtime-specific dependencies and behaviour in their owning
201
+ modules; prefer injected runners and hardware snapshots in tests.
202
+
203
+ ```sh
204
+ uv run ruff check .
205
+ uv run pyright
206
+ ```
207
+
208
+ ## Testing
209
+
210
+ ### Unit and mocked integration tests
211
+
212
+ ```sh
213
+ uv run pytest -q
214
+ ```
215
+
216
+ ### Native integration tests
217
+
218
+ The native integration tests require uv on PATH and a compatible Python interpreter.
219
+ They exercise managed profile creation, reuse and dependency resolution, including
220
+ synthetic local wheel fixtures. Run them separately when working on provisioning:
221
+
222
+ ```sh
223
+ uv run pytest -q tests/test_native_integration.py tests/test_m4_integration.py
224
+ ```
225
+
226
+ ### Full acceptance suite
227
+
228
+ Run the following commands on hosts with the corresponding hardware, drivers
229
+ and toolchains. Docker cases also require a running Docker daemon with GPU
230
+ access where applicable. These commands may download large dependencies and
231
+ build images or environments.
232
+
233
+ ```sh
234
+ uv run python scripts/acceptance.py --backend=docker --acceleration=cuda --allow-source-build --apps
235
+ uv run python scripts/acceptance.py --backend=venv --acceleration=apple --allow-source-build --apps
236
+ uv run python scripts/acceptance.py --backend=venv --acceleration=cpu
237
+ ```
238
+
239
+ The acceptance script continues across profiles, reports failures and exits
240
+ nonzero if any fail. `--case NAME` selects individual cases. `--apps` is opt-in
241
+ because real ML packages can be large. Separate case profiles isolate independent
242
+ acceptance tests; the combined Torch/TRT profile is a single environment.
243
+
244
+ The suite exercises managed provisioning. Test the in-place installer separately
245
+ in a disposable virtual environment on the relevant hardware; do not assume a
246
+ successful managed profile validates the in-place installation path.
247
+
248
+ ## Release process
249
+
250
+ ### Release validation
251
+
252
+ Before publishing, record the results of real Docker daemon integration,
253
+ GPU execution, native Windows/macOS checks and live upstream dependency
254
+ resolution on relevant hosts. Unit tests and mocked transport tests are not
255
+ substitutes for hardware acceptance tests. Review redistribution obligations
256
+ and third-party licensing before release.
257
+
258
+ For the first public release, confirm the version is `0.1.0`, the intended
259
+ MIT/Apache-2.0 license metadata and both license files are present, and the
260
+ README and examples reflect the supported public configuration. Check that the
261
+ wheel contains the packaged CUDA policy resource and exposes the `sinx-infra`
262
+ console entry point.
263
+
264
+ ### Building distributions
265
+
266
+ From a clean checkout with the release metadata in place:
267
+
268
+ ```sh
269
+ uv build
270
+ ```
271
+
272
+ Test the built wheel in a clean Python 3.13 virtual environment before publishing.
273
+ Verify `sinx-infra --help`, `sinx-infra doctor`, and
274
+ `sinx-infra install llama-cpp-python --help` using the installed package, rather than
275
+ relying solely on imports from the source tree.
276
+
277
+ ### Publishing
278
+
279
+ After release validation and approval, publish the intended distributions using
280
+ the project's configured PyPI publishing workflow. For a manual release with
281
+ appropriate credentials, `uv publish` uploads the built distributions. Ensure the
282
+ package name, version and artifacts are correct before uploading.
283
+
284
+ ## License
285
+
286
+ Contributions are made to the project under its documented licensing terms.
287
+ See [License](README.md#license) in the README.