Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tutorial not working #47

Open
tjboller opened this issue Dec 20, 2023 · 0 comments
Open

tutorial not working #47

tjboller opened this issue Dec 20, 2023 · 0 comments

Comments

@tjboller
Copy link

my python file

import great_expectations as gx


from prefect import flow
from prefect_great_expectations import run_checkpoint_validation

def create_expectation_suite_and_checkpoint():
    """Create a DataContext, connect to data, create Expectations, create and return a checkpoint."""

    context = gx.get_context()

    validator = context.sources.pandas_default.read_csv(
        "https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv"
    )
    validator.expect_column_values_to_not_be_null("pickup_datetime")

    # this expectation will fail
    validator.expect_column_values_to_be_between(
        "passenger_count", min_value=1, max_value=5
    )

    # checkpoints are reusble and only need to be created once
    checkpoint = gx.checkpoint.SimpleCheckpoint(
        name="taxi_check",
        data_context=context,
        validator=validator,
    )

    return checkpoint


@flow
def validation_flow(checkpoint):
    """Creates a task that validates a run of a Great Expectations checkpoint"""
    res = run_checkpoint_validation(checkpoint=checkpoint)
    return 


if __name__ == "__main__":
    checkpoint = create_expectation_suite_and_checkpoint()
    validation_flow(checkpoint=checkpoint)

versions:
great-expectations 0.18.5
prefect-great-expectations 0.2.1
prefect 2.14.11

error:

Traceback (most recent call last):
  File "...", line 1, in <module>
    import great_expectations as gx
  File "...", line 5, in <module>
    from prefect_great_expectations import run_checkpoint_validation
  File ".../.venv/lib/python3.9/site-packages/prefect_great_expectations/__init__.py", line 2, in <module>
    from .validation import run_checkpoint_validation  # noqa
  File ".../.venv/lib/python3.9/site-packages/prefect_great_expectations/validation.py", line 6, in <module>
    from great_expectations import DataContext
ImportError: cannot import name 'DataContext' from partially initialized module 'great_expectations' (most likely due to a circular import) (...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant