datacontract-cli 0.10.22__py3-none-any.whl → 0.10.24__py3-none-any.whl
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.
Potentially problematic release.
This version of datacontract-cli might be problematic. Click here for more details.
- datacontract/__init__.py +13 -0
- datacontract/catalog/catalog.py +2 -2
- datacontract/cli.py +20 -72
- datacontract/data_contract.py +5 -3
- datacontract/engines/data_contract_test.py +32 -7
- datacontract/engines/datacontract/check_that_datacontract_contains_valid_servers_configuration.py +2 -3
- datacontract/engines/fastjsonschema/s3/s3_read_files.py +3 -2
- datacontract/engines/soda/check_soda_execute.py +17 -4
- datacontract/engines/soda/connections/{duckdb.py → duckdb_connection.py} +66 -9
- datacontract/engines/soda/connections/kafka.py +3 -2
- datacontract/export/avro_converter.py +10 -3
- datacontract/export/bigquery_converter.py +1 -1
- datacontract/export/dbt_converter.py +13 -10
- datacontract/export/duckdb_type_converter.py +57 -0
- datacontract/export/odcs_v3_exporter.py +27 -7
- datacontract/export/protobuf_converter.py +163 -69
- datacontract/imports/avro_importer.py +31 -6
- datacontract/imports/csv_importer.py +111 -57
- datacontract/imports/importer.py +1 -0
- datacontract/imports/importer_factory.py +5 -0
- datacontract/imports/odcs_v3_importer.py +49 -7
- datacontract/imports/protobuf_importer.py +266 -0
- datacontract/lint/resolve.py +40 -12
- datacontract/model/data_contract_specification.py +2 -2
- datacontract/model/run.py +3 -0
- datacontract/output/__init__.py +0 -0
- datacontract/output/junit_test_results.py +135 -0
- datacontract/output/output_format.py +10 -0
- datacontract/output/test_results_writer.py +79 -0
- datacontract/templates/datacontract.html +2 -1
- datacontract/templates/index.html +2 -1
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info}/METADATA +279 -193
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info}/RECORD +37 -33
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info}/WHEEL +1 -1
- datacontract/export/csv_type_converter.py +0 -36
- datacontract/lint/linters/quality_schema_linter.py +0 -52
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info}/entry_points.txt +0 -0
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info/licenses}/LICENSE +0 -0
- {datacontract_cli-0.10.22.dist-info → datacontract_cli-0.10.24.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich import box
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.table import Table
|
|
7
|
+
|
|
8
|
+
from datacontract.model.run import Run
|
|
9
|
+
from datacontract.output.junit_test_results import write_junit_test_results
|
|
10
|
+
from datacontract.output.output_format import OutputFormat
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def write_test_result(run: Run, console: Console, output_format: OutputFormat, output_path: Path):
|
|
14
|
+
if output_format == OutputFormat.junit:
|
|
15
|
+
write_junit_test_results(run, console, output_path)
|
|
16
|
+
|
|
17
|
+
_print_table(run, console)
|
|
18
|
+
if run.result == "passed":
|
|
19
|
+
console.print(
|
|
20
|
+
f"🟢 data contract is valid. Run {len(run.checks)} checks. Took {(run.timestampEnd - run.timestampStart).total_seconds()} seconds."
|
|
21
|
+
)
|
|
22
|
+
elif run.result == "warning":
|
|
23
|
+
console.print("🟠 data contract has warnings. Found the following warnings:")
|
|
24
|
+
i = 1
|
|
25
|
+
for check in run.checks:
|
|
26
|
+
if check.result != "passed":
|
|
27
|
+
field = to_field(run, check)
|
|
28
|
+
if field:
|
|
29
|
+
field = field + " "
|
|
30
|
+
else:
|
|
31
|
+
field = ""
|
|
32
|
+
console.print(f"{i}) {field}{check.name}: {check.reason}")
|
|
33
|
+
i += 1
|
|
34
|
+
else:
|
|
35
|
+
console.print("🔴 data contract is invalid, found the following errors:")
|
|
36
|
+
i = 1
|
|
37
|
+
for check in run.checks:
|
|
38
|
+
if check.result != "passed":
|
|
39
|
+
field = to_field(run, check)
|
|
40
|
+
if field:
|
|
41
|
+
field = field + " "
|
|
42
|
+
else:
|
|
43
|
+
field = ""
|
|
44
|
+
console.print(f"{i}) {field}{check.name}: {check.reason}")
|
|
45
|
+
i += 1
|
|
46
|
+
raise typer.Exit(code=1)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _print_table(run, console):
|
|
50
|
+
table = Table(box=box.ROUNDED)
|
|
51
|
+
table.add_column("Result", no_wrap=True)
|
|
52
|
+
table.add_column("Check", max_width=100)
|
|
53
|
+
table.add_column("Field", max_width=32)
|
|
54
|
+
table.add_column("Details", max_width=50)
|
|
55
|
+
for check in sorted(run.checks, key=lambda c: (c.result or "", c.model or "", c.field or "")):
|
|
56
|
+
table.add_row(with_markup(check.result), check.name, to_field(run, check), check.reason)
|
|
57
|
+
console.print(table)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def to_field(run, check):
|
|
61
|
+
models = [c.model for c in run.checks]
|
|
62
|
+
if len(set(models)) > 1:
|
|
63
|
+
if check.field is None:
|
|
64
|
+
return check.model
|
|
65
|
+
return check.model + "." + check.field
|
|
66
|
+
else:
|
|
67
|
+
return check.field
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def with_markup(result):
|
|
71
|
+
if result == "passed":
|
|
72
|
+
return "[green]passed[/green]"
|
|
73
|
+
if result == "warning":
|
|
74
|
+
return "[yellow]warning[/yellow]"
|
|
75
|
+
if result == "failed":
|
|
76
|
+
return "[red]failed[/red]"
|
|
77
|
+
if result == "error":
|
|
78
|
+
return "[red]error[/red]"
|
|
79
|
+
return result
|
|
@@ -283,7 +283,8 @@
|
|
|
283
283
|
</div>
|
|
284
284
|
<div class="mt-8 md:order-1 md:mt-0">
|
|
285
285
|
<p class="text-center leading-5 text-gray-400">
|
|
286
|
-
Supported
|
|
286
|
+
Supported by <a href="https://datacontract-manager.com"
|
|
287
|
+
class="text-gray-400 hover:text-gray-500">Data Contract Manager</a>
|
|
287
288
|
</p>
|
|
288
289
|
</div>
|
|
289
290
|
</div>
|
|
@@ -190,7 +190,8 @@
|
|
|
190
190
|
</div>
|
|
191
191
|
<div class="mt-8 md:order-1 md:mt-0">
|
|
192
192
|
<p class="text-center leading-5 text-gray-400">
|
|
193
|
-
Supported
|
|
193
|
+
Supported by <a href="https://datacontract-manager.com"
|
|
194
|
+
class="text-gray-400 hover:text-gray-500">Data Contract Manager</a>
|
|
194
195
|
</p>
|
|
195
196
|
</div>
|
|
196
197
|
</div>
|