synth-curator 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 (72) hide show
  1. synth_curator-0.1.0/.github/workflows/release.yml +94 -0
  2. synth_curator-0.1.0/.github/workflows/tests.yml +66 -0
  3. synth_curator-0.1.0/.gitignore +10 -0
  4. synth_curator-0.1.0/CHANGELOG.md +19 -0
  5. synth_curator-0.1.0/LICENSE +21 -0
  6. synth_curator-0.1.0/PKG-INFO +509 -0
  7. synth_curator-0.1.0/README.md +466 -0
  8. synth_curator-0.1.0/config.example.shipped.yaml +70 -0
  9. synth_curator-0.1.0/config.example.yaml +159 -0
  10. synth_curator-0.1.0/docs/design.md +96 -0
  11. synth_curator-0.1.0/pyproject.toml +56 -0
  12. synth_curator-0.1.0/src/synth_curator/__init__.py +7 -0
  13. synth_curator-0.1.0/src/synth_curator/__main__.py +5 -0
  14. synth_curator-0.1.0/src/synth_curator/cli.py +49 -0
  15. synth_curator-0.1.0/src/synth_curator/core/__init__.py +1 -0
  16. synth_curator-0.1.0/src/synth_curator/core/block_search.py +134 -0
  17. synth_curator-0.1.0/src/synth_curator/core/distributional.py +109 -0
  18. synth_curator-0.1.0/src/synth_curator/core/features.py +43 -0
  19. synth_curator-0.1.0/src/synth_curator/core/fingerprint.py +31 -0
  20. synth_curator-0.1.0/src/synth_curator/core/geometry.py +25 -0
  21. synth_curator-0.1.0/src/synth_curator/core/groups.py +87 -0
  22. synth_curator-0.1.0/src/synth_curator/core/output.py +45 -0
  23. synth_curator-0.1.0/src/synth_curator/core/registry.py +61 -0
  24. synth_curator-0.1.0/src/synth_curator/core/safety.py +70 -0
  25. synth_curator-0.1.0/src/synth_curator/core/sampling.py +65 -0
  26. synth_curator-0.1.0/src/synth_curator/core/scoring.py +75 -0
  27. synth_curator-0.1.0/src/synth_curator/exceptions.py +17 -0
  28. synth_curator-0.1.0/src/synth_curator/model_interface.py +136 -0
  29. synth_curator-0.1.0/src/synth_curator/pipeline.py +588 -0
  30. synth_curator-0.1.0/src/synth_curator/py.typed +0 -0
  31. synth_curator-0.1.0/src/synth_curator/shipped/isic2018_resnet50/meta.json +52 -0
  32. synth_curator-0.1.0/src/synth_curator/shipped/isic2018_resnet50/weights.json +121 -0
  33. synth_curator-0.1.0/src/synth_curator/shipped/isic2018_swin_b/meta.json +53 -0
  34. synth_curator-0.1.0/src/synth_curator/shipped/isic2018_swin_b/weights.json +121 -0
  35. synth_curator-0.1.0/src/synth_curator/steps/__init__.py +1 -0
  36. synth_curator-0.1.0/src/synth_curator/steps/curate.py +105 -0
  37. synth_curator-0.1.0/src/synth_curator/steps/features.py +132 -0
  38. synth_curator-0.1.0/src/synth_curator/steps/metric_sets.py +99 -0
  39. synth_curator-0.1.0/src/synth_curator/steps/metrics/__init__.py +112 -0
  40. synth_curator-0.1.0/src/synth_curator/steps/metrics/from_features.py +68 -0
  41. synth_curator-0.1.0/src/synth_curator/steps/metrics/paired.py +149 -0
  42. synth_curator-0.1.0/src/synth_curator/steps/metrics/single_image.py +79 -0
  43. synth_curator-0.1.0/src/synth_curator/steps/standardize.py +75 -0
  44. synth_curator-0.1.0/src/synth_curator/steps/tournament.py +140 -0
  45. synth_curator-0.1.0/src/synth_curator/steps/weights.py +123 -0
  46. synth_curator-0.1.0/src/synth_curator/weights_bundle.py +93 -0
  47. synth_curator-0.1.0/tests/__init__.py +0 -0
  48. synth_curator-0.1.0/tests/conftest.py +166 -0
  49. synth_curator-0.1.0/tests/test_block_search.py +95 -0
  50. synth_curator-0.1.0/tests/test_cli.py +215 -0
  51. synth_curator-0.1.0/tests/test_curate_step.py +126 -0
  52. synth_curator-0.1.0/tests/test_distributional.py +110 -0
  53. synth_curator-0.1.0/tests/test_features_core.py +54 -0
  54. synth_curator-0.1.0/tests/test_features_step.py +63 -0
  55. synth_curator-0.1.0/tests/test_fingerprint.py +38 -0
  56. synth_curator-0.1.0/tests/test_geometry.py +42 -0
  57. synth_curator-0.1.0/tests/test_groups.py +61 -0
  58. synth_curator-0.1.0/tests/test_image_steps.py +115 -0
  59. synth_curator-0.1.0/tests/test_metric_sets.py +156 -0
  60. synth_curator-0.1.0/tests/test_metrics_calculators.py +111 -0
  61. synth_curator-0.1.0/tests/test_metrics_dispatch.py +50 -0
  62. synth_curator-0.1.0/tests/test_metrics_from_features.py +57 -0
  63. synth_curator-0.1.0/tests/test_model_interface.py +78 -0
  64. synth_curator-0.1.0/tests/test_output.py +65 -0
  65. synth_curator-0.1.0/tests/test_pipeline.py +1460 -0
  66. synth_curator-0.1.0/tests/test_registry.py +46 -0
  67. synth_curator-0.1.0/tests/test_safety.py +64 -0
  68. synth_curator-0.1.0/tests/test_sampling.py +46 -0
  69. synth_curator-0.1.0/tests/test_scoring.py +80 -0
  70. synth_curator-0.1.0/tests/test_tournament.py +150 -0
  71. synth_curator-0.1.0/tests/test_weights.py +130 -0
  72. synth_curator-0.1.0/tests/test_weights_bundle.py +106 -0
