Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2024
1 parent d2e735d commit c2ef944
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 48 deletions.
32 changes: 24 additions & 8 deletions gx-1.0.0a2/demos/notebooks/01-authoring_expectation_suites.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,26 @@
"context = gx.get_context(mode=\"file\")\n",
"\n",
"try:\n",
" datasource = context.sources.add_postgres(DATASOURCE_NAME, connection_string=DB_CONNECTION_STRING)\n",
" datasource = context.sources.add_postgres(\n",
" DATASOURCE_NAME, connection_string=DB_CONNECTION_STRING\n",
" )\n",
" data_asset = datasource.add_table_asset(name=ASSET_NAME, table_name=TABLE_NAME)\n",
" \n",
" batch_definition = data_asset.add_batch_definition_whole_table(BATCH_DEFINITION_NAME_WHOLE_TABLE)\n",
"\n",
" batch_definition = data_asset.add_batch_definition_whole_table(\n",
" BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
" )\n",
"\n",
" print(\"Created entities\")\n",
"\n",
"except exceptions.DataContextError:\n",
" datasource = context.get_datasource(DATASOURCE_NAME)\n",
" assert isinstance(datasource, Datasource)\n",
" data_asset = datasource.get_asset(asset_name=ASSET_NAME)\n",
" batch_definition = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE)\n",
" batch_definition = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
" )\n",
"\n",
" print(\"Entities alread exist - loaded them\")"
]
Expand All @@ -103,7 +111,9 @@
"metadata": {},
"outputs": [],
"source": [
"expectation = gxe.ExpectColumnMinToBeBetween(column=\"passenger_count\", min_value=4, max_value=5)\n",
"expectation = gxe.ExpectColumnMinToBeBetween(\n",
" column=\"passenger_count\", min_value=4, max_value=5\n",
")\n",
"batch = batch_definition.get_batch()\n",
"batch.validate(expectation)"
]
Expand Down Expand Up @@ -152,11 +162,15 @@
" suite = context.suites.add(ExpectationSuite(name=SUITE_NAME))\n",
"\n",
" suite.add_expectation(expectation)\n",
" expectation = suite.add_expectation(gxe.ExpectColumnValuesToBeBetween(column=\"passenger_count\", min_value=0, max_value=4))\n",
" expectation = suite.add_expectation(\n",
" gxe.ExpectColumnValuesToBeBetween(\n",
" column=\"passenger_count\", min_value=0, max_value=4\n",
" )\n",
" )\n",
" print(\"Expectation Suite created\")\n",
"except exceptions.DataContextError:\n",
" suite = context.suites.get(SUITE_NAME)\n",
" print(\"We've already added the suite\")\n"
" print(\"We've already added the suite\")"
]
},
{
Expand Down Expand Up @@ -195,7 +209,9 @@
"outputs": [],
"source": [
"suite = context.suites.get(SUITE_NAME)\n",
"expectation = next(e for e in suite.expectations if isinstance(e, gxe.ExpectColumnValuesToBeBetween))\n",
"expectation = next(\n",
" e for e in suite.expectations if isinstance(e, gxe.ExpectColumnValuesToBeBetween)\n",
")\n",
"expectation.max_value = 10\n",
"\n",
"results = batch.validate(suite)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
"\n",
"suite = context.suites.get(SUITE_NAME)\n",
"\n",
"batch_definition = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE)"
"batch_definition = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
")"
]
},
{
Expand Down Expand Up @@ -103,14 +107,18 @@
"outputs": [],
"source": [
"try:\n",
" checkpoint = context.checkpoints.add(Checkpoint(\n",
" name=CHECKPOINT_NAME,\n",
" validation_definitions=[\n",
" validation_definition,\n",
" ValidationDefinition(name=\"another\", data=batch_definition, suite=suite)\n",
" ],\n",
" actions=[UpdateDataDocsAction()]\n",
" ))\n",
" checkpoint = context.checkpoints.add(\n",
" Checkpoint(\n",
" name=CHECKPOINT_NAME,\n",
" validation_definitions=[\n",
" validation_definition,\n",
" ValidationDefinition(\n",
" name=\"another\", data=batch_definition, suite=suite\n",
" ),\n",
" ],\n",
" actions=[UpdateDataDocsAction()],\n",
" )\n",
" )\n",
"except exceptions.DataContextError:\n",
" checkpoint = context.checkpoints.get(name=CHECKPOINT_NAME)\n",
"\n",
Expand Down
23 changes: 16 additions & 7 deletions gx-1.0.0a2/demos/notebooks/03-sql_month_and_year.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,26 @@
"source": [
"try:\n",
" batch_def = data_asset.add_batch_definition_monthly(\n",
" BATCH_DEFINITION_NAME_PARTIONED,\n",
" column=\"tpep_pickup_datetime\"\n",
" BATCH_DEFINITION_NAME_PARTIONED, column=\"tpep_pickup_datetime\"\n",
" )\n",
" batch_def_desc = data_asset.add_batch_definition_monthly(\n",
" BATCH_DEFINITION_NAME_PARTIONED_DESC,\n",
" column=\"tpep_pickup_datetime\",\n",
" sort_ascending=False\n",
" sort_ascending=False,\n",
" )\n",
" print(\"Created BatchDefinitions\")\n",
"except DataContextError:\n",
" batch_def = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_PARTIONED)\n",
" batch_def_desc = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_PARTIONED_DESC)\n",
" print(\"Entities already exist\")\n"
" batch_def = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_PARTIONED\n",
" )\n",
" batch_def_desc = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_PARTIONED_DESC\n",
" )\n",
" print(\"Entities already exist\")"
]
},
{
Expand All @@ -111,7 +118,9 @@
"metadata": {},
"outputs": [],
"source": [
"validation_definition = ValidationDefinition(name=\"ephemeral validation definition\", data=batch_def_desc, suite=suite)\n",
"validation_definition = ValidationDefinition(\n",
" name=\"ephemeral validation definition\", data=batch_def_desc, suite=suite\n",
")\n",
"\n",
"results = validation_definition.run()\n",
"print(results.describe())"
Expand Down
32 changes: 24 additions & 8 deletions gx-1.0.0a4/demos/notebooks/01-authoring_expectation_suites.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,26 @@
"context = gx.get_context(mode=\"file\")\n",
"\n",
"try:\n",
" datasource = context.data_sources.add_postgres(DATASOURCE_NAME, connection_string=DB_CONNECTION_STRING)\n",
" datasource = context.data_sources.add_postgres(\n",
" DATASOURCE_NAME, connection_string=DB_CONNECTION_STRING\n",
" )\n",
" data_asset = datasource.add_table_asset(name=ASSET_NAME, table_name=TABLE_NAME)\n",
" \n",
" batch_definition = data_asset.add_batch_definition_whole_table(BATCH_DEFINITION_NAME_WHOLE_TABLE)\n",
"\n",
" batch_definition = data_asset.add_batch_definition_whole_table(\n",
" BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
" )\n",
"\n",
" print(\"Created entities\")\n",
"\n",
"except exceptions.DataContextError:\n",
" datasource = context.get_datasource(DATASOURCE_NAME)\n",
" assert isinstance(datasource, Datasource)\n",
" data_asset = datasource.get_asset(asset_name=ASSET_NAME)\n",
" batch_definition = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE)\n",
" batch_definition = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
" )\n",
"\n",
" print(\"Entities alread exist - loaded them\")"
]
Expand All @@ -103,7 +111,9 @@
"metadata": {},
"outputs": [],
"source": [
"expectation = gxe.ExpectColumnMinToBeBetween(column=\"passenger_count\", min_value=4, max_value=5)\n",
"expectation = gxe.ExpectColumnMinToBeBetween(\n",
" column=\"passenger_count\", min_value=4, max_value=5\n",
")\n",
"batch = batch_definition.get_batch()\n",
"batch.validate(expectation)"
]
Expand Down Expand Up @@ -152,11 +162,15 @@
" suite = context.suites.add(ExpectationSuite(name=SUITE_NAME))\n",
"\n",
" suite.add_expectation(expectation)\n",
" expectation = suite.add_expectation(gxe.ExpectColumnValuesToBeBetween(column=\"passenger_count\", min_value=0, max_value=4))\n",
" expectation = suite.add_expectation(\n",
" gxe.ExpectColumnValuesToBeBetween(\n",
" column=\"passenger_count\", min_value=0, max_value=4\n",
" )\n",
" )\n",
" print(\"Expectation Suite created\")\n",
"except exceptions.DataContextError:\n",
" suite = context.suites.get(SUITE_NAME)\n",
" print(\"We've already added the suite\")\n"
" print(\"We've already added the suite\")"
]
},
{
Expand Down Expand Up @@ -195,7 +209,9 @@
"outputs": [],
"source": [
"suite = context.suites.get(SUITE_NAME)\n",
"expectation = next(e for e in suite.expectations if isinstance(e, gxe.ExpectColumnValuesToBeBetween))\n",
"expectation = next(\n",
" e for e in suite.expectations if isinstance(e, gxe.ExpectColumnValuesToBeBetween)\n",
")\n",
"expectation.max_value = 10\n",
"\n",
"results = batch.validate(suite)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
"\n",
"suite = context.suites.get(SUITE_NAME)\n",
"\n",
"batch_definition = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE)"
"batch_definition = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_WHOLE_TABLE\n",
")"
]
},
{
Expand Down Expand Up @@ -103,14 +107,18 @@
"outputs": [],
"source": [
"try:\n",
" checkpoint = context.checkpoints.add(Checkpoint(\n",
" name=CHECKPOINT_NAME,\n",
" validation_definitions=[\n",
" validation_definition,\n",
" ValidationDefinition(name=\"another\", data=batch_definition, suite=suite)\n",
" ],\n",
" actions=[UpdateDataDocsAction(name=\"update_data_docs\")]\n",
" ))\n",
" checkpoint = context.checkpoints.add(\n",
" Checkpoint(\n",
" name=CHECKPOINT_NAME,\n",
" validation_definitions=[\n",
" validation_definition,\n",
" ValidationDefinition(\n",
" name=\"another\", data=batch_definition, suite=suite\n",
" ),\n",
" ],\n",
" actions=[UpdateDataDocsAction(name=\"update_data_docs\")],\n",
" )\n",
" )\n",
"except exceptions.DataContextError:\n",
" checkpoint = context.checkpoints.get(name=CHECKPOINT_NAME)\n",
"\n",
Expand Down
23 changes: 16 additions & 7 deletions gx-1.0.0a4/demos/notebooks/03-sql_month_and_year.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,26 @@
"source": [
"try:\n",
" batch_def = data_asset.add_batch_definition_monthly(\n",
" BATCH_DEFINITION_NAME_PARTIONED,\n",
" column=\"tpep_pickup_datetime\"\n",
" BATCH_DEFINITION_NAME_PARTIONED, column=\"tpep_pickup_datetime\"\n",
" )\n",
" batch_def_desc = data_asset.add_batch_definition_monthly(\n",
" BATCH_DEFINITION_NAME_PARTIONED_DESC,\n",
" column=\"tpep_pickup_datetime\",\n",
" sort_ascending=False\n",
" sort_ascending=False,\n",
" )\n",
" print(\"Created BatchDefinitions\")\n",
"except DataContextError:\n",
" batch_def = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_PARTIONED)\n",
" batch_def_desc = next(bd for bd in data_asset.batch_definitions if bd.name == BATCH_DEFINITION_NAME_PARTIONED_DESC)\n",
" print(\"Entities already exist\")\n"
" batch_def = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_PARTIONED\n",
" )\n",
" batch_def_desc = next(\n",
" bd\n",
" for bd in data_asset.batch_definitions\n",
" if bd.name == BATCH_DEFINITION_NAME_PARTIONED_DESC\n",
" )\n",
" print(\"Entities already exist\")"
]
},
{
Expand All @@ -104,7 +111,9 @@
"metadata": {},
"outputs": [],
"source": [
"validation_definition = ValidationDefinition(name=\"ephemeral validation definition\", data=batch_def_desc, suite=suite)\n",
"validation_definition = ValidationDefinition(\n",
" name=\"ephemeral validation definition\", data=batch_def_desc, suite=suite\n",
")\n",
"\n",
"results = validation_definition.run()\n",
"print(results.describe())"
Expand Down

0 comments on commit c2ef944

Please sign in to comment.