Gestionarea componentelor

Introducere în calitatea datelor cu Great Expectations

Davina Moossazadeh

Data Scientist

Componente

Componente GX - clase Python ce reprezintă entități de date și validare

  • 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
Introducere în calitatea datelor cu Great Expectations

Gestionarea componentelor în GX

Data Sources:

  • se conectează la date și conțin Data Assets

Expectation Suites:

  • grupează Expectations

Validation Definitions:

  • validează Expectations față de date

Checkpoints:

  • grupează și automatizează validările

context.data_sources

$$

context.suites

$$

context.validation_definitions

$$

context.checkpoints

Introducere în calitatea datelor cu Great Expectations

Adăugarea componentelor

Expectation Suite:

suite = context.suites.add(suite)

Validation Definition:

validation_definition = context.validation_definitions.add(validation_definition)

Checkpoint:

checkpoint = context.checkpoints.add(
    checkpoint=checkpoint
)
Introducere în calitatea datelor cu Great Expectations

Adăugarea unui Data Source

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

1 https://docs.greatexpectations.io/docs/core/connect_to_data/
Introducere în calitatea datelor cu Great Expectations

Adăugarea unui Data Source pandas

Folosiți .add_pandas() pentru a configura ușor un Data Source pentru pandas DataFrames:

data_source = context.data_sources.add_pandas(
    name="my_pandas_datasource"
)
Introducere în calitatea datelor cu Great Expectations

Recuperarea componentelor

Recuperați componentele cu .get() specificând parametrul 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
Introducere în calitatea datelor cu Great Expectations

Recuperarea componentelor

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"
)
Introducere în calitatea datelor cu Great Expectations

Listarea componentelor

Folosiți .all() pentru a lista toate componentele din Data Context, inclusiv numele și metadatele acestora:

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=[]
    )
}
Introducere în calitatea datelor cu Great Expectations

Listarea componentelor

Data Sources:

context.data_sources.all()

Expectation Suites:

context.suites.all()

Validation Definitions:

context.validation_definitions.all()

Checkpoints:

context.checkpoints.all()
Introducere în calitatea datelor cu Great Expectations

Ștergerea componentelor

Folosiți .delete() pentru a elimina componente specificând numele acestora:

context.<COMPONENT>s.delete(

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

print(context.data_sources.all())
{}
Introducere în calitatea datelor cu Great Expectations

Ștergerea componentelor

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"
)
Introducere în calitatea datelor cu Great Expectations

Fișă de referință

Adăugați o componentă în Data Context:

context.data_sources.add(data_source)

context.suites.add(suite)

context.validation_definitions.add(
    validation_definition
)

context.checkpoints.add(checkpoint)

Recuperați o componentă:

.get(name: str)

Listați componentele:

.all()

Ștergeți o componentă:

.delete(name: str)
Introducere în calitatea datelor cu Great Expectations

Să exersăm!

Introducere în calitatea datelor cu Great Expectations

Preparing Video For Download...