Керування компонентами

Вступ до контролю якості даних із Great Expectations

Davina Moossazadeh

Data Scientist

Компоненти

Компоненти GX — це класи Python, що представляють дані та сутності валідації

  • Data Context
  • Data Sources & Data Assets
  • Batch Definitions & Batches
  • Expectations
  • Expectation Suites
  • Validation Definitions
  • Checkpoints & Actions
  • Data Docs
1 https://docs.greatexpectations.io/docs/core/introduction/gx_overview
Вступ до контролю якості даних із Great Expectations

Керування компонентами в GX

Data Sources:

  • під'єднуються до даних і містять Data Assets

Expectation Suites:

  • містять Expectations

Validation Definitions:

  • перевіряють Expectations на даних

Checkpoints:

  • групують і автоматизують Validations

context.data_sources

$$

context.suites

$$

context.validation_definitions

$$

context.checkpoints

Вступ до контролю якості даних із Great Expectations

Додавання компонентів

Expectation Suite:

suite = context.suites.add(suite)

Validation Definition:

validation_definition = context.validation_definitions.add(validation_definition)

Checkpoint:

checkpoint = context.checkpoints.add(
    checkpoint=checkpoint
)
Вступ до контролю якості даних із Great Expectations

Додавання Data Source

data_source = context.data_sources.add_<TYPE_NAME>()

1 https://docs.greatexpectations.io/docs/core/connect_to_data/
Вступ до контролю якості даних із Great Expectations

Додавання pandas Data Source

Скористайтеся .add_pandas(), щоб швидко налаштувати Data Source для датафреймів pandas:

data_source = context.data_sources.add_pandas(
    name="my_pandas_datasource"
)
Вступ до контролю якості даних із Great Expectations

Отримання компонентів

Отримуйте компоненти за допомогою .get(), указавши параметр name:

context.<COMPONENT>s.get(

name: str )
data_source = context.data_sources.get(

name="my_pandas_datasource" )
print(data_source)
id: 46c91f1b-1db9-4351-b5dd-83e038c0f511
name: 'my_pandas_datasource'
type: pandas
Вступ до контролю якості даних із Great Expectations

Отримання компонентів

Data Sources:

context.data_sources.get(
    name="my_pandas_datasource"
)

Expectation Suites:

context.suites.get(
    name="my_suite"
)

Validation Definitions:

context.validation_definitions.get(
    name="my_validation_definition"
)

Checkpoints:

context.checkpoints.get(
    name="my_checkpoint"
)
Вступ до контролю якості даних із Great Expectations

Список компонентів

Використовуйте .all(), щоб перелічити всі компоненти у вашому Data Context, з їхніми назвами та метаданими:

context.<COMPONENT>s.all()
data_sources = context.data_sources.all()

print(data_sources)
{
    'my_pandas_datasource': PandasDatasource(
        type='pandas',
        name='my_pandas_datasource', 
        id=UUID('c22b16f7-6945-400e-932f-026cbd63b112'), 
        assets=[]
    )
}
Вступ до контролю якості даних із Great Expectations

Список компонентів

Data Sources:

context.data_sources.all()

Expectation Suites:

context.suites.all()

Validation Definitions:

context.validation_definitions.all()

Checkpoints:

context.checkpoints.all()
Вступ до контролю якості даних із Great Expectations

Видалення компонентів

Використовуйте .delete(), щоб видаляти компоненти, указавши їхнє name:

context.<COMPONENT>s.delete(

name: str )
context.data_sources.delete(
    name="my_pandas_datasource"
)

print(context.data_sources.all())
{}
Вступ до контролю якості даних із Great Expectations

Видалення компонентів

Data Sources:

context.data_sources.delete(
    name="my_pandas_datasource"
)

Expectation Suites:

context.suites.delete(
    name="my_suite"
)

Validation Definitions:

context.validation_definitions.delete(
    name="my_validation_definition"
)

Checkpoints:

context.checkpoints.delete(
    name="my_checkpoint"
)
Вступ до контролю якості даних із Great Expectations

Шпаргалка

Додайте компонент до Data Context:

context.data_sources.add(data_source)

context.suites.add(suite)

context.validation_definitions.add(
    validation_definition
)

context.checkpoints.add(checkpoint)

Отримати компонент:

.get(name: str)

Перелічити компоненти:

.all()

Видалити компонент:

.delete(name: str)
Вступ до контролю якості даних із Great Expectations

Давайте потренуємось!

Вступ до контролю якості даних із Great Expectations

Preparing Video For Download...