google-pso-data-validator 4.4.0__tar.gz → 5.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/PKG-INFO +48 -53
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/README.md +47 -52
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/__main__.py +18 -11
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/cli_tools.py +42 -33
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/combiner.py +15 -5
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/config_manager.py +18 -8
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/consts.py +1 -1
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/data_validation.py +28 -14
- google_pso_data_validator-5.0.0/data_validation/gcs_helper.py +94 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/metadata.py +2 -2
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/partition_builder.py +2 -2
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/query_builder/query_builder.py +13 -6
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/secret_manager.py +5 -0
- google_pso_data_validator-5.0.0/data_validation/state_manager.py +126 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/PKG-INFO +48 -53
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/SOURCES.txt +1 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/setup.py +1 -1
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_addon/operations.py +184 -15
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_db2/registry.py +2 -1
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_impala/api.py +2 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_teradata/__init__.py +20 -11
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_teradata/datatypes.py +7 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_teradata/registry.py +34 -1
- google-pso-data-validator-4.4.0/data_validation/state_manager.py +0 -277
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/LICENSE +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/app.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/client_info.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/clients.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/exceptions.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/jellyfish_distance.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/query_builder/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/query_builder/partition_row_builder.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/query_builder/random_row_builder.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/result_handlers/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/result_handlers/bigquery.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/result_handlers/text.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/schema_validation.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/validation_builder.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/dependency_links.txt +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/entry_points.txt +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/requires.txt +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/google_pso_data_validator.egg-info/top_level.txt +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/setup.cfg +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_addon/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_addon/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/client.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/compiler.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/registry.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/tests/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/tests/conftest.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_cloud_spanner/to_pandas.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_db2/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_db2/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_db2/compiler.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_db2/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_impala/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mssql/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mssql/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mssql/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mysql/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mysql/base_sql_compiler/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mysql/base_sql_compiler/select_builder.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_mysql/compiler.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_oracle/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_oracle/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_oracle/compiler.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_oracle/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_oracle/registry.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_postgres/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_postgres/client.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_postgres/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_redshift/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_redshift/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_redshift/compiler.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_snowflake/__init__.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_snowflake/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_snowflake/datatypes.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_teradata/api.py +0 -0
- {google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/third_party/ibis/ibis_teradata/compiler.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: google-pso-data-validator
|
|
3
|
-
Version:
|
|
3
|
+
Version: 5.0.0
|
|
4
4
|
Summary: A package to enable easy data validation
|
|
5
5
|
Home-page: https://github.com/pypa/sampleproject
|
|
6
6
|
Author: Dylan Hercher
|
|
@@ -154,7 +154,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
154
154
|
[--max COLUMNS] Comma separated list of columns for max or * for all numeric
|
|
155
155
|
[--avg COLUMNS] Comma separated list of columns for avg or * for all numeric
|
|
156
156
|
[--std COLUMNS] Comma separated list of columns for stddev_samp or * for all numeric
|
|
157
|
-
[--exclude-columns or -ec]
|
|
157
|
+
[--exclude-columns or -ec]
|
|
158
|
+
Flag to indicate the list of columns provided should be excluded and not included.
|
|
158
159
|
[--bq-result-handler or -bqrh PROJECT_ID.DATASET.TABLE]
|
|
159
160
|
BigQuery destination for validation results. Defaults to stdout.
|
|
160
161
|
See: *Validation Reports* section
|
|
@@ -171,7 +172,7 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
171
172
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
172
173
|
See: *Filters* section
|
|
173
174
|
[--config-file or -c CONFIG_FILE]
|
|
174
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
175
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
175
176
|
See: *Running DVT with YAML Configuration Files* section
|
|
176
177
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
177
178
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
@@ -179,8 +180,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
179
180
|
Float value. Maximum pct_difference allowed for validation to be considered a success. Defaults to 0.0
|
|
180
181
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
181
182
|
Comma-separated key value pair labels for the run.
|
|
182
|
-
[--format or -fmt]
|
|
183
|
-
Defaults to table.
|
|
183
|
+
[--format or -fmt FORMAT]
|
|
184
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
184
185
|
[--filter-status or -fs STATUSES_LIST]
|
|
185
186
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
186
187
|
```
|
|
@@ -241,14 +242,14 @@ data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
|
241
242
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
242
243
|
See: *Filters* section
|
|
243
244
|
[--config-file or -c CONFIG_FILE]
|
|
244
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
245
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
245
246
|
See: *Running DVT with YAML Configuration Files* section
|
|
246
247
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
247
248
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
248
249
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
249
250
|
Comma-separated key value pair labels for the run.
|
|
250
|
-
[--format or -fmt]
|
|
251
|
-
Defaults to table.
|
|
251
|
+
[--format or -fmt FORMAT]
|
|
252
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
252
253
|
[--use-random-row or -rr]
|
|
253
254
|
Finds a set of random rows of the first primary key supplied.
|
|
254
255
|
[--random-row-batch-size or -rbs]
|
|
@@ -321,7 +322,7 @@ data-validation (--verbose or -v) (--log-level or -ll) validate schema
|
|
|
321
322
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
322
323
|
Service account to use for BigQuery result handler output.
|
|
323
324
|
[--config-file or -c CONFIG_FILE]
|
|
324
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
325
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
325
326
|
See: *Running DVT with YAML Configuration Files* section
|
|
326
327
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
327
328
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
@@ -368,21 +369,22 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query col
|
|
|
368
369
|
[--max COLUMNS] Comma separated list of columns for max or * for all numeric
|
|
369
370
|
[--avg COLUMNS] Comma separated list of columns for avg or * for all numeric
|
|
370
371
|
[--std COLUMNS] Comma separated list of columns for stddev_samp or * for all numeric
|
|
371
|
-
[--exclude-columns or -ec]
|
|
372
|
+
[--exclude-columns or -ec]
|
|
373
|
+
Flag to indicate the list of columns provided should be excluded and not included.
|
|
372
374
|
[--bq-result-handler or -bqrh PROJECT_ID.DATASET.TABLE]
|
|
373
375
|
BigQuery destination for validation results. Defaults to stdout.
|
|
374
376
|
See: *Validation Reports* section
|
|
375
377
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
376
378
|
Service account to use for BigQuery result handler output.
|
|
377
379
|
[--config-file or -c CONFIG_FILE]
|
|
378
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
380
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
379
381
|
See: *Running DVT with YAML Configuration Files* section
|
|
380
382
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
381
383
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
382
384
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
383
385
|
Comma-separated key value pair labels for the run.
|
|
384
|
-
[--format or -fmt]
|
|
385
|
-
Defaults to table.
|
|
386
|
+
[--format or -fmt FORMAT]
|
|
387
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
386
388
|
[--filter-status or -fs STATUSES_LIST]
|
|
387
389
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
388
390
|
```
|
|
@@ -437,14 +439,14 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query row
|
|
|
437
439
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
438
440
|
Service account to use for BigQuery result handler output.
|
|
439
441
|
[--config-file or -c CONFIG_FILE]
|
|
440
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
442
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
441
443
|
See: *Running DVT with YAML Configuration Files* section
|
|
442
444
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
443
445
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
444
446
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
445
447
|
Comma-separated key value pair labels for the run.
|
|
446
|
-
[--format or -fmt]
|
|
447
|
-
Defaults to table.
|
|
448
|
+
[--format or -fmt FORMAT]
|
|
449
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
448
450
|
[--filter-status or -fs STATUSES_LIST]
|
|
449
451
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
450
452
|
```
|
|
@@ -481,59 +483,51 @@ For example, this flag can be used as follows:
|
|
|
481
483
|
|
|
482
484
|
Running DVT with YAML configuration files is the recommended approach if:
|
|
483
485
|
* you want to customize the configuration for any given validation OR
|
|
484
|
-
* you want to run DVT at scale (i.e.
|
|
485
|
-
Nearly every validation command can take the argument `-c <file-name>` (the `generate-table-partitions` command takes `-cdir <directory-name>`) where one or more yaml files are produced. These yaml files can be modified for custom validations.
|
|
486
|
+
* you want to run DVT at scale (i.e. run multiple validations sequentially or in parallel)
|
|
486
487
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
my_bq_conn -tbls bigquery-public-data.new_york_citibike.citibike_trips -c
|
|
490
|
-
citibike.yaml`.
|
|
488
|
+
We recommend generating YAML configs with the `--config-file <file-name>` flag when running a validation command, which supports
|
|
489
|
+
GCS and local paths.
|
|
491
490
|
|
|
492
|
-
|
|
493
|
-
env variable if that has been set; otherwise, it is saved to wherever the tool is run.
|
|
494
|
-
|
|
495
|
-
You can now edit the YAML file if, for example, the `new_york_citibike` table is
|
|
496
|
-
stored in datasets that have different names in the source and target systems.
|
|
497
|
-
Once the file is updated and saved, the following command runs the
|
|
498
|
-
validation:
|
|
491
|
+
You can use the `data-validation configs` command to run and view YAMLs.
|
|
499
492
|
|
|
500
493
|
```
|
|
501
|
-
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
494
|
+
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
495
|
+
[--config-file or -c CONFIG_FILE]
|
|
496
|
+
Path to YAML config file to run. Supports local and GCS paths.
|
|
497
|
+
[--config-dir or -cdir CONFIG_DIR]
|
|
498
|
+
Directory path containing YAML configs to be run sequentially. Supports local and GCS paths.
|
|
499
|
+
[--dry-run or -dr] If this flag is present, prints the source and target SQL generated in lieu of running the validation.
|
|
500
|
+
[--kube-completions or -kc]
|
|
501
|
+
Flag to indicate usage in Kubernetes index completion mode.
|
|
502
|
+
See *Scaling DVT* section
|
|
502
503
|
```
|
|
503
504
|
|
|
504
|
-
You can also specify a directory to read from using the --config-dir (or -cdir) flag. All yaml files in that directory will be run as validations. Support both local and GCS paths. For example:
|
|
505
505
|
```
|
|
506
|
-
data-validation configs
|
|
507
|
-
|
|
508
|
-
|
|
506
|
+
data-validation configs list
|
|
507
|
+
[--config-dir or -cdir CONFIG_DIR]
|
|
508
|
+
GCS or local directory from which to list validation YAML configs. Defaults to current local directory.
|
|
509
|
+
```
|
|
509
510
|
|
|
510
|
-
|
|
511
|
+
```
|
|
512
|
+
data-validation configs get
|
|
513
|
+
[--config-file or -c CONFIG_FILE] GCS or local path of validation YAML to print.
|
|
511
514
|
```
|
|
512
515
|
|
|
513
516
|
View the complete YAML file for a Grouped Column validation on the
|
|
514
517
|
[Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md#sample-yaml-config-grouped-column-validation) page.
|
|
515
518
|
|
|
516
|
-
You can view a list of all saved validation YAML files using `data-validation configs list`, and print a YAML config using `data-validation configs get -c citibike.yaml`.
|
|
517
|
-
#### Scaling DVT to run 10's to 1000's of validations concurrently
|
|
518
|
-
The above example `configs run -cdir` shows how you can run multiple validations with one command. If the directory used has been created by `generate-table-partitions`, you will have partition files numbered from `0000.yaml` to `<partno-1>.yaml`, where `<partno>` is the total number of partitions. These can be run as mentioned above and the partitions will be validated in order. This could take a long time if the number of partitions is large.
|
|
519
519
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
where GCS_DIRECTORY = CONFIG_DIR/SOURCE_SCHEMA.SOURCE_TABLE, where CONFIG_DIR, SOURCE_SCHEMA and SOURCE_TABLE are
|
|
527
|
-
the arguments provided to generate-table-partitions to generate the partition yamls. GCS_DIRECTORY is the directory
|
|
528
|
-
where the partition files numbered 0000.yaml to <partno-1>.yaml are stored.
|
|
529
|
-
```
|
|
530
|
-
If you are not familiar with Kubernetes or Cloud Run Jobs, review the [internal docs](docs/internal/kubernetes_jobs.md) for an overview of the orchestration of multiple validations.
|
|
520
|
+
### Scaling DVT
|
|
521
|
+
|
|
522
|
+
You can scale DVT for large table validations by running the tool in a distributed manner. To optimize the validation speed for large tables, you can use GKE Jobs ([Google Kubernetes Jobs](https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-workloads-overview#batch_jobs)) or [Cloud Run Jobs](https://cloud.google.com/run/docs/create-jobs). If you are not familiar with Kubernetes or Cloud Run Jobs, see [Scaling DVT with Distributed Jobs](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/internal/distributed_jobs.md) for a detailed overview.
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
We recommend first generating table partitions with the `generate-table-partitions` command for your large tables. Then, use Cloud Run or GKE to distribute validating each chunk in parallel. See the [Cloud Run Jobs Quickstart sample](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples/cloud_run_jobs) to get started.
|
|
531
526
|
|
|
532
|
-
|
|
527
|
+
When running DVT in a distributed fashion, both the `--kube-completions` and `--config-dir` flags are required. The `--kube-completions` flag specifies that the validation is being run in indexed completion mode in Kubernetes or as multiple independent tasks in Cloud Run. If the `-kc` option is used and you are not running in indexed mode, you will receive a warning and the container will process all the validations sequentially. If the `-kc` option is used and a config directory is not provided (i.e. a `--config-file` is provided instead), a warning is issued.
|
|
533
528
|
|
|
534
|
-
|
|
529
|
+
The `--config-dir` flag will specify the directory with the YAML files to be executed in parallel. If you used `generate-table-partitions` to generate the YAMLs, this would be the directory where the partition files numbered `0000.yaml` to `<partition_num - 1>.yaml` are stored i.e (`gs://my_config_dir/source_schema.source_table/`). When creating your Cloud Run Job, set the number of tasks equal to the number of table partitions so the task index matches the YAML file to be validated. When executed, each Cloud Run task will validate a partition in parallel.
|
|
535
530
|
|
|
536
|
-
By default, each partition validation is retried up to 3 times if there is an error. In Kubernetes and Cloud Run, you can set the parallelism to the number you want. Keep in mind that if you are validating 1000's of partitions in parallel, you may find that setting the parallelism too high (say 100) may result in timeouts and slow down the validation.
|
|
537
531
|
|
|
538
532
|
### Validation Reports
|
|
539
533
|
|
|
@@ -638,7 +632,8 @@ with calculated fields as shown in [this example](https://github.com/GoogleCloud
|
|
|
638
632
|
|
|
639
633
|
Filters let you apply a WHERE statement to your validation query (ie. `SELECT *
|
|
640
634
|
FROM table WHERE created_at > 30 days ago AND region_id = 71;`). The filter is
|
|
641
|
-
written in the syntax of the given source
|
|
635
|
+
written in the syntax of the given source and must reference columns in the
|
|
636
|
+
underlying table, not projected DVT expressions.
|
|
642
637
|
|
|
643
638
|
Note that you are writing the query to execute, which does not have to match
|
|
644
639
|
between source and target as long as the results can be expected to align. If
|
|
@@ -106,7 +106,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
106
106
|
[--max COLUMNS] Comma separated list of columns for max or * for all numeric
|
|
107
107
|
[--avg COLUMNS] Comma separated list of columns for avg or * for all numeric
|
|
108
108
|
[--std COLUMNS] Comma separated list of columns for stddev_samp or * for all numeric
|
|
109
|
-
[--exclude-columns or -ec]
|
|
109
|
+
[--exclude-columns or -ec]
|
|
110
|
+
Flag to indicate the list of columns provided should be excluded and not included.
|
|
110
111
|
[--bq-result-handler or -bqrh PROJECT_ID.DATASET.TABLE]
|
|
111
112
|
BigQuery destination for validation results. Defaults to stdout.
|
|
112
113
|
See: *Validation Reports* section
|
|
@@ -123,7 +124,7 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
123
124
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
124
125
|
See: *Filters* section
|
|
125
126
|
[--config-file or -c CONFIG_FILE]
|
|
126
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
127
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
127
128
|
See: *Running DVT with YAML Configuration Files* section
|
|
128
129
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
129
130
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
@@ -131,8 +132,8 @@ data-validation (--verbose or -v) (--log-level or -ll) validate column
|
|
|
131
132
|
Float value. Maximum pct_difference allowed for validation to be considered a success. Defaults to 0.0
|
|
132
133
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
133
134
|
Comma-separated key value pair labels for the run.
|
|
134
|
-
[--format or -fmt]
|
|
135
|
-
Defaults to table.
|
|
135
|
+
[--format or -fmt FORMAT]
|
|
136
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
136
137
|
[--filter-status or -fs STATUSES_LIST]
|
|
137
138
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
138
139
|
```
|
|
@@ -193,14 +194,14 @@ data-validation (--verbose or -v) (--log-level or -ll) validate row
|
|
|
193
194
|
If target filter is not provided, the source filter will run on source and target tables.
|
|
194
195
|
See: *Filters* section
|
|
195
196
|
[--config-file or -c CONFIG_FILE]
|
|
196
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
197
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
197
198
|
See: *Running DVT with YAML Configuration Files* section
|
|
198
199
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
199
200
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
200
201
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
201
202
|
Comma-separated key value pair labels for the run.
|
|
202
|
-
[--format or -fmt]
|
|
203
|
-
Defaults to table.
|
|
203
|
+
[--format or -fmt FORMAT]
|
|
204
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
204
205
|
[--use-random-row or -rr]
|
|
205
206
|
Finds a set of random rows of the first primary key supplied.
|
|
206
207
|
[--random-row-batch-size or -rbs]
|
|
@@ -273,7 +274,7 @@ data-validation (--verbose or -v) (--log-level or -ll) validate schema
|
|
|
273
274
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
274
275
|
Service account to use for BigQuery result handler output.
|
|
275
276
|
[--config-file or -c CONFIG_FILE]
|
|
276
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
277
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
277
278
|
See: *Running DVT with YAML Configuration Files* section
|
|
278
279
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
279
280
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
@@ -320,21 +321,22 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query col
|
|
|
320
321
|
[--max COLUMNS] Comma separated list of columns for max or * for all numeric
|
|
321
322
|
[--avg COLUMNS] Comma separated list of columns for avg or * for all numeric
|
|
322
323
|
[--std COLUMNS] Comma separated list of columns for stddev_samp or * for all numeric
|
|
323
|
-
[--exclude-columns or -ec]
|
|
324
|
+
[--exclude-columns or -ec]
|
|
325
|
+
Flag to indicate the list of columns provided should be excluded and not included.
|
|
324
326
|
[--bq-result-handler or -bqrh PROJECT_ID.DATASET.TABLE]
|
|
325
327
|
BigQuery destination for validation results. Defaults to stdout.
|
|
326
328
|
See: *Validation Reports* section
|
|
327
329
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
328
330
|
Service account to use for BigQuery result handler output.
|
|
329
331
|
[--config-file or -c CONFIG_FILE]
|
|
330
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
332
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
331
333
|
See: *Running DVT with YAML Configuration Files* section
|
|
332
334
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
333
335
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
334
336
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
335
337
|
Comma-separated key value pair labels for the run.
|
|
336
|
-
[--format or -fmt]
|
|
337
|
-
Defaults to table.
|
|
338
|
+
[--format or -fmt FORMAT]
|
|
339
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
338
340
|
[--filter-status or -fs STATUSES_LIST]
|
|
339
341
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
340
342
|
```
|
|
@@ -389,14 +391,14 @@ data-validation (--verbose or -v) (--log-level or -ll) validate custom-query row
|
|
|
389
391
|
[--service-account or -sa PATH_TO_SA_KEY]
|
|
390
392
|
Service account to use for BigQuery result handler output.
|
|
391
393
|
[--config-file or -c CONFIG_FILE]
|
|
392
|
-
YAML Config File Path to be used for storing validations and other features.
|
|
394
|
+
YAML Config File Path to be used for storing validations and other features. Supports GCS and local paths.
|
|
393
395
|
See: *Running DVT with YAML Configuration Files* section
|
|
394
396
|
[--config-file-json or -cj CONFIG_FILE_JSON]
|
|
395
397
|
JSON Config File Path to be used for storing validations only for application purposes.
|
|
396
398
|
[--labels or -l KEY1=VALUE1,KEY2=VALUE2]
|
|
397
399
|
Comma-separated key value pair labels for the run.
|
|
398
|
-
[--format or -fmt]
|
|
399
|
-
Defaults to table.
|
|
400
|
+
[--format or -fmt FORMAT]
|
|
401
|
+
Format for stdout output. Supported formats are (text, csv, json, table). Defaults to table.
|
|
400
402
|
[--filter-status or -fs STATUSES_LIST]
|
|
401
403
|
Comma separated list of statuses to filter the validation results. Supported statuses are (success, fail). If no list is provided, all statuses are returned.
|
|
402
404
|
```
|
|
@@ -433,59 +435,51 @@ For example, this flag can be used as follows:
|
|
|
433
435
|
|
|
434
436
|
Running DVT with YAML configuration files is the recommended approach if:
|
|
435
437
|
* you want to customize the configuration for any given validation OR
|
|
436
|
-
* you want to run DVT at scale (i.e.
|
|
437
|
-
Nearly every validation command can take the argument `-c <file-name>` (the `generate-table-partitions` command takes `-cdir <directory-name>`) where one or more yaml files are produced. These yaml files can be modified for custom validations.
|
|
438
|
+
* you want to run DVT at scale (i.e. run multiple validations sequentially or in parallel)
|
|
438
439
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
my_bq_conn -tbls bigquery-public-data.new_york_citibike.citibike_trips -c
|
|
442
|
-
citibike.yaml`.
|
|
440
|
+
We recommend generating YAML configs with the `--config-file <file-name>` flag when running a validation command, which supports
|
|
441
|
+
GCS and local paths.
|
|
443
442
|
|
|
444
|
-
|
|
445
|
-
env variable if that has been set; otherwise, it is saved to wherever the tool is run.
|
|
446
|
-
|
|
447
|
-
You can now edit the YAML file if, for example, the `new_york_citibike` table is
|
|
448
|
-
stored in datasets that have different names in the source and target systems.
|
|
449
|
-
Once the file is updated and saved, the following command runs the
|
|
450
|
-
validation:
|
|
443
|
+
You can use the `data-validation configs` command to run and view YAMLs.
|
|
451
444
|
|
|
452
445
|
```
|
|
453
|
-
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
446
|
+
data-validation (--verbose or -v) (--log-level or -ll) configs run
|
|
447
|
+
[--config-file or -c CONFIG_FILE]
|
|
448
|
+
Path to YAML config file to run. Supports local and GCS paths.
|
|
449
|
+
[--config-dir or -cdir CONFIG_DIR]
|
|
450
|
+
Directory path containing YAML configs to be run sequentially. Supports local and GCS paths.
|
|
451
|
+
[--dry-run or -dr] If this flag is present, prints the source and target SQL generated in lieu of running the validation.
|
|
452
|
+
[--kube-completions or -kc]
|
|
453
|
+
Flag to indicate usage in Kubernetes index completion mode.
|
|
454
|
+
See *Scaling DVT* section
|
|
454
455
|
```
|
|
455
456
|
|
|
456
|
-
You can also specify a directory to read from using the --config-dir (or -cdir) flag. All yaml files in that directory will be run as validations. Support both local and GCS paths. For example:
|
|
457
457
|
```
|
|
458
|
-
data-validation configs
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
data-validation configs list
|
|
459
|
+
[--config-dir or -cdir CONFIG_DIR]
|
|
460
|
+
GCS or local directory from which to list validation YAML configs. Defaults to current local directory.
|
|
461
|
+
```
|
|
461
462
|
|
|
462
|
-
|
|
463
|
+
```
|
|
464
|
+
data-validation configs get
|
|
465
|
+
[--config-file or -c CONFIG_FILE] GCS or local path of validation YAML to print.
|
|
463
466
|
```
|
|
464
467
|
|
|
465
468
|
View the complete YAML file for a Grouped Column validation on the
|
|
466
469
|
[Examples](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/examples.md#sample-yaml-config-grouped-column-validation) page.
|
|
467
470
|
|
|
468
|
-
You can view a list of all saved validation YAML files using `data-validation configs list`, and print a YAML config using `data-validation configs get -c citibike.yaml`.
|
|
469
|
-
#### Scaling DVT to run 10's to 1000's of validations concurrently
|
|
470
|
-
The above example `configs run -cdir` shows how you can run multiple validations with one command. If the directory used has been created by `generate-table-partitions`, you will have partition files numbered from `0000.yaml` to `<partno-1>.yaml`, where `<partno>` is the total number of partitions. These can be run as mentioned above and the partitions will be validated in order. This could take a long time if the number of partitions is large.
|
|
471
471
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
where GCS_DIRECTORY = CONFIG_DIR/SOURCE_SCHEMA.SOURCE_TABLE, where CONFIG_DIR, SOURCE_SCHEMA and SOURCE_TABLE are
|
|
479
|
-
the arguments provided to generate-table-partitions to generate the partition yamls. GCS_DIRECTORY is the directory
|
|
480
|
-
where the partition files numbered 0000.yaml to <partno-1>.yaml are stored.
|
|
481
|
-
```
|
|
482
|
-
If you are not familiar with Kubernetes or Cloud Run Jobs, review the [internal docs](docs/internal/kubernetes_jobs.md) for an overview of the orchestration of multiple validations.
|
|
472
|
+
### Scaling DVT
|
|
473
|
+
|
|
474
|
+
You can scale DVT for large table validations by running the tool in a distributed manner. To optimize the validation speed for large tables, you can use GKE Jobs ([Google Kubernetes Jobs](https://cloud.google.com/kubernetes-engine/docs/how-to/deploying-workloads-overview#batch_jobs)) or [Cloud Run Jobs](https://cloud.google.com/run/docs/create-jobs). If you are not familiar with Kubernetes or Cloud Run Jobs, see [Scaling DVT with Distributed Jobs](https://github.com/GoogleCloudPlatform/professional-services-data-validator/blob/develop/docs/internal/distributed_jobs.md) for a detailed overview.
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
We recommend first generating table partitions with the `generate-table-partitions` command for your large tables. Then, use Cloud Run or GKE to distribute validating each chunk in parallel. See the [Cloud Run Jobs Quickstart sample](https://github.com/GoogleCloudPlatform/professional-services-data-validator/tree/develop/samples/cloud_run_jobs) to get started.
|
|
483
478
|
|
|
484
|
-
|
|
479
|
+
When running DVT in a distributed fashion, both the `--kube-completions` and `--config-dir` flags are required. The `--kube-completions` flag specifies that the validation is being run in indexed completion mode in Kubernetes or as multiple independent tasks in Cloud Run. If the `-kc` option is used and you are not running in indexed mode, you will receive a warning and the container will process all the validations sequentially. If the `-kc` option is used and a config directory is not provided (i.e. a `--config-file` is provided instead), a warning is issued.
|
|
485
480
|
|
|
486
|
-
|
|
481
|
+
The `--config-dir` flag will specify the directory with the YAML files to be executed in parallel. If you used `generate-table-partitions` to generate the YAMLs, this would be the directory where the partition files numbered `0000.yaml` to `<partition_num - 1>.yaml` are stored i.e (`gs://my_config_dir/source_schema.source_table/`). When creating your Cloud Run Job, set the number of tasks equal to the number of table partitions so the task index matches the YAML file to be validated. When executed, each Cloud Run task will validate a partition in parallel.
|
|
487
482
|
|
|
488
|
-
By default, each partition validation is retried up to 3 times if there is an error. In Kubernetes and Cloud Run, you can set the parallelism to the number you want. Keep in mind that if you are validating 1000's of partitions in parallel, you may find that setting the parallelism too high (say 100) may result in timeouts and slow down the validation.
|
|
489
483
|
|
|
490
484
|
### Validation Reports
|
|
491
485
|
|
|
@@ -590,7 +584,8 @@ with calculated fields as shown in [this example](https://github.com/GoogleCloud
|
|
|
590
584
|
|
|
591
585
|
Filters let you apply a WHERE statement to your validation query (ie. `SELECT *
|
|
592
586
|
FROM table WHERE created_at > 30 days ago AND region_id = 71;`). The filter is
|
|
593
|
-
written in the syntax of the given source
|
|
587
|
+
written in the syntax of the given source and must reference columns in the
|
|
588
|
+
underlying table, not projected DVT expressions.
|
|
594
589
|
|
|
595
590
|
Note that you are writing the query to execute, which does not have to match
|
|
596
591
|
between source and target as long as the results can be expected to align. If
|
{google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/__main__.py
RENAMED
|
@@ -48,7 +48,10 @@ def _get_arg_config_file(args):
|
|
|
48
48
|
"""Return String YAML config file path."""
|
|
49
49
|
if not args.config_file:
|
|
50
50
|
raise ValueError("YAML Config File was not supplied.")
|
|
51
|
-
|
|
51
|
+
elif not args.config_file.endswith(".yaml"):
|
|
52
|
+
raise ValueError(
|
|
53
|
+
f"Invalid YAML config name: {args.config_file}. Provide YAML file extension."
|
|
54
|
+
)
|
|
52
55
|
return args.config_file
|
|
53
56
|
|
|
54
57
|
|
|
@@ -56,12 +59,15 @@ def _get_arg_config_file_json(args):
|
|
|
56
59
|
"""Return String JSON config file path."""
|
|
57
60
|
if not args.config_file_json:
|
|
58
61
|
raise ValueError("JSON Config File was not supplied.")
|
|
59
|
-
|
|
62
|
+
elif not args.config_file_json.endswith(".json"):
|
|
63
|
+
raise ValueError(
|
|
64
|
+
f"Invalid JSON config name: {args.config_file_json}. Provide JSON file extension."
|
|
65
|
+
)
|
|
60
66
|
return args.config_file_json
|
|
61
67
|
|
|
62
68
|
|
|
63
69
|
def get_aggregate_config(args, config_manager: ConfigManager):
|
|
64
|
-
"""Return list of
|
|
70
|
+
"""Return list of formatted aggregation objects.
|
|
65
71
|
|
|
66
72
|
Args:
|
|
67
73
|
config_manager (ConfigManager): Validation config manager instance.
|
|
@@ -350,16 +356,17 @@ def config_runner(args):
|
|
|
350
356
|
setattr(args, "config_dir", None)
|
|
351
357
|
setattr(args, "config_file", config_file_path)
|
|
352
358
|
config_managers = build_config_managers_from_yaml(args, config_file_path)
|
|
359
|
+
run_validations(args, config_managers)
|
|
353
360
|
else:
|
|
354
361
|
if args.kube_completions:
|
|
355
362
|
logging.warning(
|
|
356
363
|
"--kube-completions or -kc specified, however not running in Kubernetes Job completion, check your command line."
|
|
357
364
|
)
|
|
358
|
-
|
|
359
|
-
config_file_names = mgr.list_validations_in_dir(args.config_dir)
|
|
365
|
+
config_file_names = cli_tools.list_validations(config_dir=args.config_dir)
|
|
360
366
|
config_managers = []
|
|
361
367
|
for file in config_file_names:
|
|
362
|
-
config_managers
|
|
368
|
+
config_managers = build_config_managers_from_yaml(args, file)
|
|
369
|
+
run_validations(args, config_managers)
|
|
363
370
|
else:
|
|
364
371
|
if args.kube_completions:
|
|
365
372
|
logging.warning(
|
|
@@ -367,13 +374,12 @@ def config_runner(args):
|
|
|
367
374
|
)
|
|
368
375
|
config_file_path = _get_arg_config_file(args)
|
|
369
376
|
config_managers = build_config_managers_from_yaml(args, config_file_path)
|
|
370
|
-
|
|
371
|
-
run_validations(args, config_managers)
|
|
377
|
+
run_validations(args, config_managers)
|
|
372
378
|
|
|
373
379
|
|
|
374
380
|
def build_config_managers_from_yaml(args, config_file_path):
|
|
375
381
|
"""Returns List[ConfigManager] instances ready to be executed."""
|
|
376
|
-
if
|
|
382
|
+
if args.config_dir:
|
|
377
383
|
yaml_configs = cli_tools.get_validation(config_file_path, args.config_dir)
|
|
378
384
|
else:
|
|
379
385
|
yaml_configs = cli_tools.get_validation(config_file_path)
|
|
@@ -616,7 +622,7 @@ def store_json_config_file(args, config_managers):
|
|
|
616
622
|
"""
|
|
617
623
|
json_config = convert_config_to_json(config_managers)
|
|
618
624
|
config_file_path = _get_arg_config_file_json(args)
|
|
619
|
-
cli_tools.
|
|
625
|
+
cli_tools.store_validation(config_file_path, json_config)
|
|
620
626
|
|
|
621
627
|
|
|
622
628
|
def partition_and_store_config_files(args: Namespace) -> None:
|
|
@@ -672,7 +678,8 @@ def run_validation_configs(args):
|
|
|
672
678
|
if args.validation_config_cmd == "run":
|
|
673
679
|
config_runner(args)
|
|
674
680
|
elif args.validation_config_cmd == "list":
|
|
675
|
-
|
|
681
|
+
config_dir = args.config_dir or "./"
|
|
682
|
+
cli_tools.print_validations_in_dir(config_dir=config_dir)
|
|
676
683
|
elif args.validation_config_cmd == "get":
|
|
677
684
|
# Get and print yaml file config.
|
|
678
685
|
yaml = cli_tools.get_validation(_get_arg_config_file(args))
|
{google-pso-data-validator-4.4.0 → google_pso_data_validator-5.0.0}/data_validation/cli_tools.py
RENAMED
|
@@ -49,10 +49,12 @@ import json
|
|
|
49
49
|
import logging
|
|
50
50
|
import sys
|
|
51
51
|
import uuid
|
|
52
|
+
import os
|
|
52
53
|
from argparse import Namespace
|
|
53
54
|
from typing import Dict, List
|
|
55
|
+
from yaml import Dumper, Loader, dump, load
|
|
54
56
|
|
|
55
|
-
from data_validation import clients, consts, state_manager
|
|
57
|
+
from data_validation import clients, consts, state_manager, gcs_helper
|
|
56
58
|
|
|
57
59
|
CONNECTION_SOURCE_FIELDS = {
|
|
58
60
|
"BigQuery": [
|
|
@@ -328,7 +330,15 @@ def _configure_validation_config_parser(subparsers):
|
|
|
328
330
|
configs_subparsers = validation_config_parser.add_subparsers(
|
|
329
331
|
dest="validation_config_cmd"
|
|
330
332
|
)
|
|
331
|
-
|
|
333
|
+
list_parser = configs_subparsers.add_parser(
|
|
334
|
+
"list", help="List your validation configs"
|
|
335
|
+
)
|
|
336
|
+
list_parser.add_argument(
|
|
337
|
+
"--config-dir",
|
|
338
|
+
"-cdir",
|
|
339
|
+
help="Directory path from which to list validation YAML configs.",
|
|
340
|
+
)
|
|
341
|
+
|
|
332
342
|
run_parser = configs_subparsers.add_parser(
|
|
333
343
|
"run", help="Run your validation configs"
|
|
334
344
|
)
|
|
@@ -1073,47 +1083,46 @@ def get_connection(connection_name):
|
|
|
1073
1083
|
return mgr.get_connection_config(connection_name)
|
|
1074
1084
|
|
|
1075
1085
|
|
|
1076
|
-
def store_validation(validation_file_name,
|
|
1077
|
-
"""Store the validation
|
|
1078
|
-
|
|
1079
|
-
mgr.create_validation_yaml(validation_file_name, yaml_config)
|
|
1086
|
+
def store_validation(validation_file_name, config, include_log=True):
|
|
1087
|
+
"""Store the validation config under the given name."""
|
|
1088
|
+
validation_path = gcs_helper.get_validation_path(validation_file_name)
|
|
1080
1089
|
|
|
1090
|
+
if validation_file_name.endswith(".yaml"):
|
|
1091
|
+
config_str = dump(config, Dumper=Dumper)
|
|
1092
|
+
elif validation_file_name.endswith("json"):
|
|
1093
|
+
config_str = json.dumps(config)
|
|
1094
|
+
else:
|
|
1095
|
+
raise ValueError(f"Invalid validation file name: {validation_file_name}")
|
|
1081
1096
|
|
|
1082
|
-
|
|
1083
|
-
"""Store the validation JSON config under the given name."""
|
|
1084
|
-
mgr = state_manager.StateManager()
|
|
1085
|
-
mgr.create_validation_json(validation_file_name, json_config)
|
|
1097
|
+
gcs_helper.write_file(validation_path, config_str, include_log=include_log)
|
|
1086
1098
|
|
|
1087
1099
|
|
|
1088
|
-
def
|
|
1089
|
-
"""
|
|
1090
|
-
|
|
1091
|
-
|
|
1100
|
+
def get_validation(name: str, config_dir: str = None):
|
|
1101
|
+
"""Return validation YAML config."""
|
|
1102
|
+
if config_dir:
|
|
1103
|
+
validation_path = os.path.join(config_dir, name)
|
|
1104
|
+
else:
|
|
1105
|
+
validation_path = gcs_helper.get_validation_path(name)
|
|
1092
1106
|
|
|
1107
|
+
validation_bytes = gcs_helper.read_file(validation_path)
|
|
1108
|
+
return load(validation_bytes, Loader=Loader)
|
|
1093
1109
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1110
|
+
|
|
1111
|
+
def list_validations(config_dir="./"):
|
|
1112
|
+
"""List all saved validation YAMLs in a directory."""
|
|
1113
|
+
logging.info(f"Looking for validations in path {config_dir}")
|
|
1114
|
+
if gcs_helper._is_gcs_path(config_dir):
|
|
1115
|
+
if not config_dir.endswith("/"):
|
|
1116
|
+
config_dir += "/"
|
|
1117
|
+
files = gcs_helper.list_gcs_directory(config_dir)
|
|
1099
1118
|
else:
|
|
1100
|
-
|
|
1101
|
-
obj_depth = len(validation_name.split("/"))
|
|
1102
|
-
gcs_prefix = "/".join(validation_name.split("/")[: obj_depth - 1])
|
|
1103
|
-
mgr = state_manager.StateManager(file_system_root_path=gcs_prefix)
|
|
1104
|
-
return mgr.get_validation_config(
|
|
1105
|
-
validation_name.split("/")[obj_depth - 1], gcs_prefix
|
|
1106
|
-
)
|
|
1107
|
-
else:
|
|
1108
|
-
mgr = state_manager.StateManager()
|
|
1109
|
-
return mgr.get_validation_config(validation_name)
|
|
1119
|
+
files = os.listdir(config_dir)
|
|
1110
1120
|
|
|
1121
|
+
return [file_name for file_name in files if file_name.endswith(".yaml")]
|
|
1111
1122
|
|
|
1112
|
-
def list_validations():
|
|
1113
|
-
"""List all saved validation YAMLs."""
|
|
1114
|
-
mgr = state_manager.StateManager()
|
|
1115
|
-
validations = mgr.list_validations()
|
|
1116
1123
|
|
|
1124
|
+
def print_validations_in_dir(config_dir="./"):
|
|
1125
|
+
validations = list_validations(config_dir=config_dir)
|
|
1117
1126
|
logging.info("Validation YAMLs found:")
|
|
1118
1127
|
for validation_name in validations:
|
|
1119
1128
|
logging.info(validation_name)
|