### Install GX Core Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Install the GX Core library using pip. Ensure you have Python 3.10 to 3.13 installed. ```bash pip install great_expectations ``` -------------------------------- ### Complete Great Expectations Workflow Example Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx This snippet shows the full process of setting up and running Great Expectations, including creating a data context, connecting to a PostgreSQL database, defining expectations, creating a validation definition, and running a checkpoint. Use this as a comprehensive example for a basic GX implementation. ```python import great_expectations as gx context = gx.get_context() connection_string = "postgresql+psycopg2://try_gx:try_gx@postgres.workshops.greatexpectations.io/gx_example_db" data_source = context.data_sources.add_postgres( "postgres db", connection_string=connection_string ) data_asset = data_source.add_table_asset(name="taxi data", table_name="nyc_taxi_data") batch_definition = data_asset.add_batch_definition_whole_table("batch definition") batch = batch_definition.get_batch() suite = context.suites.add( gx.core.expectation_suite.ExpectationSuite(name="expectations") ) suite.add_expectation( gx.expectations.ExpectColumnValuesToBeBetween( column="passenger_count", min_value=1, max_value=6, severity="warning" ) ) suite.add_expectation( gx.expectations.ExpectColumnValuesToBeBetween( column="fare_amount", min_value=0, severity="critical" ) ) validation_definition = context.validation_definitions.add( gx.core.validation_definition.ValidationDefinition( name="validation definition", data=batch_definition, suite=suite, ) ) checkpoint = context.checkpoints.add( gx.checkpoint.checkpoint.Checkpoint( name="checkpoint", validation_definitions=[validation_definition] ) ) checkpoint_result = checkpoint.run() print(checkpoint_result.describe()) ``` -------------------------------- ### Verify GX Core Installation Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Verify that GX Core has been installed successfully by printing its version number. This code can be run in a Python interpreter, IDE, notebook, or script. ```python import great_expectations as gx print(gx.__version__) ``` -------------------------------- ### Full Example: Great Expectations Workflow Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx A complete script demonstrating the entire process from importing libraries to validating data with Great Expectations. ```python # Import required modules from GX library. import great_expectations as gx import pandas as pd # Create Data Context. context = gx.get_context() # Import sample data into Pandas DataFrame. df = pd.read_csv( "https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv" ) # Connect to data. # Create Data Source, Data Asset, Batch Definition, and Batch. data_source = context.data_sources.add_pandas("pandas") data_asset = data_source.add_dataframe_asset(name="pd dataframe asset") batch_definition = data_asset.add_batch_definition_whole_dataframe("batch definition") batch = batch_definition.get_batch(batch_parameters={"dataframe": df}) # Create Expectation. expectation = gx.expectations.ExpectColumnValuesToBeBetween( column="passenger_count", min_value=1, max_value=6, severity="warning" ) # Validate Batch using Expectation. validation_result = batch.validate(expectation) print(validation_result) ``` -------------------------------- ### Get Data Context Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Initialize a Data Context, which is the main entry point for GX functionalities. ```python context = gx.get_context() ``` -------------------------------- ### Import Great Expectations and Pandas Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Import the necessary libraries to start using Great Expectations and Pandas for data manipulation. ```python import great_expectations as gx import pandas as pd ``` -------------------------------- ### update_data_docs_site Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Updates an existing Data Docs Site with new configuration. This method allows modification of existing site settings, with example configurations available in the "Host and share Data Docs" guides. ```APIDOC ## update_data_docs_site ### Description Update an existing Data Docs Site. ### Signature ```python update_data_docs_site(site_name: str, site_config: DataDocsSiteConfigTypedDict) -> None ``` ### Parameters #### Parameters - **site_name** (str) - Required - Site name to update. - **site_config** (DataDocsSiteConfigTypedDict) - Required - Config dict that replaces the existing. ``` -------------------------------- ### Example Checkpoint Result Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx This JSON structure represents a typical result from a Great Expectations checkpoint, highlighting validation failures. ```json { "type": "expect_column_values_to_be_between", "success": false, "severity": "critical", "kwargs": { "batch_id": "postgres db-taxi data", "column": "fare_amount", "min_value": 0.0 }, "result": { "element_count": 20000, "unexpected_count": 14, "unexpected_percent": 0.06999999999999999, "partial_unexpected_list": [ -0.01, -52.0, -0.1, -5.5, -3.0, -52.0, -4.0, -0.01, -52.0, -0.1, -5.5, -3.0, -52.0, -4.0 ], "missing_count": 0, "missing_percent": 0.0, "unexpected_percent_total": 0.06999999999999999, "unexpected_percent_nonmissing": 0.06999999999999999, "partial_unexpected_counts": [ { "value": -52.0, "count": 4 }, { "value": -5.5, "count": 2 }, { "value": -4.0, "count": 2 }, { "value": -3.0, "count": 2 }, { "value": -0.1, "count": 2 }, { "value": -0.01, "count": 2 } ] } } ``` -------------------------------- ### Get Asset from AlloyDatasource Source: https://docs.greatexpectations.io/docs/reference/api/datasource/fluent/AlloyDatasource_class Retrieves a specific DataAsset from the AlloyDatasource by its name. ```python get_asset( name: str ) → great_expectations.datasource.fluent.interfaces._DataAssetT ``` -------------------------------- ### Create and Run Checkpoint Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Set up a Checkpoint to execute the validation against the data and print a summary of the results. ```python checkpoint = context.checkpoints.add( gx.checkpoint.checkpoint.Checkpoint( name="checkpoint", validation_definitions=[validation_definition] ) ) checkpoint_result = checkpoint.run() print(checkpoint_result.describe()) ``` -------------------------------- ### Connect to Data and Create a Batch Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Sets up a Pandas data source, adds a DataFrame asset, defines a batch definition for the entire DataFrame, and retrieves a batch for validation. ```python data_source = context.data_sources.add_pandas("pandas") data_asset = data_source.add_dataframe_asset(name="pd dataframe asset") batch_definition = data_asset.add_batch_definition_whole_dataframe("batch definition") batch = batch_definition.get_batch(batch_parameters={"dataframe": df}) ``` -------------------------------- ### List Data Docs Sites Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Lists all Data Docs Sites with their configurations. Returns a dictionary of site names and their configurations. ```python list_data_docs_sites() → dict[str, DataDocsSiteConfigTypedDict] ``` -------------------------------- ### view_validation_result Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Opens a validation result in a browser. This method is available starting from version 0.16.15. ```APIDOC ## view_validation_result ### Description Opens a validation result in a browser. ### Signature ```python view_validation_result(result: CheckpointResult) -> None ``` ### Parameters #### Parameters - **result** (CheckpointResult) - Required - The result of a Checkpoint run. ``` -------------------------------- ### Build Data Docs Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Builds Data Docs for the project. Can specify sites, resources, and dry run mode. Returns a dictionary of updated site names and their locations. ```python build_data_docs( site_names: list[str] | None = None, resource_identifiers: list[great_expectations.data_context.types.resource_identifiers.ExpectationSuiteIdentifier] | list[great_expectations.data_context.types.resource_identifiers.ValidationResultIdentifier] | None = None, dry_run: bool = False, build_index: bool = True ) → dict[str, str] ``` -------------------------------- ### ExpectationSuite Class Constructor Source: https://docs.greatexpectations.io/docs/reference/api/ExpectationSuite_class Initializes an ExpectationSuite with optional name, expectations, suite parameters, meta data, notes, and ID. Use this to create a new suite or load an existing one. ```python class great_expectations.ExpectationSuite( name: Optional[str] = None, expectations: Optional[Sequence[Union[dict, ExpectationConfiguration, Expectation]]] = None, suite_parameters: Optional[dict] = None, meta: Optional[dict] = None, notes: str | list[str] | None = None, id: Optional[str] = None ) ``` -------------------------------- ### Get Max Severity Failure Source: https://docs.greatexpectations.io/docs/reference/api/core/ExpectationSuiteValidationResult_class This method retrieves the maximum severity failure among the expectations in the validation result. It returns CRITICAL, WARNING, INFO, or None if no failures exist. ```python get_max_severity_failure() ``` -------------------------------- ### ExpectationSuite Constructor Source: https://docs.greatexpectations.io/docs/reference/api/ExpectationSuite_class Initializes an ExpectationSuite with a name, a collection of expectations, suite parameters, metadata, notes, and an ID. ```APIDOC ## ExpectationSuite Constructor ### Description Initializes an ExpectationSuite with a name, a collection of expectations, suite parameters, metadata, notes, and an ID. ### Parameters - **name** (Optional[str]) - Name of the Expectation Suite. - **expectations** (Optional[Sequence[Union[dict, ExpectationConfiguration, Expectation]]]) - Expectation Configurations to associate with this Expectation Suite. - **suite_parameters** (Optional[dict]) - Suite parameters to be substituted when evaluating Expectations. - **meta** (Optional[dict]) - Metadata related to the suite. - **notes** (str | list[str] | None) - Notes associated with the suite. - **id** (Optional[str]) - Great Expectations Cloud id for this Expectation Suite. ``` -------------------------------- ### Connect to Postgres and Add Data Asset Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Establish a connection to a PostgreSQL database and define a data asset for the 'nyc_taxi_data' table. ```python connection_string = "postgresql+psycopg2://try_gx:try_gx@postgres.workshops.greatexpectations.io/gx_example_db" data_source = context.data_sources.add_postgres( "postgres db", connection_string=connection_string ) data_asset = data_source.add_table_asset(name="taxi data", table_name="nyc_taxi_data") batch_definition = data_asset.add_batch_definition_whole_table("batch definition") batch = batch_definition.get_batch() ``` -------------------------------- ### run Source: https://docs.greatexpectations.io/docs/reference/api/ValidationDefinition_class Runs a validation using the configured data and suite. ```APIDOC ## Method run Runs a validation using the configured data and suite. ### Parameters * **checkpoint_id** (Optional[str]) - This is used by the checkpoints code when it runs a validation definition. Otherwise, it should be None. * **batch_parameters** (Optional[BatchParameters]) - The dictionary of parameters necessary for selecting the correct batch to run the validation on. The keys are strings that are determined by the BatchDefinition used to instantiate this ValidationDefinition. For example: * whole table -> None * yearly -> year * monthly -> year, month * daily -> year, month, day * **expectation_parameters** (Optional[SuiteParameterDict]) - A dictionary of parameters values for any expectations using parameterized values (the $PARAMETER syntax). The keys are the parameter names and the values are the values to be used for this validation run. * **result_format** (ResultFormatUnion) - A parameter controlling how much diagnostic information the result contains. * **run_id** (RunIdentifier | None) - An identifier for this run. Typically, this should be set to None and it will be generated by this call. ### Returns * **ExpectationSuiteValidationResult** - The result of the validation run. ``` -------------------------------- ### Import Great Expectations Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Import the necessary Great Expectations library to begin. ```python import great_expectations as gx ``` -------------------------------- ### Add Data Docs Site Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Adds a new Data Docs Site to the DataContext. Requires a site name and its configuration. ```python add_data_docs_site( site_name: str, site_config: DataDocsSiteConfigTypedDict ) → None ``` -------------------------------- ### Create a Great Expectations Data Context Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Initializes a Data Context, which is the entry point for interacting with Great Expectations components. ```python context = gx.get_context() ``` -------------------------------- ### Expectation Constructor Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class The base class for all Expectations. It initializes various properties that define an expectation's behavior, metadata, and rendering. ```APIDOC ## Expectation Constructor ### Description Initializes an Expectation object with optional parameters for ID, metadata, notes, result format, description, exception handling, rendered content, severity, and windows. ### Signature ```python Expectation( *, id: Optional[str] = None, meta: Optional[dict] = None, notes: Optional[Union[str, List[str]]] = None, result_format: Union[great_expectations.core.result_format.ResultFormat, dict] = ResultFormat.BASIC, description: Optional[str] = None, catch_exceptions: bool = False, rendered_content: Optional[List[great_expectations.render.components.RenderedAtomicContent]] = None, severity: great_expectations.expectations.metadata_types.FailureSeverity = FailureSeverity.CRITICAL, windows: Optional[List[great_expectations.expectations.window.Window]] = None ) ``` ### Parameters * **id** (Optional[str]) - Unique identifier for the expectation. * **meta** (Optional[dict]) - Metadata associated with the expectation. * **notes** (Optional[Union[str, List[str]]]) - Notes or explanations for the expectation. * **result_format** (Union[great_expectations.core.result_format.ResultFormat, dict]) - Specifies the format for the expectation's results. Defaults to ResultFormat.BASIC. * **description** (Optional[str]) - A human-readable description of the expectation. * **catch_exceptions** (bool) - Whether to catch exceptions during expectation execution. Defaults to False. * **rendered_content** (Optional[List[great_expectations.render.components.RenderedAtomicContent]]) - Content for rendering the expectation. * **severity** (great_expectations.expectations.metadata_types.FailureSeverity) - The severity level of the expectation. Defaults to FailureSeverity.CRITICAL. * **windows** (Optional[List[great_expectations.expectations.window.Window]]) - Defines windows for the expectation. ``` -------------------------------- ### list_data_docs_sites Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Lists all configured Data Docs Sites along with their configurations. This method provides an overview of all active Data Docs sites within the project. ```APIDOC ## list_data_docs_sites ### Description List all Data Docs Sites with configurations. ### Signature ```python list_data_docs_sites() -> dict[str, DataDocsSiteConfigTypedDict] ``` ### Returns #### Returns - **dict[str, DataDocsSiteConfigTypedDict]** - A dictionary containing the names and configurations of all Data Docs Sites. ``` -------------------------------- ### run Method Source: https://docs.greatexpectations.io/docs/reference/api/Checkpoint_class Runs the Checkpoint's underlying Validation Definitions and Actions. This method executes the validations defined within the checkpoint and triggers any associated actions. ```APIDOC ## run Method ### Description Runs the Checkpoint's underlying Validation Definitions and Actions. This method executes the validations defined within the checkpoint and triggers any associated actions. ### Parameters #### Path Parameters - **batch_parameters** (Optional[Dict[str, Any]]) - Optional - Parameters to be used when loading the Batch. - **expectation_parameters** (dict | None) - Optional - Parameters to be used when validating the Batch. - **run_id** (Optional[RunIdentifier]) - Optional - An optional unique identifier for the run. ### Returns - **CheckpointResult** (great_expectations.checkpoint.checkpoint.CheckpointResult) - A CheckpointResult object containing the results of the run. ### Raises - **CheckpointRunWithoutValidationDefinitionError** - If the Checkpoint is run without any Validation Definitions. - **CheckpointNotAddedError** - If the Checkpoint has not been added to the Store. - **CheckpointNotFreshError** - If the Checkpoint has been modified since it was last added to the Store. ``` -------------------------------- ### print_diagnostic_checklist Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class Runs self.run_diagnostics and generates a diagnostic checklist. This method is experimental and provides a wrapper for ExpectationDiagnostics.generate_checklist(). ```APIDOC ## print_diagnostic_checklist ### Description Runs self.run_diagnostics and generates a diagnostic checklist. This output is a thin wrapper for ExpectationDiagnostics.generate_checklist(). This method is experimental. ### Signature ```python print_diagnostic_checklist( diagnostics: Optional[ExpectationDiagnostics] = None, show_failed_tests: bool = False, backends: Optional[List[str]] = None, show_debug_messages: bool = False ) -> str ``` ### Parameters * **diagnostics** (Optional[ExpectationDiagnostics]) - If diagnostics are not provided, diagnostics will be ran on self. * **show_failed_tests** (bool) - If true, failing tests will be printed. * **backends** (Optional[List[str]]) - List of backends to pass to run_diagnostics. * **show_debug_messages** (bool) - If true, create a logger and pass to run_diagnostics. ``` -------------------------------- ### run Method Source: https://docs.greatexpectations.io/docs/reference/api/ValidationDefinition_class Executes a validation using the configured data and suite. It allows specifying batch parameters, expectation parameters, result format, and an optional checkpoint ID or run ID. ```python run( *, checkpoint_id: Optional[str] = None, batch_parameters: Optional[BatchParameters] = None, expectation_parameters: Optional[SuiteParameterDict] = None, result_format: ResultFormatUnion = ResultFormat.SUMMARY, run_id: RunIdentifier | None = None ) → ExpectationSuiteValidationResult ``` -------------------------------- ### build_data_docs Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Builds Data Docs for the project. This method can selectively build docs for specific sites or resources, and supports a dry run mode to preview buildable URLs without actual generation. ```APIDOC ## build_data_docs ### Description Build Data Docs for your project. ### Signature ```python build_data_docs(site_names: list[str] | None = None, resource_identifiers: list[great_expectations.data_context.types.resource_identifiers.ExpectationSuiteIdentifier] | list[great_expectations.data_context.types.resource_identifiers.ValidationResultIdentifier] | None = None, dry_run: bool = False, build_index: bool = True) -> dict[str, str] ``` ### Parameters #### Parameters - **site_names** (list[str] | None) - Optional - if specified, build data docs only for these sites, otherwise, build all the sites specified in the context's config. - **resource_identifiers** (list[ExpectationSuiteIdentifier] | list[ValidationResultIdentifier] | None) - Optional - a list of resource identifiers (ExpectationSuiteIdentifier, ValidationResultIdentifier). If specified, rebuild HTML (or other views the data docs sites are rendering) only for the resources in this list. This supports incremental build of data docs sites (e.g., when a new validation result is created) and avoids full rebuild. - **dry_run** (bool) - Optional - a flag, if True, the method returns a structure containing the URLs of the sites that would be built, but it does not build these sites. - **build_index** (bool) - Optional - a flag if False, skips building the index page. ### Returns #### Returns - **dict[str, str]** - A dictionary with the names of the updated data documentation sites as keys and the location info of their index.html files as values. ### Raises #### Raises - **ClassInstantiationError** - Site config in your Data Context config is not valid. ``` -------------------------------- ### Checkpoint Class Constructor Source: https://docs.greatexpectations.io/docs/reference/api/Checkpoint_class Defines the Checkpoint class with parameters for name, validation definitions, actions, result format, and an optional ID. Use this to instantiate a Checkpoint object. ```python class great_expectations.Checkpoint( *, name: str, validation_definitions: List[great_expectations.core.validation_definition.ValidationDefinition], actions: List[great_expectations.checkpoint.actions.ValidationAction] = None, result_format: Union[great_expectations.core.result_format.ResultFormat, dict, Literal['BOOLEAN_ONLY', 'BASIC', 'SUMMARY', 'COMPLETE']] = ResultFormat.SUMMARY, id: Optional[str] = None ) ``` -------------------------------- ### Checkpoint Run Method Source: https://docs.greatexpectations.io/docs/reference/api/Checkpoint_class Executes the Checkpoint's validation definitions and actions. It accepts optional batch parameters, expectation parameters, and a run ID. This method is crucial for initiating data validation. ```python run( batch_parameters: Optional[Dict[str, Any]] = None, expectation_parameters: dict | None = None, run_id: great_expectations.core.run_identifier.RunIdentifier | None = None ) → great_expectations.checkpoint.checkpoint.CheckpointResult ``` -------------------------------- ### Define Expectation Suite Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Create an Expectation Suite with two expectations: one for passenger count range (warning) and another for non-negative fare amount (critical). ```python suite = context.suites.add( gx.core.expectation_suite.ExpectationSuite(name="expectations") ) suite.add_expectation( gx.expectations.ExpectColumnValuesToBeBetween( column="passenger_count", min_value=1, max_value=6, severity="warning" ) ) suite.add_expectation( gx.expectations.ExpectColumnValuesToBeBetween( column="fare_amount", min_value=0, severity="critical" ) ) ``` -------------------------------- ### Load Sample Data into Pandas DataFrame Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Reads a CSV file from a URL into a Pandas DataFrame for use in Great Expectations. ```python df = pd.read_csv( "https://raw.githubusercontent.com/great-expectations/gx_tutorials/main/data/yellow_tripdata_sample_2019-01.csv" ) ``` -------------------------------- ### Expectation Class Parameters Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class Configuration options for the Expectation class. ```APIDOC ## Expectation Class Configuration ### Parameters - **raise_exceptions_for_backends** (Bool) - When True, raises an Exception if a backend fails to connect. - **ignore_suppress** (Bool) - When True, ignores the `suppress_test_for` list on Expectation sample tests. - **ignore_only_for** (Bool) - When True, ignores the `only_for` list on Expectation sample tests. - **for_gallery** (Bool) - When True, creates empty arrays to use as examples for the Expectation Diagnostics. - **debug_logger** (optional[logging.Logger]) - Logger object for sending debug messages. - **only_consider_these_backends** (optional[List[str]]) - Specifies backends to consider. - **context** (optional[AbstractDataContext]) - An instance of any child class of "AbstractDataContext". ``` -------------------------------- ### save() Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class Saves the current state of the Expectation. ```APIDOC ## save() ### Description Save the current state of this Expectation. ### Method ```python save() ``` ### Returns - **ExpectationDiagnostics** - An Expectation Diagnostics report object. ``` -------------------------------- ### save Method Source: https://docs.greatexpectations.io/docs/reference/api/Checkpoint_class Saves the current state of this Checkpoint. This method persists the current configuration and status of the checkpoint. ```APIDOC ## save Method ### Description Save the current state of this Checkpoint. This method persists the current configuration and status of the checkpoint. ### Returns - **None** ``` -------------------------------- ### Describe ExpectationSuiteValidationResult Source: https://docs.greatexpectations.io/docs/reference/api/core/ExpectationSuiteValidationResult_class This method returns a JSON string describing the ExpectationSuiteValidationResult. ```python describe() ``` -------------------------------- ### Add Validation Definition Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Link the data batch with the defined Expectation Suite by creating a Validation Definition. ```python validation_definition = context.validation_definitions.add( gx.core.validation_definition.ValidationDefinition( name="validation definition", data=batch_definition, suite=suite, ) ) ``` -------------------------------- ### AlloyDatasource Constructor Source: https://docs.greatexpectations.io/docs/reference/api/datasource/fluent/AlloyDatasource_class Initializes an AlloyDatasource object. This constructor is used to establish a connection to an Alloy database and define its associated data assets. ```APIDOC ## AlloyDatasource Constructor ### Description Initializes an AlloyDatasource object. This constructor is used to establish a connection to an Alloy database and define its associated data assets. ### Parameters - **name** (str) - Required - The name of this alloy datasource. - **connection_string** (Union[ConfigStr, PostgresDsn]) - Required - The connection string used to connect to the postgres database. For example: "postgresql+psycopg2://:@:/" - **assets** (Optional[List[Union[TableAsset, QueryAsset]]]) - Optional - An optional dictionary whose keys are TableAsset or QueryAsset names and whose values are TableAsset or QueryAsset objects. - **type** (Literal['alloy']) - Optional - Defaults to 'alloy'. - **id** (Optional[uuid.UUID]) - Optional - The unique identifier for the datasource. - **create_temp_table** (bool) - Optional - Defaults to False. - **kwargs** (Dict[str, Union[ConfigStr, Any]]) - Optional - Additional keyword arguments. ``` -------------------------------- ### get_asset Source: https://docs.greatexpectations.io/docs/reference/api/datasource/fluent/AlloyDatasource_class Returns the DataAsset referred to by asset_name. ```APIDOC ## get_asset ### Description Returns the DataAsset referred to by asset_name. ### Method get_asset ### Parameters - **name** (str) - Required - name of DataAsset sought. ### Returns - **_DataAssetT** - if named "DataAsset" object exists; otherwise, exception is raised. ``` -------------------------------- ### Validate Data Against Expectation Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Runs the defined expectation against the data batch and prints the validation result. ```python validation_result = batch.validate(expectation) print(validation_result) ``` -------------------------------- ### Checkpoint Result Summary Source: https://docs.greatexpectations.io/docs/core/introduction/try_gx Examine the output of a checkpoint run, which indicates the success or failure of expectations and provides statistics. ```json { "success": false, "statistics": { "evaluated_validations": 1, "success_percent": 0.0, "successful_validations": 0, "unsuccessful_validations": 1 }, "validation_results": [ { "success": false, "statistics": { "evaluated_expectations": 2, "successful_expectations": 1, "unsuccessful_expectations": 1, "success_percent": 50.0 }, "expectations": [ { "type": "expect_column_values_to_be_between", "success": true, "severity": "warning", "kwargs": { "batch_id": "postgres db-taxi data", "column": "passenger_count", "min_value": 1.0, "max_value": 6.0 }, "result": { "element_count": 20000, "unexpected_count": 0, "unexpected_percent": 0.0, "partial_unexpected_list": [], "missing_count": 0, "missing_percent": 0.0, "unexpected_percent_total": 0.0, "unexpected_percent_nonmissing": 0.0, "partial_unexpected_counts": [] } }, { ``` -------------------------------- ### AlloyDatasource Class Signature Source: https://docs.greatexpectations.io/docs/reference/api/datasource/fluent/AlloyDatasource_class Defines the structure and parameters for creating an AlloyDatasource instance. This includes type, name, connection string, and optional assets. ```python class great_expectations.datasource.fluent.AlloyDatasource( *, type: Literal['alloy'] = 'alloy', name: str, id: Optional[uuid.UUID] = None, assets: List[Union[great_expectations.datasource.fluent.sql_datasource.TableAsset, great_expectations.datasource.fluent.sql_datasource.QueryAsset]] = [], connection_string: Union[great_expectations.datasource.fluent.config_str.ConfigStr, pydantic.v1.networks.PostgresDsn], create_temp_table: bool = False, kwargs: Dict[ str, Union[great_expectations.datasource.fluent.config_str.ConfigStr, Any]] = {} ) ``` -------------------------------- ### print_diagnostic_checklist Method Signature Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class Signature for the print_diagnostic_checklist method, which runs diagnostics and generates a checklist. This method is experimental and wraps ExpectationDiagnostics.generate_checklist(). ```python print_diagnostic_checklist( diagnostics: Optional[ExpectationDiagnostics] = None, show_failed_tests: bool = False, backends: Optional[List[str]] = None, show_debug_messages: bool = False ) → str ``` -------------------------------- ### Update Project Config Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Updates the context's configuration with values from another config object. Returns the updated DataContextConfig. ```python update_project_config( project_config: Union[great_expectations.data_context.types.base.DataContextConfig, Mapping] ) → great_expectations.data_context.types.base.DataContextConfig ``` -------------------------------- ### save Source: https://docs.greatexpectations.io/docs/reference/api/ExpectationSuite_class Saves the current state of the ExpectationSuite. ```APIDOC ## save ### Description Save this ExpectationSuite. ### Signature ``` save() -> None ``` ``` -------------------------------- ### enable_analytics Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Enables or disables analytics for this DataContext. The setting can be preserved via context.variables.save() for non-ephemeral contexts. If set to None, it defaults to the GX_ANALYTICS_ENABLED environment variable. ```APIDOC ## enable_analytics ### Description Enable or disable analytics for this DataContext. ### Signature ```python enable_analytics(enable: Optional[bool]) -> None ``` ### Parameters #### Parameters - **enable** (Optional[bool]) - Optional - Boolean to enable or disable analytics. If None, uses the GX_ANALYTICS_ENABLED environment variable. ``` -------------------------------- ### Enable Analytics Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Enables or disables analytics for this DataContext. Can be preserved via context.variables.save(). If set to None, the GX_ANALYTICS_ENABLED environment variable will be used. ```python enable_analytics( enable: Optional[bool] ) → None ``` -------------------------------- ### Update Data Docs Site Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Updates an existing Data Docs Site with new configuration. Requires the site name and the new site config. ```python update_data_docs_site( site_name: str, site_config: DataDocsSiteConfigTypedDict ) → None ``` -------------------------------- ### to_json_dict Source: https://docs.greatexpectations.io/docs/reference/api/RunIdentifier_class Returns a JSON-serializable dictionary representation of the RunIdentifier object. ```APIDOC ## to_json_dict ### Description Returns a JSON-serializable dict representation of this RunIdentifier. ### Returns - **Dict[str, Optional[Union[Dict[str, Optional[Union[Dict[str, JSONValues], List[JSONValues], str, int, float, bool]]], List[Optional[Union[Dict[str, JSONValues], List[JSONValues], str, int, float, bool]]], str, int, float, bool]]]** - A JSON-serializable dict representation of this RunIdentifier. ``` -------------------------------- ### Checkpoint Class Initialization Source: https://docs.greatexpectations.io/docs/reference/api/Checkpoint_class Initializes a Checkpoint object. A Checkpoint is the primary means for validating data in a production deployment of Great Expectations. Checkpoints provide a convenient abstraction for running a number of validation definitions and triggering a set of actions to be taken after the validation step. ```APIDOC ## Checkpoint Class ### Description Initializes a Checkpoint object. A Checkpoint is the primary means for validating data in a production deployment of Great Expectations. Checkpoints provide a convenient abstraction for running a number of validation definitions and triggering a set of actions to be taken after the validation step. ### Parameters #### Path Parameters - **name** (str) - Required - The name of the checkpoint. - **validation_definitions** (List[ValidationDefinition]) - Required - List of validation definitions to be run. #### Query Parameters - **actions** (List[ValidationAction]) - Optional - List of actions to be taken after the validation definitions are run. - **result_format** (Union[ResultFormat, dict, Literal['BOOLEAN_ONLY', 'BASIC', 'SUMMARY', 'COMPLETE']]) - Optional - The format in which to return the results of the validation definitions. Default is ResultFormat.SUMMARY. - **id** (Optional[str]) - Optional - An optional unique identifier for the checkpoint. ``` -------------------------------- ### ExpectationSuiteValidationResult Statistics Source: https://docs.greatexpectations.io/docs/reference/api/core/ExpectationSuiteValidationResult_class This dictionary contains statistics about the validation run, such as the number of evaluated, successful, and unsuccessful expectations, and the success percentage. ```json { "evaluated_expectations": 14, "success_percent": 71.42857142857143, "successful_expectations": 10, "unsuccessful_expectations": 4 } ``` -------------------------------- ### ExpectationSuiteValidationResult Meta Information Source: https://docs.greatexpectations.io/docs/reference/api/core/ExpectationSuiteValidationResult_class The meta property provides details about the validation run, including active batch definition, batch markers, batch specification, checkpoint name, expectation suite name, Great Expectations version, run ID, and validation time. ```json { "active_batch_definition": { "batch_identifiers": {}, "data_asset_name": "taxi_data_1.csv", "data_connector_name": "default_inferred_data_connector_name", "datasource_name": "pandas" }, "batch_markers": { "ge_load_time": "20220727T154327.630107Z", "pandas_data_fingerprint": "c4f929e6d4fab001fedc9e075bf4b612" }, "batch_spec": { "path": "/Users/username/work/gx_example_projects/great_expectations/../data/taxi_data_1.csv" }, "checkpoint_name": "single_validation_checkpoint", "expectation_suite_name": "taxi_suite_1", "great_expectations_version": "0.15.15", "run_id": { "run_name": "20220727-114327-my-run-name-template", "run_time": "2022-07-27T11:43:27.625252+00:00" }, "validation_time": "20220727T154327.701100Z" } ``` -------------------------------- ### add_data_docs_site Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Adds a new Data Docs Site to the DataContext. This method allows for the configuration and registration of new sites for generating and hosting Data Docs. ```APIDOC ## add_data_docs_site ### Description Add a new Data Docs Site to the DataContext. ### Signature ```python add_data_docs_site(site_name: str, site_config: DataDocsSiteConfigTypedDict) -> None ``` ### Parameters #### Parameters - **site_name** (str) - Required - New site name to add. - **site_config** (DataDocsSiteConfigTypedDict) - Required - Config dict for the new site. ``` -------------------------------- ### AbstractDataContext Class Signature Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class The base class for all Data Contexts, encapsulating shared functionality and managing CRUD operations for core GX objects. ```python class great_expectations.data_context.AbstractDataContext( runtime_environment: Optional[dict] = None, user_agent_str: Optional[str] = None ) ``` -------------------------------- ### save Source: https://docs.greatexpectations.io/docs/reference/api/ValidationDefinition_class Save the current state of this ValidationDefinition. ```APIDOC ## Method save Save the current state of this ValidationDefinition. ### Returns * **None** ``` -------------------------------- ### Convert ExpectationSuite to JSON Dictionary Source: https://docs.greatexpectations.io/docs/reference/api/ExpectationSuite_class Returns a JSON-serializable dictionary representation of the ExpectationSuite. This is useful for serialization and storage. ```python to_json_dict() → Dict[str, JSONValues] ``` -------------------------------- ### RunIdentifier Class Source: https://docs.greatexpectations.io/docs/reference/api/RunIdentifier_class Initializes a RunIdentifier object. This object identifies a run (collection of validations) by run_name and run_time. ```APIDOC ## RunIdentifier ### Description Initializes a RunIdentifier object. This object identifies a run (collection of validations) by run_name and run_time. ### Parameters #### Parameters - **run_name** (Optional[str]) - A string or None. The name of the run. - **run_time** (Optional[Union[datetime.datetime, str]]) - A Datetime.datetime instance, a string, or None. The time the run occurred. ``` -------------------------------- ### RunIdentifier Class Signature Source: https://docs.greatexpectations.io/docs/reference/api/RunIdentifier_class Defines the RunIdentifier class with optional run_name and run_time parameters. ```python class great_expectations.RunIdentifier( run_name: Optional[str] = None, run_time: Optional[Union[datetime.datetime, str]] = None ) ``` -------------------------------- ### run_diagnostics Source: https://docs.greatexpectations.io/docs/reference/api/expectations/Expectation_class Produces a diagnostic report about this Expectation, useful for populating the Public Expectation Gallery and for developing new Expectations. ```APIDOC ## run_diagnostics ### Description Produce a diagnostic report about this Expectation. The current uses for this method's output are using the JSON structure to populate the Public Expectation Gallery and enabling a fast dev loop for developing new Expectations where the contributors can quickly check the completeness of their expectations. The contents of the report are captured in the ExpectationDiagnostics dataclass. ### Signature ```python run_diagnostics( raise_exceptions_for_backends: bool = False, ignore_suppress: bool = False, ignore_only_for: bool = False, for_gallery: bool = False, debug_logger: Optional[logging.Logger] = None, only_consider_these_backends: Optional[List[str]] = None, context: Optional[AbstractDataContext] = None ) -> ExpectationDiagnostics ``` ### Parameters * **raise_exceptions_for_backends** (bool) - If true, exceptions will be raised for backends. * **ignore_suppress** (bool) - If true, suppressions will be ignored. * **ignore_only_for** (bool) - If true, 'only_for' will be ignored. * **for_gallery** (bool) - If true, diagnostics are run for gallery purposes. * **debug_logger** (Optional[logging.Logger]) - A logger for debugging purposes. * **only_consider_these_backends** (Optional[List[str]]) - A list of backends to consider for diagnostics. * **context** (Optional[AbstractDataContext]) - The data context for running diagnostics. ``` -------------------------------- ### Delete Data Docs Site Source: https://docs.greatexpectations.io/docs/reference/api/data_context/AbstractDataContext_class Deletes an existing Data Docs Site from the DataContext. Requires the site name. ```python delete_data_docs_site( site_name: str ) ``` -------------------------------- ### to_json_dict Method Signature Source: https://docs.greatexpectations.io/docs/reference/api/RunIdentifier_class Provides the signature for the to_json_dict method, which returns a JSON-serializable dictionary representation of a RunIdentifier object. ```python to_json_dict() → Dict[str, Optional[Union[Dict[str, Optional[Union[Dict[str, JSONValues], List[JSONValues], str, int, float, bool]]], List[Optional[Union[Dict[str, JSONValues], List[JSONValues], str, int, float, bool]]], str, int, float, bool]]] ``` -------------------------------- ### Add Expectation to Suite Source: https://docs.greatexpectations.io/docs/reference/api/ExpectationSuite_class Adds a single Expectation to the ExpectationSuite. Ensure the expectation object is correctly formatted before adding. ```python add_expectation( expectation: _TExpectation ) → _TExpectation ```