opencomb 0.2.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.
- opencomb-0.2.0/.gitignore +52 -0
- opencomb-0.2.0/LICENSE +21 -0
- opencomb-0.2.0/PKG-INFO +253 -0
- opencomb-0.2.0/README.md +214 -0
- opencomb-0.2.0/examples/sample_recipe.yaml +22 -0
- opencomb-0.2.0/pyproject.toml +96 -0
- opencomb-0.2.0/src/opencomb/__init__.py +23 -0
- opencomb-0.2.0/src/opencomb/cli.py +323 -0
- opencomb-0.2.0/src/opencomb/combinatorial.py +169 -0
- opencomb-0.2.0/src/opencomb/combiner.py +232 -0
- opencomb-0.2.0/src/opencomb/prompt.py +149 -0
- opencomb-0.2.0/src/opencomb/recipe.py +165 -0
- opencomb-0.2.0/src/opencomb/template.py +68 -0
- opencomb-0.2.0/tests/test_combinatorial.py +51 -0
- opencomb-0.2.0/tests/test_combiner.py +76 -0
- opencomb-0.2.0/tests/test_prompt.py +41 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Byte-compiled / cache
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# Distribution / packaging
|
|
8
|
+
.Python
|
|
9
|
+
build/
|
|
10
|
+
develop-eggs/
|
|
11
|
+
dist/
|
|
12
|
+
downloads/
|
|
13
|
+
eggs/
|
|
14
|
+
.eggs/
|
|
15
|
+
lib/
|
|
16
|
+
lib64/
|
|
17
|
+
parts/
|
|
18
|
+
sdist/
|
|
19
|
+
var/
|
|
20
|
+
wheels/
|
|
21
|
+
*.egg-info/
|
|
22
|
+
.installed.cfg
|
|
23
|
+
*.egg
|
|
24
|
+
MANIFEST
|
|
25
|
+
|
|
26
|
+
# Virtual environments
|
|
27
|
+
.venv/
|
|
28
|
+
venv/
|
|
29
|
+
ENV/
|
|
30
|
+
env/
|
|
31
|
+
|
|
32
|
+
# Testing / coverage
|
|
33
|
+
.coverage
|
|
34
|
+
htmlcov/
|
|
35
|
+
.pytest_cache/
|
|
36
|
+
.mypy_cache/
|
|
37
|
+
.ruff_cache/
|
|
38
|
+
.tox/
|
|
39
|
+
|
|
40
|
+
# IDE
|
|
41
|
+
.idea/
|
|
42
|
+
.vscode/
|
|
43
|
+
*.swp
|
|
44
|
+
*.swo
|
|
45
|
+
|
|
46
|
+
# OS
|
|
47
|
+
.DS_Store
|
|
48
|
+
Thumbs.db
|
|
49
|
+
|
|
50
|
+
# Local
|
|
51
|
+
*.local
|
|
52
|
+
.env
|
opencomb-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DarkFox Co. / SlabyLol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
opencomb-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: opencomb
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: OpenComb – Smart Combiner for Code, Configs, Prompts, Templates, Recipes & Combinatorial Generation
|
|
5
|
+
Project-URL: Homepage, https://github.com/SlabyLol/OpenComb
|
|
6
|
+
Project-URL: Repository, https://github.com/SlabyLol/OpenComb
|
|
7
|
+
Project-URL: Issues, https://github.com/SlabyLol/OpenComb/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/SlabyLol/OpenComb#readme
|
|
9
|
+
Author-email: "DarkFox Co." <darkfox-to@proton.me>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: cli,code-generation,combinatorial,combiner,config-merge,jinja2,opencomb,prompts,recipes,templates,testing
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: click>=8.0.0
|
|
27
|
+
Requires-Dist: jinja2>=3.1.0
|
|
28
|
+
Requires-Dist: pyyaml>=6.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
31
|
+
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
32
|
+
Requires-Dist: typer>=0.12.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: mypy>=1.10.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.5.0; extra == 'dev'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# OpenComb
|
|
41
|
+
|
|
42
|
+
**Smart Combiner for Code, Configs, Prompts, Templates, Recipes & Combinatorial Generation**
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/opencomb/)
|
|
45
|
+
[](https://pypi.org/project/opencomb/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
[](https://github.com/SlabyLol/OpenComb/actions/workflows/ci.yml)
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<img src="docs/logo.svg" alt="OpenComb Logo" width="160"/>
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
**OpenComb** is a powerful, practical toolkit for developers that helps you:
|
|
54
|
+
|
|
55
|
+
- **Combine** multiple Python source files into one clean module (with smart import deduplication)
|
|
56
|
+
- **Merge** YAML, JSON and TOML configs intelligently (deep or shallow)
|
|
57
|
+
- **Generate** combinatorial parameter sets (cartesian, pairwise testing, sampling)
|
|
58
|
+
- **Build** structured LLM prompts from system / instruction / context / few-shot / user parts
|
|
59
|
+
- **Render** Jinja2 templates (single or multi-file)
|
|
60
|
+
- **Run declarative recipes** that orchestrate all of the above in one YAML file
|
|
61
|
+
|
|
62
|
+
Perfect for rapid prototyping, test matrix generation, config management, AI/prompt engineering and automation pipelines.
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install opencomb
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Or with uv:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
uv add opencomb
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Features at a Glance
|
|
77
|
+
|
|
78
|
+
| Feature | CLI Command | Library Class | Description |
|
|
79
|
+
|----------------------|-----------------|--------------------------|--------------------------------------------------|
|
|
80
|
+
| Code Combining | `combine` | `CodeCombiner` | Merge Python files + import dedupe |
|
|
81
|
+
| Config Merging | `merge` | `ConfigMerger` | Deep / shallow YAML·JSON·TOML |
|
|
82
|
+
| Combinatorial Gen | `generate` | `CombinatorialGenerator` | Cartesian · Pairwise · Sample |
|
|
83
|
+
| Prompt Building | `prompt` | `PromptCombiner` | Structured LLM prompts |
|
|
84
|
+
| Template Rendering | `template` | `TemplateRenderer` | Jinja2 power |
|
|
85
|
+
| Recipe Runner | `recipe` | `RecipeRunner` | Full pipelines in one YAML |
|
|
86
|
+
|
|
87
|
+
## Quick Start – CLI
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Combine Python files
|
|
91
|
+
opencomb combine module_a.py module_b.py utils.py -o combined.py
|
|
92
|
+
|
|
93
|
+
# Merge configs (later files win)
|
|
94
|
+
opencomb merge base.yaml local.yaml secrets.toml -o final.yaml
|
|
95
|
+
|
|
96
|
+
# Generate combinations
|
|
97
|
+
opencomb generate -p params.yaml --method pairwise --report
|
|
98
|
+
|
|
99
|
+
# Build an LLM prompt
|
|
100
|
+
opencomb prompt \
|
|
101
|
+
--system system.txt \
|
|
102
|
+
--instruction task.txt \
|
|
103
|
+
--examples fewshot.yaml \
|
|
104
|
+
--user query.txt \
|
|
105
|
+
-o final_prompt.txt
|
|
106
|
+
|
|
107
|
+
# Render Jinja2 templates
|
|
108
|
+
opencomb template template.j2 --data data.yaml -o output.md
|
|
109
|
+
|
|
110
|
+
# Run a full recipe
|
|
111
|
+
opencomb recipe examples/sample_recipe.yaml
|
|
112
|
+
opencomb recipe examples/sample_recipe.yaml --dry-run --verbose
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Quick Start – Library
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from opencomb import (
|
|
119
|
+
CodeCombiner,
|
|
120
|
+
ConfigMerger,
|
|
121
|
+
CombinatorialGenerator,
|
|
122
|
+
PromptCombiner,
|
|
123
|
+
TemplateRenderer,
|
|
124
|
+
RecipeRunner,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Code
|
|
128
|
+
combiner = CodeCombiner()
|
|
129
|
+
code = combiner.combine_files(["a.py", "b.py"])
|
|
130
|
+
|
|
131
|
+
# Config
|
|
132
|
+
merger = ConfigMerger()
|
|
133
|
+
config = merger.merge_files(["base.yaml", "override.yaml"])
|
|
134
|
+
merger.save(config, "result.yaml")
|
|
135
|
+
|
|
136
|
+
# Combinations
|
|
137
|
+
gen = CombinatorialGenerator(seed=42)
|
|
138
|
+
params = {"lr": [0.001, 0.01], "batch": [16, 32], "opt": ["adam", "sgd"]}
|
|
139
|
+
all_combos = gen.cartesian(params)
|
|
140
|
+
pairwise = gen.pairwise(params) # much smaller & efficient
|
|
141
|
+
|
|
142
|
+
# Prompts
|
|
143
|
+
pc = PromptCombiner()
|
|
144
|
+
prompt = pc.combine(
|
|
145
|
+
system="You are a senior Python engineer.",
|
|
146
|
+
instruction="Review the following code.",
|
|
147
|
+
examples=[{"input": "x=1", "output": "Looks fine."}],
|
|
148
|
+
user="def foo(): pass",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Templates
|
|
152
|
+
renderer = TemplateRenderer()
|
|
153
|
+
html = renderer.render_string("<h1>{{ title }}</h1>", title="OpenComb")
|
|
154
|
+
|
|
155
|
+
# Recipes
|
|
156
|
+
runner = RecipeRunner()
|
|
157
|
+
results = runner.run("my_recipe.yaml")
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Recipe Example
|
|
161
|
+
|
|
162
|
+
```yaml
|
|
163
|
+
# my_pipeline.yaml
|
|
164
|
+
name: full-pipeline
|
|
165
|
+
|
|
166
|
+
combine:
|
|
167
|
+
files: [src/a.py, src/b.py, src/utils.py]
|
|
168
|
+
output: build/combined.py
|
|
169
|
+
|
|
170
|
+
merge:
|
|
171
|
+
files: [config/base.yaml, config/prod.yaml]
|
|
172
|
+
output: build/config.yaml
|
|
173
|
+
strategy: deep
|
|
174
|
+
|
|
175
|
+
generate:
|
|
176
|
+
method: pairwise
|
|
177
|
+
params:
|
|
178
|
+
python: ["3.10", "3.11", "3.12"]
|
|
179
|
+
os: ["linux", "macos", "windows"]
|
|
180
|
+
output: build/matrix.jsonl
|
|
181
|
+
seed: 42
|
|
182
|
+
|
|
183
|
+
prompt:
|
|
184
|
+
system: |
|
|
185
|
+
You are an expert code reviewer.
|
|
186
|
+
instruction: |
|
|
187
|
+
Review the combined module and suggest improvements.
|
|
188
|
+
output: build/review_prompt.txt
|
|
189
|
+
|
|
190
|
+
template:
|
|
191
|
+
file: templates/report.md.j2
|
|
192
|
+
data:
|
|
193
|
+
project: OpenComb
|
|
194
|
+
version: "0.2.0"
|
|
195
|
+
output: build/report.md
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
opencomb recipe my_pipeline.yaml
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Publishing to PyPI
|
|
203
|
+
|
|
204
|
+
This repository includes ready-to-use GitHub Actions:
|
|
205
|
+
|
|
206
|
+
- **CI** (`.github/workflows/ci.yml`) – runs tests on Python 3.10–3.13 + builds the package
|
|
207
|
+
- **Publish** (`.github/workflows/publish.yml`) – publishes to PyPI when you create a GitHub Release
|
|
208
|
+
|
|
209
|
+
### How to release
|
|
210
|
+
|
|
211
|
+
1. Make sure the version in `pyproject.toml` is correct (currently `0.2.0`)
|
|
212
|
+
2. Create a new GitHub Release (or tag):
|
|
213
|
+
```bash
|
|
214
|
+
git tag v0.2.0
|
|
215
|
+
git push origin v0.2.0
|
|
216
|
+
```
|
|
217
|
+
Then create a Release on GitHub from that tag.
|
|
218
|
+
3. The `publish.yml` workflow will automatically build and upload to PyPI.
|
|
219
|
+
|
|
220
|
+
### Trusted Publishing (recommended)
|
|
221
|
+
|
|
222
|
+
1. Go to https://pypi.org/manage/account/publishing/
|
|
223
|
+
2. Add a new pending publisher:
|
|
224
|
+
- **PyPI Project Name**: `opencomb`
|
|
225
|
+
- **Owner**: `SlabyLol`
|
|
226
|
+
- **Repository name**: `OpenComb`
|
|
227
|
+
- **Workflow name**: `publish.yml`
|
|
228
|
+
- **Environment name**: `pypi`
|
|
229
|
+
3. Create the project on PyPI if it doesn’t exist yet (first upload will create it).
|
|
230
|
+
|
|
231
|
+
Alternatively you can use a classic API token:
|
|
232
|
+
- Create a token on PyPI → add it as repository secret `PYPI_TOKEN`
|
|
233
|
+
- Uncomment the token-based step in `publish.yml`
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
git clone https://github.com/SlabyLol/OpenComb.git
|
|
239
|
+
cd OpenComb
|
|
240
|
+
pip install -e ".[dev]"
|
|
241
|
+
pytest
|
|
242
|
+
ruff check src tests
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT © DarkFox Co. / SlabyLol
|
|
248
|
+
|
|
249
|
+
## Links
|
|
250
|
+
|
|
251
|
+
- **Repository**: https://github.com/SlabyLol/OpenComb
|
|
252
|
+
- **Issues**: https://github.com/SlabyLol/OpenComb/issues
|
|
253
|
+
- **PyPI**: https://pypi.org/project/opencomb/
|
opencomb-0.2.0/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# OpenComb
|
|
2
|
+
|
|
3
|
+
**Smart Combiner for Code, Configs, Prompts, Templates, Recipes & Combinatorial Generation**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/opencomb/)
|
|
6
|
+
[](https://pypi.org/project/opencomb/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://github.com/SlabyLol/OpenComb/actions/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<img src="docs/logo.svg" alt="OpenComb Logo" width="160"/>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
**OpenComb** is a powerful, practical toolkit for developers that helps you:
|
|
15
|
+
|
|
16
|
+
- **Combine** multiple Python source files into one clean module (with smart import deduplication)
|
|
17
|
+
- **Merge** YAML, JSON and TOML configs intelligently (deep or shallow)
|
|
18
|
+
- **Generate** combinatorial parameter sets (cartesian, pairwise testing, sampling)
|
|
19
|
+
- **Build** structured LLM prompts from system / instruction / context / few-shot / user parts
|
|
20
|
+
- **Render** Jinja2 templates (single or multi-file)
|
|
21
|
+
- **Run declarative recipes** that orchestrate all of the above in one YAML file
|
|
22
|
+
|
|
23
|
+
Perfect for rapid prototyping, test matrix generation, config management, AI/prompt engineering and automation pipelines.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install opencomb
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or with uv:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
uv add opencomb
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Features at a Glance
|
|
38
|
+
|
|
39
|
+
| Feature | CLI Command | Library Class | Description |
|
|
40
|
+
|----------------------|-----------------|--------------------------|--------------------------------------------------|
|
|
41
|
+
| Code Combining | `combine` | `CodeCombiner` | Merge Python files + import dedupe |
|
|
42
|
+
| Config Merging | `merge` | `ConfigMerger` | Deep / shallow YAML·JSON·TOML |
|
|
43
|
+
| Combinatorial Gen | `generate` | `CombinatorialGenerator` | Cartesian · Pairwise · Sample |
|
|
44
|
+
| Prompt Building | `prompt` | `PromptCombiner` | Structured LLM prompts |
|
|
45
|
+
| Template Rendering | `template` | `TemplateRenderer` | Jinja2 power |
|
|
46
|
+
| Recipe Runner | `recipe` | `RecipeRunner` | Full pipelines in one YAML |
|
|
47
|
+
|
|
48
|
+
## Quick Start – CLI
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Combine Python files
|
|
52
|
+
opencomb combine module_a.py module_b.py utils.py -o combined.py
|
|
53
|
+
|
|
54
|
+
# Merge configs (later files win)
|
|
55
|
+
opencomb merge base.yaml local.yaml secrets.toml -o final.yaml
|
|
56
|
+
|
|
57
|
+
# Generate combinations
|
|
58
|
+
opencomb generate -p params.yaml --method pairwise --report
|
|
59
|
+
|
|
60
|
+
# Build an LLM prompt
|
|
61
|
+
opencomb prompt \
|
|
62
|
+
--system system.txt \
|
|
63
|
+
--instruction task.txt \
|
|
64
|
+
--examples fewshot.yaml \
|
|
65
|
+
--user query.txt \
|
|
66
|
+
-o final_prompt.txt
|
|
67
|
+
|
|
68
|
+
# Render Jinja2 templates
|
|
69
|
+
opencomb template template.j2 --data data.yaml -o output.md
|
|
70
|
+
|
|
71
|
+
# Run a full recipe
|
|
72
|
+
opencomb recipe examples/sample_recipe.yaml
|
|
73
|
+
opencomb recipe examples/sample_recipe.yaml --dry-run --verbose
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Quick Start – Library
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from opencomb import (
|
|
80
|
+
CodeCombiner,
|
|
81
|
+
ConfigMerger,
|
|
82
|
+
CombinatorialGenerator,
|
|
83
|
+
PromptCombiner,
|
|
84
|
+
TemplateRenderer,
|
|
85
|
+
RecipeRunner,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Code
|
|
89
|
+
combiner = CodeCombiner()
|
|
90
|
+
code = combiner.combine_files(["a.py", "b.py"])
|
|
91
|
+
|
|
92
|
+
# Config
|
|
93
|
+
merger = ConfigMerger()
|
|
94
|
+
config = merger.merge_files(["base.yaml", "override.yaml"])
|
|
95
|
+
merger.save(config, "result.yaml")
|
|
96
|
+
|
|
97
|
+
# Combinations
|
|
98
|
+
gen = CombinatorialGenerator(seed=42)
|
|
99
|
+
params = {"lr": [0.001, 0.01], "batch": [16, 32], "opt": ["adam", "sgd"]}
|
|
100
|
+
all_combos = gen.cartesian(params)
|
|
101
|
+
pairwise = gen.pairwise(params) # much smaller & efficient
|
|
102
|
+
|
|
103
|
+
# Prompts
|
|
104
|
+
pc = PromptCombiner()
|
|
105
|
+
prompt = pc.combine(
|
|
106
|
+
system="You are a senior Python engineer.",
|
|
107
|
+
instruction="Review the following code.",
|
|
108
|
+
examples=[{"input": "x=1", "output": "Looks fine."}],
|
|
109
|
+
user="def foo(): pass",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# Templates
|
|
113
|
+
renderer = TemplateRenderer()
|
|
114
|
+
html = renderer.render_string("<h1>{{ title }}</h1>", title="OpenComb")
|
|
115
|
+
|
|
116
|
+
# Recipes
|
|
117
|
+
runner = RecipeRunner()
|
|
118
|
+
results = runner.run("my_recipe.yaml")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Recipe Example
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
# my_pipeline.yaml
|
|
125
|
+
name: full-pipeline
|
|
126
|
+
|
|
127
|
+
combine:
|
|
128
|
+
files: [src/a.py, src/b.py, src/utils.py]
|
|
129
|
+
output: build/combined.py
|
|
130
|
+
|
|
131
|
+
merge:
|
|
132
|
+
files: [config/base.yaml, config/prod.yaml]
|
|
133
|
+
output: build/config.yaml
|
|
134
|
+
strategy: deep
|
|
135
|
+
|
|
136
|
+
generate:
|
|
137
|
+
method: pairwise
|
|
138
|
+
params:
|
|
139
|
+
python: ["3.10", "3.11", "3.12"]
|
|
140
|
+
os: ["linux", "macos", "windows"]
|
|
141
|
+
output: build/matrix.jsonl
|
|
142
|
+
seed: 42
|
|
143
|
+
|
|
144
|
+
prompt:
|
|
145
|
+
system: |
|
|
146
|
+
You are an expert code reviewer.
|
|
147
|
+
instruction: |
|
|
148
|
+
Review the combined module and suggest improvements.
|
|
149
|
+
output: build/review_prompt.txt
|
|
150
|
+
|
|
151
|
+
template:
|
|
152
|
+
file: templates/report.md.j2
|
|
153
|
+
data:
|
|
154
|
+
project: OpenComb
|
|
155
|
+
version: "0.2.0"
|
|
156
|
+
output: build/report.md
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
opencomb recipe my_pipeline.yaml
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Publishing to PyPI
|
|
164
|
+
|
|
165
|
+
This repository includes ready-to-use GitHub Actions:
|
|
166
|
+
|
|
167
|
+
- **CI** (`.github/workflows/ci.yml`) – runs tests on Python 3.10–3.13 + builds the package
|
|
168
|
+
- **Publish** (`.github/workflows/publish.yml`) – publishes to PyPI when you create a GitHub Release
|
|
169
|
+
|
|
170
|
+
### How to release
|
|
171
|
+
|
|
172
|
+
1. Make sure the version in `pyproject.toml` is correct (currently `0.2.0`)
|
|
173
|
+
2. Create a new GitHub Release (or tag):
|
|
174
|
+
```bash
|
|
175
|
+
git tag v0.2.0
|
|
176
|
+
git push origin v0.2.0
|
|
177
|
+
```
|
|
178
|
+
Then create a Release on GitHub from that tag.
|
|
179
|
+
3. The `publish.yml` workflow will automatically build and upload to PyPI.
|
|
180
|
+
|
|
181
|
+
### Trusted Publishing (recommended)
|
|
182
|
+
|
|
183
|
+
1. Go to https://pypi.org/manage/account/publishing/
|
|
184
|
+
2. Add a new pending publisher:
|
|
185
|
+
- **PyPI Project Name**: `opencomb`
|
|
186
|
+
- **Owner**: `SlabyLol`
|
|
187
|
+
- **Repository name**: `OpenComb`
|
|
188
|
+
- **Workflow name**: `publish.yml`
|
|
189
|
+
- **Environment name**: `pypi`
|
|
190
|
+
3. Create the project on PyPI if it doesn’t exist yet (first upload will create it).
|
|
191
|
+
|
|
192
|
+
Alternatively you can use a classic API token:
|
|
193
|
+
- Create a token on PyPI → add it as repository secret `PYPI_TOKEN`
|
|
194
|
+
- Uncomment the token-based step in `publish.yml`
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
git clone https://github.com/SlabyLol/OpenComb.git
|
|
200
|
+
cd OpenComb
|
|
201
|
+
pip install -e ".[dev]"
|
|
202
|
+
pytest
|
|
203
|
+
ruff check src tests
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT © DarkFox Co. / SlabyLol
|
|
209
|
+
|
|
210
|
+
## Links
|
|
211
|
+
|
|
212
|
+
- **Repository**: https://github.com/SlabyLol/OpenComb
|
|
213
|
+
- **Issues**: https://github.com/SlabyLol/OpenComb/issues
|
|
214
|
+
- **PyPI**: https://pypi.org/project/opencomb/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# OpenComb Sample Recipe
|
|
2
|
+
name: demo-pipeline
|
|
3
|
+
|
|
4
|
+
# Generate a test matrix
|
|
5
|
+
generate:
|
|
6
|
+
method: pairwise
|
|
7
|
+
params:
|
|
8
|
+
python: ["3.10", "3.11", "3.12"]
|
|
9
|
+
os: ["linux", "macos"]
|
|
10
|
+
arch: ["x64", "arm64"]
|
|
11
|
+
output: build/test_matrix.jsonl
|
|
12
|
+
seed: 42
|
|
13
|
+
|
|
14
|
+
# Build a prompt
|
|
15
|
+
prompt:
|
|
16
|
+
system: |
|
|
17
|
+
You are a helpful Python expert.
|
|
18
|
+
instruction: |
|
|
19
|
+
Explain the following code clearly and suggest improvements.
|
|
20
|
+
user: |
|
|
21
|
+
How does the pairwise generator work?
|
|
22
|
+
output: build/prompt.txt
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "opencomb"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "OpenComb – Smart Combiner for Code, Configs, Prompts, Templates, Recipes & Combinatorial Generation"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "DarkFox Co.", email = "darkfox-to@proton.me" }
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"combiner",
|
|
17
|
+
"code-generation",
|
|
18
|
+
"config-merge",
|
|
19
|
+
"combinatorial",
|
|
20
|
+
"testing",
|
|
21
|
+
"cli",
|
|
22
|
+
"prompts",
|
|
23
|
+
"templates",
|
|
24
|
+
"recipes",
|
|
25
|
+
"jinja2",
|
|
26
|
+
"opencomb"
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 3 - Alpha",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"License :: OSI Approved :: MIT License",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Programming Language :: Python :: 3.13",
|
|
37
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
38
|
+
"Topic :: Software Development :: Code Generators",
|
|
39
|
+
"Topic :: Utilities",
|
|
40
|
+
"Environment :: Console",
|
|
41
|
+
]
|
|
42
|
+
dependencies = [
|
|
43
|
+
"typer>=0.12.0",
|
|
44
|
+
"rich>=13.0.0",
|
|
45
|
+
"pyyaml>=6.0",
|
|
46
|
+
"tomli>=2.0.0; python_version < '3.11'",
|
|
47
|
+
"tomli-w>=1.0.0",
|
|
48
|
+
"click>=8.0.0",
|
|
49
|
+
"jinja2>=3.1.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
dev = [
|
|
54
|
+
"pytest>=8.0.0",
|
|
55
|
+
"pytest-cov>=5.0.0",
|
|
56
|
+
"ruff>=0.5.0",
|
|
57
|
+
"mypy>=1.10.0",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.scripts]
|
|
61
|
+
opencomb = "opencomb.cli:app"
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
Homepage = "https://github.com/SlabyLol/OpenComb"
|
|
65
|
+
Repository = "https://github.com/SlabyLol/OpenComb"
|
|
66
|
+
Issues = "https://github.com/SlabyLol/OpenComb/issues"
|
|
67
|
+
Documentation = "https://github.com/SlabyLol/OpenComb#readme"
|
|
68
|
+
|
|
69
|
+
[tool.hatch.build.targets.wheel]
|
|
70
|
+
packages = ["src/opencomb"]
|
|
71
|
+
|
|
72
|
+
[tool.hatch.build.targets.sdist]
|
|
73
|
+
include = [
|
|
74
|
+
"/src",
|
|
75
|
+
"/tests",
|
|
76
|
+
"/examples",
|
|
77
|
+
"/README.md",
|
|
78
|
+
"/LICENSE",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
[tool.ruff]
|
|
82
|
+
line-length = 100
|
|
83
|
+
target-version = "py310"
|
|
84
|
+
|
|
85
|
+
[tool.ruff.lint]
|
|
86
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
87
|
+
|
|
88
|
+
[tool.mypy]
|
|
89
|
+
python_version = "3.10"
|
|
90
|
+
strict = true
|
|
91
|
+
warn_return_any = true
|
|
92
|
+
warn_unused_configs = true
|
|
93
|
+
|
|
94
|
+
[tool.pytest.ini_options]
|
|
95
|
+
testpaths = ["tests"]
|
|
96
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
OpenComb – Smart Combiner for Code, Configs, Prompts, Templates, Recipes
|
|
3
|
+
and Combinatorial Generation.
|
|
4
|
+
|
|
5
|
+
A practical toolkit for developers.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from opencomb.combiner import CodeCombiner, ConfigMerger
|
|
9
|
+
from opencomb.combinatorial import CombinatorialGenerator
|
|
10
|
+
from opencomb.prompt import PromptCombiner
|
|
11
|
+
from opencomb.recipe import RecipeRunner
|
|
12
|
+
from opencomb.template import TemplateRenderer
|
|
13
|
+
|
|
14
|
+
__version__ = "0.2.0"
|
|
15
|
+
__all__ = [
|
|
16
|
+
"CodeCombiner",
|
|
17
|
+
"ConfigMerger",
|
|
18
|
+
"CombinatorialGenerator",
|
|
19
|
+
"PromptCombiner",
|
|
20
|
+
"TemplateRenderer",
|
|
21
|
+
"RecipeRunner",
|
|
22
|
+
"__version__",
|
|
23
|
+
]
|