-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[DOCS] Custom Actions #10772
[DOCS] Custom Actions #10772
Conversation
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
for more information, see https://pre-commit.ci
Thanks for the PR @pre-commit-ci[bot] 👋 Our GitHub actions pipelines require a user with write permissions to retry the failed jobs. We've sent a message to a maintainer to review your PR. Please be patient and we'll get back to you as soon as possible. |
…ions/great_expectations into kml/DOC-900/customActions
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## develop #10772 +/- ##
========================================
Coverage 80.67% 80.67%
========================================
Files 464 464
Lines 40348 40349 +1
========================================
+ Hits 32552 32553 +1
Misses 7796 7796
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ions/great_expectations into kml/DOC-900/customActions
for more information, see https://pre-commit.ci
…ions/great_expectations into kml/DOC-900/customActions
…ions/great_expectations into kml/DOC-900/customActions
…ions/great_expectations into kml/DOC-900/customActions
|
||
- <PrereqPythonInstalled/>. | ||
- <PrereqGxInstalled/>. | ||
- <PrereqPreconfiguredDataContext/>. In this guide the variable `context` is assumed to contain your Data Context. | ||
- <PrereqValidationDefinition/>. | ||
|
||
### Procedure | ||
## Procedure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: apologies for scope creep but I noticed some header level issues on this page when I copied it to scaffold the new page, so I went ahead and fixed the problems on this page.
<sup>6</sup> Airflow version 2.9.0+ required<br/> | ||
<sup>3</sup> This includes configuration storage for Expectations, Checkpoints, Validation Definitions, and Validation Results.<br/> | ||
<sup>4</sup> We support the general workflow for creating custom Actions but cannot help troubleshoot the domain-specific logic within a custom Action.<br/> | ||
<sup>5</sup> Use `config_variables.yml`.<br/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer: apologies for scope creep but I went ahead and made these footnotes more consistently structured as long as I was editing this content.
@@ -0,0 +1,46 @@ | |||
""" | |||
This is an example script for how to create a custom Action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for technical reviewer: this is my first time putting a new code sample under test. I did get some errors with it that I was able to resolve so I think the test is working. But, please let me know if I need to add anything else to make sure this is sufficiently tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm so usually these snippet files represent actual tests and I don't think we have any test logic here.
At the bottom of the file, could we instantiate an instance of this custom class and assert against its run method?
my_action = MyCustomAction(...)
result = my_action.run(...)
assert result == {"some": "info"}
You may need to create a checkpoint and that can be a little cumbersome so let me know if you want me to jump in and add these details on your behalf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you - I would appreciate if you'd jump in and add the extra code to make this a sufficient test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the logic to show a concrete example of what a user might want to do but feel free to modify/critique as you see fit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
How does this custom calculated percentage of successful expectations across all validation results compare to the success_percent
info available through ExpectationSuiteValidationResult.statistics
?
If these two things provide the same exact information in different ways, are there advantages to using a custom action instead of the built-in statistics?
Depending on how similar these two things are and what if any advantages there are to choosing one option over another in various scenarios, I think we should either acknowledge the similarities and tradeoffs or pick a different concrete example.
(this feedback is somewhat similar to the feedback you had for me about the email use case in the intro overlapping a bit with our built in email action.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
connecting some dots: more discussion about this in slack at https://greatexpectationslabs.slack.com/archives/C05V0M18TEJ/p1734482967962709?thread_ts=1734360165.007409&cid=C05V0M18TEJ
|
||
from typing import Literal | ||
|
||
from typing_extensions import override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for technical reviewer: I got an error about override not being defined so I added this based on other code I see in the repo. It resolved the error so I think it's right but let me know if there's anything amiss here.
@@ -70,7 +70,7 @@ To ensure the long-term quality of the GX Core codebase, we're not yet ready to | |||
| -------------------- | ------------------ | ----- | | |||
| CredentialStore | 🟢 Ready | | | |||
| BatchDefinition | 🟡 Partially ready | Formerly known as splitters | | |||
| Action | 🔴 Not ready | | | |||
| Action | 🟢 Ready | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for product reviewer Please confirm the contribution readiness status for Actions. I tried to ask about this in my docs plan but didn't get an answer so want to double check that I've got the right status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the product review but LGTM from an engineering perspective - the API is stable and the steps to create custom actions are quite simple (as laid out here 🎉 )
@@ -182,10 +182,10 @@ def __new__(cls, clsname, bases, attrs): | |||
@public_api | |||
class ValidationAction(BaseModel, metaclass=MetaValidationAction): | |||
""" | |||
ValidationActions define a set of steps to be run after a validation result is produced. | |||
Actions define a set of steps to run after a Validation Result is produced. Subclass `ValidationAction` to create a `custom Action </docs/core/trigger_actions_based_on_results/create_a_custom_action>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh that is a little odd - I don't know the exact logic that does this but it might be ingrained in one of the docs libs we use.
Perhaps try MD syntax for hyperlinks? Not sure that's supported but worth a shot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MD syntax worked! 🎉
…ions/great_expectations into kml/DOC-900/customActions :wq
@@ -87,7 +87,7 @@ def _build_renderer(config: dict) -> Renderer: | |||
) | |||
return renderer | |||
|
|||
|
|||
@public_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah amazing I was attempting to do the same thing here: #10752
Let's take in your change and then I'll update my PR to fill in any other gaps if we have them
for more information, see https://pre-commit.ci
@@ -308,7 +308,7 @@ jobs: | |||
# We decided to exclude all external HTTP requests but the ones that under the domain greatexpectations.io | |||
# The reason is to avoid having network errors such as pages that throw 429 after too many requests (like Github) | |||
# and to prevent other possible errors related to user agent or lychee capturing hrefs from metadata that don't resolve to a specific page (preconnects in JS) | |||
args: "--exclude='http.*' --include='^https://(.+\\.)?greatexpectations\\.io/' 'docs/docusaurus/build/**/*.html'" | |||
args: "--exclude='http.*' 'docs/docusaurus/build/**/*.html'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewers: I'm temporarily changing the link checker config to work around a bug where the link checker fails when a PR contains a link to a page that that same PR is introducing. I'll undo this change after merging this PR to restore link checking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay I have the same issue and didn't realize it was a documented bug - thanks for the call out!
|
||
Great Expectations provides [Actions for common workflows](/application_integration_support.md#integrations) such as sending emails and updating Data Docs. If these don't meet your needs, you can create a custom Action to integrate with different tools or apply custom business logic based on Validation Results. Example use cases for custom Actions include: | ||
- Opening tickets in an issue tracker when Validation runs fail. | ||
- Sending emails to different teams depending on which Expectations fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has some overlap with our current email action right? Should we perhaps pick another example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good just a minor point or two about the test file - happy to discuss just let me know!
…ps://github.com/great-expectations/great_expectations into m/zelda-1183/zelda-1188/adding-databricks-types * 'm/zelda-1183/zelda-1188/adding-databricks-types' of https://github.com/great-expectations/great_expectations: [MAINTENANCE] Allow `CheckpointResult` and `ActionContext` to be importable from top-level checkpoint module (#10788) [DOCS] Custom Actions (#10772) [DOCS] Remove unnecessary escape character in Expectation for Gallery (#10780) [MAINTENANCE] Deprecate `DataContext.add_or_update_datasource` (#10784)
…thub.com/great-expectations/great_expectations into m/zelda-1183/zelda-1188/databricks-tests * 'm/zelda-1183/zelda-1188/databricks-tests' of https://github.com/great-expectations/great_expectations: [MAINTENANCE] Allow `CheckpointResult` and `ActionContext` to be importable from top-level checkpoint module (#10788) [DOCS] Custom Actions (#10772) [DOCS] Remove unnecessary escape character in Expectation for Gallery (#10780) [MAINTENANCE] Deprecate `DataContext.add_or_update_datasource` (#10784)
Resolves https://greatexpectations.atlassian.net/browse/DOC-900 according to the plan linked in that issue
Deploy Preview at https://deploy-preview-10772.docs.greatexpectations.io/docs/core/trigger_actions_based_on_results/create_a_custom_action
invoke lint
(usesruff format
+ruff check
)For more information about contributing, visit our community resources.
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!