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

Demo Scripts - Quickstart, Idempotency #9002

Closed
wants to merge 64 commits into from
Closed

Conversation

jcampbell
Copy link
Member

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB]
  • Code is linted - run invoke lint (uses black + ruff)
  • Appropriate tests and docs have been updated

For more information about contributing, see Contribute.

After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!

Copy link

netlify bot commented Nov 27, 2023

Deploy Preview for niobium-lead-7998 failed.

Name Link
🔨 Latest commit e97e29f
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/65b12cf3dfd92600088d4f0c

@ghost
Copy link

ghost commented Nov 27, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

Comment on lines 23 to 39
# <snippet name="tutorials/quickstart/quickstart.py connect_to_data">
batch = context.sources.pandas_default.read_csv(
"https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv"
)

# What happened in the background?
# Datsource: "default_pandas_datasource"
# Asset: "#ephemeral_pandas_asset" -- CSVAsset (path lives here)
# BatchConfig (Splitters): No Splitters
# BatchOptions: (none needed)

# TODO: ticket We can also use a SQL query as a data source
context.sources.add_postgresql(
name="postgresql", connection_string="postgresql://localhost"
)
batch = context.sources.postgresql.query_batch("SELECT * FROM taxi LIMIT 1000")
# </snippet>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My original thought was to have the connect to data code, along with any related testing/verification, wrapped in a function that returns whatever is needed for the rest of the script (one function for each datasource demonstrated), and then call each of those functions once before proceeding with the rest of the example script.

Because snippets automatically truncate excess spacing when they are imported into the docs, it won't matter that there is "extra" indentation from the snippet existing in a function rather than in the top level namespace, at least insofar as the docs are concerned.

Then, we would just have each snippet named something like:
snippet name="tutorials/quickstart/quickstart.py connect_to_data <specific datasource>" and reference the appropriate <specific datasource> in each tab in the docs.

Comment on lines 23 to 39
# <snippet name="tutorials/quickstart/quickstart.py connect_to_data">
batch = context.sources.pandas_default.read_csv(
"https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv"
)

# What happened in the background?
# Datsource: "default_pandas_datasource"
# Asset: "#ephemeral_pandas_asset" -- CSVAsset (path lives here)
# BatchConfig (Splitters): No Splitters
# BatchOptions: (none needed)

# TODO: ticket We can also use a SQL query as a data source
context.sources.add_postgresql(
name="postgresql", connection_string="postgresql://localhost"
)
batch = context.sources.postgresql.query_batch("SELECT * FROM taxi LIMIT 1000")
# </snippet>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example:

def connect_to_data_pandas_csv()
    # <snippet name="tutorials/quickstart/quickstart.py connect_to_data pandas_csv">
    batch = context.sources.pandas_default.read_csv(
    "https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv"
)
    </snippet>
    return batch
batch = connect_to_data_pandas_csv()

# BatchOptions: (none needed)

batch = context.sources.postgresql.add_query_asset(
name="top1000" "SELECT * FROM taxi LIMIT 1000"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing a comma between the name and the query.

def get_quickstart_batch(datasource_type: QuickstartDatasourceTabs) -> Batch:
if datasource_type == QuickstartDatasourceTabs.PANDAS_DEFAULT:
# <snippet name="tutorials/quickstart/quickstart.py connect_to_data pandas_csv">
batch = context.sources.pandas_default.read_csv(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update read_csv to return a batch.


# <snippet name="tutorials/quickstart/quickstart.py import_gx">
import great_expectations as gx
import great_expectations.expectations as gxe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move the expectations into this namespace.

danjer and others added 28 commits January 24, 2024 10:29
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: T Pham <[email protected]>
…cusaurus (#9214)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: T Pham <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: T Pham <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anthony Burdi <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bill Dirks <[email protected]>
@jcampbell
Copy link
Member Author

Closing. This has all been merged into docs / updated based on subsequent timber work.

@jcampbell jcampbell closed this Oct 1, 2024
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

Successfully merging this pull request may close these issues.