@@ -0,0 +1,94 @@
1
+ name: release
2
+
3
+ # Manual only, by design: nothing publishes on a push or tag. Go to the Actions tab, pick
4
+ # "release", click "Run workflow", and choose which index to publish to. Auth is OIDC
5
+
6
+ on:
7
+ workflow_dispatch:
8
+ inputs:
9
+ target:
10
+ description: "Which index to publish to"
11
+ required: true
12
+ type: choice
13
+ options: [testpypi, pypi]
14
+ default: testpypi
15
+
16
+ jobs:
17
+ build:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.12"
24
+ - name: Build sdist + wheel
25
+ run: |
26
+ pip install build twine
27
+ python -m build
28
+ twine check dist/*
29
+ - uses: actions/upload-artifact@v4
30
+ with:
31
+ name: dist
32
+ path: dist/
33
+
34
+ publish-testpypi:
35
+ if: inputs.target == 'testpypi'
36
+ needs: build
37
+ runs-on: ubuntu-latest
38
+ environment: testpypi
39
+ permissions:
40
+ id-token: write # required for Trusted Publishing - no token/secret used
41
+ steps:
42
+ - uses: actions/download-artifact@v4
43
+ with:
44
+ name: dist
45
+ path: dist/
46
+ - uses: pypa/gh-action-pypi-publish@release/v1
47
+ with:
48
+ repository-url: https://test.pypi.org/legacy/
49
+ skip-existing: true # testing often means re-running against the same version - skip instead of failing
50
+
51
+ publish-pypi:
52
+ if: inputs.target == 'pypi'
53
+ needs: build
54
+ runs-on: ubuntu-latest
55
+ environment: pypi
56
+ permissions:
57
+ id-token: write # required for Trusted Publishing - no token/secret used
58
+ contents: write # required to push the tag below
59
+ steps:
60
+ - uses: actions/checkout@v4
61
+ - uses: actions/download-artifact@v4
62
+ with:
63
+ name: dist
64
+ path: dist/
65
+ - uses: pypa/gh-action-pypi-publish@release/v1
66
+
67
+ # Only reached if the publish step above succeeded - a tag only ever marks a commit that's
68
+ # actually live on PyPI, never a failed or in-progress attempt.
69
+ - name: Tag the released version
70
+ run: |
71
+ VERSION=$(python3 -c "import pathlib, re; f = next(pathlib.Path('dist').glob('*.whl')).name; print(re.match(r'^[^-]+-([^-]+)-', f).group(1))")
72
+ echo "TAG=v$VERSION" >> "$GITHUB_ENV"
73
+ git config user.name "github-actions[bot]"
74
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
75
+ git tag "v$VERSION"
76
+ git push origin "v$VERSION"
77
+
78
+ # Pulls this version's section out of CHANGELOG.md (everything between its "## x.y.z" header
79
+ # and the next one) as the release notes; falls back to a bare pointer if that section is
80
+ # missing, rather than publish an empty-looking release.
81
+ - name: Create the GitHub Release
82
+ env:
83
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84
+ run: |
85
+ VERSION="${TAG#v}"
86
+ awk -v ver="$VERSION" '
87
+ $0 ~ "^## " ver { found=1; next }
88
+ found && /^## / { exit }
89
+ found { print }
90
+ ' CHANGELOG.md > release_notes.md
91
+ if [ ! -s release_notes.md ]; then
92
+ echo "See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md)." > release_notes.md
93
+ fi
94
+ gh release create "$TAG" --title "$TAG" --notes-file release_notes.md
@@ -0,0 +1,66 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+ schedule:
9
+ # catch a newly-disclosed CVE in an already-pinned dependency even when nothing in the repo
10
+ # changes to otherwise trigger a run.
11
+ - cron: "0 6 * * 1"
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ python-version: ["3.10", "3.11", "3.12"]
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+
27
+ # [full] pulls in FSIM/LPIPS/BRISQUE/CLIP deps so the fuller suite runs, not just the core one.
28
+ - name: Install
29
+ run: pip install -e '.[dev,full]'
30
+
31
+ - name: Ruff
32
+ run: ruff check src/ tests/
33
+
34
+ - name: Pytest
35
+ run: pytest -q
36
+
37
+ security-audit:
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: actions/setup-python@v5
42
+ with:
43
+ python-version: "3.12"
44
+ # pip itself gets audited otherwise (it's always present in the venv, but it isn't a
45
+ # dependency we actually ship) - upgrading first avoids that false positive every run.
46
+ - name: Install
47
+ run: |
48
+ pip install --upgrade pip
49
+ pip install pip-audit
50
+ pip install -e '.[full,yaml]'
51
+ - name: pip-audit
52
+ run: pip-audit
53
+
54
+ build:
55
+ runs-on: ubuntu-latest
56
+ needs: [test, security-audit]
57
+ steps:
58
+ - uses: actions/checkout@v4
59
+ - uses: actions/setup-python@v5
60
+ with:
61
+ python-version: "3.12"
62
+ - name: Build sdist + wheel
63
+ run: |
64
+ pip install build twine
65
+ python -m build
66
+ twine check dist/*
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ dist/
4
+ build/
5
+ .venv/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ *.pt
10
+ !tests/fixtures/**/*.pt
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — initial release
4
+
5
+ - Full pipeline: standardize → extract features → compute metrics → curate metric sets → run
6
+ the tournament → derive per-class weights → curate the final set (`SynthCurator.run()`).
7
+ - Two-tier training: cheap tournament ranking (`train_and_evaluate`) vs. an optional, one-time
8
+ production training call (`train_production`).
9
+ - Pluggable scoring (`metric_beta` / `scoring`) and utility formulas (`utility_formula` /
10
+ `dist_utility_formula`).
11
+ - Multi-GPU tournament dispatch (`model_factory` + `gpu_ids`).
12
+ - Precomputed weights (`weights_path=` / `shipped_weights=`) to skip the tournament entirely —
13
+ ships with two ISIC-2018 presets (`isic2018_swin_b`, `isic2018_resnet50`).
14
+ - `resample()` for model-locked, data-variance-swept validation sweeps, with matching config/CLI
15
+ support (`resample:` section).
16
+ - Config file (`config.example.yaml` / `config.example.shipped.yaml`) + `synth-curator` CLI as an
17
+ alternative to the Python API.
18
+ - Fingerprint-based resumability on every cacheable step; `pool_workdir` for sharing steps 1-3
19
+ across a sweep.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amindu Kumarasinghe
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.