Skip to main content
Version: 1.2.2

FileDataContext

class great_expectations.data_context.FileDataContext(project_config: Optional[DataContextConfig] = None, context_root_dir: Optional[PathStr] = None, project_root_dir: Optional[PathStr] = None, runtime_environment: Optional[dict] = None)#

Subclass of AbstractDataContext that contains functionality necessary to work in a filesystem-backed environment.

classmethod _create(project_root_dir: Optional[PathStr] = None, runtime_environment: Optional[dict] = None) SerializableDataContext#

Build a new great_expectations directory and DataContext object in the provided project_root_dir.

create will create a new “great_expectations” directory in the provided folder, provided one does not already exist. Then, it will initialize a new DataContext in that folder and write the resulting config.

Relevant Documentation Links

Data Context

Parameters
  • project_root_dir – path to the root directory in which to create a new great_expectations directory

  • usage_statistics_enabled – boolean directive specifying whether or not to gather usage statistics

  • runtime_environment – a dictionary of config variables that override both those set in config_variables.yml and the environment

Returns

DataContext

add_data_docs_site(site_name: str, site_config: DataDocsSiteConfigTypedDict) None#

Add a new Data Docs Site to the DataContext.

New in version 0.17.2.

Example site config dicts can be found in our “Host and share Data Docs” guides.

Parameters
  • site_name – New site name to add.

  • site_config – Config dict for the new site.

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]#

Build Data Docs for your project.

Relevant Documentation Links
Parameters
  • site_names – if specified, build data docs only for these sites, otherwise, build all the sites specified in the context’s config

  • resource_identifiers – 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 – 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 – a flag if False, skips building the index page

Returns

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

ClassInstantiationError – Site config in your Data Context config is not valid.

property checkpoints: great_expectations.core.factory.checkpoint_factory.CheckpointFactory#
property data_sources: great_expectations.datasource.fluent.sources.DataSourceManager#
delete_data_docs_site(site_name: str)#

Delete an existing Data Docs Site.

New in version 0.17.2.

Parameters

site_name – Site name to delete.

enable_analytics(enable: Optional[bool]) None#

Enable or disable analytics for this DataContext. With non-ephemeral contexts, this can be preserved via context.variables.save().

If set to None, the GX_ANALYTICS_ENABLED environment variable will be used.

list_data_docs_sites() dict[str, DataDocsSiteConfigTypedDict]#

List all Data Docs Sites with configurations.

New in version 0.17.2.

property suites: great_expectations.core.factory.suite_factory.SuiteFactory#

update_data_docs_site(site_name: str, site_config: DataDocsSiteConfigTypedDict) None#

Update an existing Data Docs Site.

New in version 0.17.2.

Example site config dicts can be found in our “Host and share Data Docs” guides.

Parameters
  • site_name – Site name to update.

  • site_config – Config dict that replaces the existing.

update_project_config(project_config: Union[great_expectations.data_context.types.base.DataContextConfig, Mapping]) great_expectations.data_context.types.base.DataContextConfig#

Update the context’s config with the values from another config object.

Parameters

project_config – The config to use to update the context’s internal state.

Returns

The updated project config.

property validation_definitions: great_expectations.core.factory.validation_definition_factory.ValidationDefinitionFactory#
view_validation_result(result: CheckpointResult) None#

New in version 0.16.15.

Opens a validation result in a browser.

Parameters

result – The result of a Checkpoint run.