Skip to main content

snowpark-checkpoints-hypothesis


This package is on Public Preview.

snowpark-checkpoints-hypothesis is a Hypothesis extension for generating Snowpark DataFrames. This project provides strategies to facilitate testing and data generation for Snowpark DataFrames using the Hypothesis library.

Installation

You can install this package using either pip or conda:

pip install snowpark-checkpoints-hypothesis
--or--
conda install snowpark-checkpoints-hypothesis

Usage

The typical workflow for using the Hypothesis library to generate Snowpark dataframes is as follows:

  1. Create a standard Python test function with the different assertions or conditions your code should satisfy for all inputs.
  2. Add the Hypothesis @given decorator to your test function and pass the dataframe_strategy function as an argument.
  3. Run the test. When the test is executed, Hypothesis will automatically provide the generated inputs as arguments to the test.

Example 1: Generate Snowpark DataFrames from a JSON schema file

You can use the dataframe_strategy function to create Snowpark DataFrames from a JSON schema file generated by the collect_dataframe_checkpoint function of the snowpark-checkpoints-collectors package:

from hypothesis import given
from snowflake.hypothesis_snowpark import dataframe_strategy
from snowflake.snowpark import DataFrame, Session


@given(
    df=dataframe_strategy(
        schema="path/to/schema.json",
        session=Session.builder.getOrCreate(),
        size=10,
    )
)
def test_my_function(df: DataFrame):
    # Test your function here
    ...

Example 2: Generate Snowpark DataFrames from a Pandera DataFrameSchema object

You can also use the dataframe_strategy function to create Snowpark DataFrames from a Pandera DataFrameSchema object:

import pandera as pa
from hypothesis import given
from snowflake.hypothesis_snowpark import dataframe_strategy
from snowflake.snowpark import DataFrame, Session

@given(
    df=dataframe_strategy(
        schema=pa.DataFrameSchema(
            {
                "A": pa.Column(pa.Int, checks=pa.Check.in_range(0, 10)),
                "B": pa.Column(pa.Bool),
            }
        ),
        session=Session.builder.getOrCreate(),
        size=10,
    )
)
def test_my_function(df: DataFrame):
    # Test your function here
    ...

Development

Set up a development environment

To set up a development environment, follow the steps below:

  1. Create a virtual environment using venv or conda. Replace <env-name> with the name of your environment.

    Using venv:

    python3.11 -m venv <env-name>
    source <env-name>/bin/activate
    

    Using conda:

    conda create -n <env-name> python=3.11
    conda activate <env-name>
    
  2. Configure your IDE to use the previously created virtual environment:

  3. Install the project dependencies:

    pip install hatch
    pip install -e .
    

Running Tests

To run tests, run the following command.

hatch run test:check

Metadata

Release files for snowpark-checkpoints-hypothesis 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowpark-checkpoints-hypothesis 0.4.0
File Size Uploaded Provenance
snowpark_checkpoints_hypothesis-0.4.0.tar.gz 39.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for snowpark-checkpoints-hypothesis 0.4.0
File Interpreter ABI Platform
snowpark_checkpoints_hypothesis-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 72.8 kB

Release files / snowpark_checkpoints_hypothesis-0.4.0.tar.gz

Download URL snowpark_checkpoints_hypothesis-0.4.0.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0f339f2befef48b57892ac82a36e69e0b9ac849b2d63a76df24e27266ab8a3bd
BLAKE2b-256 checksum
How to use checksums
8fbb0c865b17e201710abcb2474cd22ea54b3b598c8a796b878c4d1f2ffd0c43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Release files / snowpark_checkpoints_hypothesis-0.4.0-py3-none-any.whl

Download URL snowpark_checkpoints_hypothesis-0.4.0-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
377885c3d6761cd7d73e7c8ca29042511f286ff23e0c4c3c013b1bf5b6eb3195
BLAKE2b-256 checksum
How to use checksums
fa3de80957d2dca8516b29e3eaf936259921f3485d1980a00fb84af4bdbbaf3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.3

Security for snowpark-checkpoints-hypothesis 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page