Skip to main content

Programmatic parameter sweeps for pydantic.

Project description

pydantic-sweep

pydantic_sweep is a library to programmatically, safely and flexibly define complex parameter sweeps over pydantic models in Python.

PyPI - Version Static Badge GitHub branch check runs GitHub License

Highlights:

  • Specify parameter sweeps in Python
  • Flexibility: specify complex parameter combinations by chaining simple operations
  • Safety checks for parameter combinations (get meaningful errors early)
  • pydantic field validation

For example, the following code will instantiate models with (x=5, y=1) and (x=6, y=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 Model(ps.BaseModel):
    seed: int = 42
    x: int = 5
    y: int

models = ps.initialize(
    Model, 
    ps.config_product(
        ps.field("seed", [43, 44]),
        ps.config_zip(
            ps.field("x", [ps.DefaultValue, 6]),
            ps.field("y", [1, 2]),
        )
    )
)

# The code above is equivalent to
models = [
    Model(seed=43, x=5, y=1), 
    Model(seed=43, x=6, y=2), 
    Model(seed=44, x=5, y=1), 
    Model(seed=44, x=6, y=2),
]

To learn mode about the full capabilities of the library visit the documentation page.

Installation

You can install the library by checking out the repo and running

pip install 'pydantic_sweep'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_sweep-0.2.0.tar.gz (109.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_sweep-0.2.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_sweep-0.2.0.tar.gz.

File metadata

  • Download URL: pydantic_sweep-0.2.0.tar.gz
  • Upload date:
  • Size: 109.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pydantic_sweep-0.2.0.tar.gz
Algorithm Hash digest
SHA256 54ae83359ccbd1cc490cc13dbe13c3efc2a487ec107f334cba8bdc579d26d3c3
MD5 f0111d9869dd39a03ecf76de44d29351
BLAKE2b-256 b4bef457e2f5b51479c8a34d71a019c058bf77823c22bae1f8029b75641181c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sweep-0.2.0.tar.gz:

Publisher: release.yml on befelix/pydantic_sweep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_sweep-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydantic_sweep-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pydantic_sweep-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fadea2d30a4ffccbcd4ef693c51c72ecdfa70a8fd411bf3ba95269cc6aa0f1c
MD5 4eced6d7494796a0ee6776fa970a1652
BLAKE2b-256 aa811bbe651e64f8d0c5a1a2454aa2b254c27deeba605d97a11906f28815d655

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_sweep-0.2.0-py3-none-any.whl:

Publisher: release.yml on befelix/pydantic_sweep

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page