pydantic-sweep
pydantic_sweep is a library to programmatically, safely and flexibly define
complex parameter sweeps over pydantic models in Python.
Highlights:
- Specify parameter sweeps in Python
- Flexibility: specify complex parameter combinations by chaining simple functional operations
- Safety checks for parameter combinations (get meaningful errors early)
pydanticfield validation- Conversion between json/yaml/python code representation of models
For example, the following code will instantiate models with (x=5, sub=Sub1(s=1) and
(x=6, sub=Sub1(s=2) and try each of those with seed values of seed=43 and
seed=44, leading to four different configurations:
import pydantic_sweep as ps
class Sub1(ps.BaseModel):
s: int = 5
class Sub2(ps.BaseModel):
y: str = "hi"
class Model(ps.BaseModel):
seed: int = 42
x: int = 5
sub: Sub1 | Sub2
# We want to test across two seeds
configs = ps.config_product(
ps.field("seed", [43, 44]),
# And two specific Sub1 and `x` combinations
ps.config_zip(
ps.field("x", [ps.DefaultValue, 6]),
ps.field("sub.s", [1, 2]),
)
)
# This includes safety checks that Sub1 / Sub2 are uniquely specified
models = ps.initialize(Model, configs)
# The code above is equivalent to
models_manual = [
Model(seed=43, sub=Sub1(s=1)),
Model(seed=43, x=6, sub=Sub1(s=2)),
Model(seed=44, sub=Sub1(s=1)),
Model(seed=44, x=6, sub=Sub1(s=2)),
]
assert models == models_manual
# We can also check that we didn't accidentally duplicate a setting
ps.check_unique(models)
While in this toy example, manually specifying the combinations may still be viable, the library allows infinitely combining different configs and sub-models, making it a powerful tool for large-scale experiment definition. To learn mode about the capabilities of the library please visit the documentation page.
Installation
You can install the library by checking out the repo and running
pip install 'pydantic-sweep'
License
The main code-base is licensed under MPL-2.0 a weak copy-left license that allows commercial use. See the license file for the exact clauses and this FAQ for a high-level description.
An exception from this are the documentation in the docs and example folders as
well as this README file, which are licensed under the
0BSD: a highly
permissive license that does not require attribution. That way, you are free to copy &
paste example code into your use-case. See
here for a high-level description.
Metadata
Release files for pydantic-sweep 0.3.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pydantic_sweep-0.3.8.tar.gz | 18.3 kB | With provenance | Details for pydantic_sweep-0.3.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_sweep-0.3.8-py3-none-any.whl | Python 3 | none | any | Details for pydantic_sweep-0.3.8-py3-none-any.whl |
Total release size: 40.8 kB
Release files / pydantic_sweep-0.3.8.tar.gz
| Download URL | pydantic_sweep-0.3.8.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1f194cc801692d628a369e93c1a47c5cac9cd316b36e48074324fc432404e6c
|
|
BLAKE2b-256 checksum How to use checksums |
d368132fb796d6d3ff05a0785d94db7537fc1b43fa2767f9c776ea9eff0397c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 6, 2026.
Transparency logRelease files / pydantic_sweep-0.3.8-py3-none-any.whl
| Download URL | pydantic_sweep-0.3.8-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3df1f72258f50b66ddd83e5c9a603e00f1436dfa726dfe3abaeb25f2b4b17b2a
|
|
BLAKE2b-256 checksum How to use checksums |
6b7300ddd60ca0e25fbd782b192a5d40d7d439c71e5a89ed314bcc6ab161a708
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 6, 2026.
Transparency logSecurity for pydantic-sweep 0.3.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pydantic_sweep-0.3.8.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.