Skip to content

Commit bf67a4a

Browse files
Merge pull request #53 from DataKitchen/release/4.38.3
Release/4.38.3
2 parents 5951f5b + 006fc4f commit bf67a4a

File tree

255 files changed

+4874
-4948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+4874
-4948
lines changed

deploy/testgen-base.dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.12.7-alpine3.20
1+
FROM python:3.12-alpine3.22
22

33
ENV LANG=C.UTF-8
44
ENV LC_ALL=C.UTF-8
@@ -14,7 +14,7 @@ RUN apk update && apk upgrade && apk add --no-cache \
1414
cmake \
1515
musl-dev \
1616
gfortran \
17-
linux-headers=6.6-r0 \
17+
linux-headers=6.14.2-r0 \
1818
# Tools needed for installing the MSSQL ODBC drivers \
1919
curl \
2020
gpg \
@@ -25,7 +25,7 @@ RUN apk update && apk upgrade && apk add --no-cache \
2525
unixodbc=2.3.12-r0 \
2626
unixodbc-dev=2.3.12-r0 \
2727
# Pinned versions for security
28-
xz=5.6.2-r1
28+
xz=5.8.1-r0
2929

3030
RUN apk add --no-cache \
3131
--repository https://dl-cdn.alpinelinux.org/alpine/v3.21/community \
@@ -48,7 +48,6 @@ RUN apk del \
4848
cmake \
4949
musl-dev \
5050
gfortran \
51-
curl \
5251
gpg \
5352
linux-headers \
5453
openblas-dev \

deploy/testgen.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG TESTGEN_BASE_LABEL=v7
1+
ARG TESTGEN_BASE_LABEL=v9
22

33
FROM datakitchen/dataops-testgen-base:${TESTGEN_BASE_LABEL} AS release-image
44

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "dataops-testgen"
11-
version = "4.32.5"
11+
version = "4.38.3"
1212
description = "DataKitchen's Data Quality DataOps TestGen"
1313
authors = [
1414
{ "name" = "DataKitchen, Inc.", "email" = "info@datakitchen.io" },
@@ -60,6 +60,8 @@ dependencies = [
6060
"streamlit-pydantic==0.6.0",
6161
"cron-converter==1.2.1",
6262
"cron-descriptor==2.0.5",
63+
"pybars3==0.9.7",
64+
"azure-identity==1.25.1",
6365

6466
# Pinned to match the manually compiled libs or for security
6567
"pyarrow==18.1.0",

testgen/__main__.py

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
import subprocess
55
import sys
66
from dataclasses import dataclass, field
7+
from datetime import UTC, datetime, timedelta
78

89
import click
910
from click.core import Context
10-
from progress.spinner import MoonSpinner
1111

1212
from testgen import settings
13-
from testgen.commands.run_execute_tests import run_execution_steps
1413
from testgen.commands.run_generate_tests import run_test_gen_queries
1514
from testgen.commands.run_get_entities import (
1615
run_get_results,
@@ -29,8 +28,9 @@
2928
)
3029
from testgen.commands.run_launch_db_config import run_launch_db_config
3130
from testgen.commands.run_observability_exporter import run_observability_exporter
32-
from testgen.commands.run_profiling_bridge import run_profiling_queries
31+
from testgen.commands.run_profiling import run_profiling
3332
from testgen.commands.run_quick_start import run_quick_start, run_quick_start_increment
33+
from testgen.commands.run_test_execution import run_test_execution
3434
from testgen.commands.run_test_metadata_exporter import run_test_metadata_exporter
3535
from testgen.commands.run_upgrade_db_config import get_schema_revision, is_db_revision_up_to_date, run_upgrade_db_config
3636
from testgen.common import (
@@ -45,6 +45,7 @@
4545
from testgen.common.models import with_database_session
4646
from testgen.common.models.profiling_run import ProfilingRun
4747
from testgen.common.models.test_run import TestRun
48+
from testgen.common.models.test_suite import TestSuite
4849
from testgen.scheduler import register_scheduler_job, run_scheduler
4950
from testgen.utils import plugins
5051

@@ -114,20 +115,16 @@ def cli(ctx: Context, verbose: bool):
114115

115116
@register_scheduler_job
116117
@cli.command("run-profile", help="Generates a new profile of the table group.")
117-
@pass_configuration
118118
@click.option(
119119
"-tg",
120120
"--table-group-id",
121121
required=True,
122122
type=click.STRING,
123-
help="The identifier for the table group used during a profile run. Use a table_group_id shown in list-table-groups.",
123+
help="ID of the table group to profile. Use a table_group_id shown in list-table-groups.",
124124
)
125-
def run_profile(configuration: Configuration, table_group_id: str):
125+
def run_profile(table_group_id: str):
126126
click.echo(f"run-profile with table_group_id: {table_group_id}")
127-
spinner = None
128-
if not configuration.verbose:
129-
spinner = MoonSpinner("Processing ... ")
130-
message = run_profiling_queries(table_group_id, spinner=spinner)
127+
message = run_profiling(table_group_id)
131128
click.echo("\n" + message)
132129

133130

@@ -163,28 +160,40 @@ def run_test_generation(configuration: Configuration, table_group_id: str, test_
163160

164161
@register_scheduler_job
165162
@cli.command("run-tests", help="Performs tests defined for a test suite.")
163+
@click.option(
164+
"-t",
165+
"--test-suite-id",
166+
required=False,
167+
type=click.STRING,
168+
help="ID of the test suite to run. Use a test_suite_id shown in list-test-suites.",
169+
)
166170
@click.option(
167171
"-pk",
168172
"--project-key",
169-
help="The identifier for a TestGen project. Use a project_key shown in list-projects.",
173+
help="DEPRECATED. Use --test-suite-id instead.",
170174
required=False,
171175
type=click.STRING,
172176
default=settings.PROJECT_KEY,
173177
)
174178
@click.option(
175179
"-ts",
176180
"--test-suite-key",
177-
help="The identifier for a test suite. Use a test_suite_key shown in list-test-suites.",
181+
help="DEPRECATED. Use --test-suite-id instead.",
178182
required=False,
179183
default=settings.DEFAULT_TEST_SUITE_KEY,
180184
)
181-
@pass_configuration
182-
def run_tests(configuration: Configuration, project_key: str, test_suite_key: str):
183-
click.echo(f"run-tests for suite: {test_suite_key}")
184-
spinner = None
185-
if not configuration.verbose:
186-
spinner = MoonSpinner("Processing ... ")
187-
message = run_execution_steps(project_key, test_suite_key, spinner=spinner)
185+
@with_database_session
186+
def run_tests(test_suite_id: str | None = None, project_key: str | None = None, test_suite_key: str | None = None):
187+
click.echo(f"run-tests for suite: {test_suite_id or test_suite_key}")
188+
# For backward compatibility
189+
if not test_suite_id:
190+
test_suites = TestSuite.select_minimal_where(
191+
TestSuite.project_code == project_key,
192+
TestSuite.test_suite == test_suite_key,
193+
)
194+
if test_suites:
195+
test_suite_id = test_suites[0].id
196+
message = run_test_execution(test_suite_id)
188197
click.echo("\n" + message)
189198

190199

@@ -370,27 +379,27 @@ def quick_start(
370379

371380
click.echo("loading initial data")
372381
run_quick_start_increment(0)
373-
minutes_offset = -30*24*60 # 1 month ago
374-
table_group_id="0ea85e17-acbe-47fe-8394-9970725ad37d"
382+
now_date = datetime.now(UTC)
383+
time_delta = timedelta(days=-30) # 1 month ago
384+
table_group_id = "0ea85e17-acbe-47fe-8394-9970725ad37d"
385+
test_suite_id = "9df7489d-92b3-49f9-95ca-512160d7896f"
375386

376387
click.echo(f"run-profile with table_group_id: {table_group_id}")
377-
spinner = None
378-
if not configuration.verbose:
379-
spinner = MoonSpinner("Processing ... ")
380-
message = run_profiling_queries(table_group_id, spinner=spinner, minutes_offset=minutes_offset)
388+
message = run_profiling(table_group_id, run_date=now_date + time_delta)
381389
click.echo("\n" + message)
382390

383391
LOG.info(f"run-test-generation with table_group_id: {table_group_id} test_suite: {settings.DEFAULT_TEST_SUITE_KEY}")
384392
message = run_test_gen_queries(table_group_id, settings.DEFAULT_TEST_SUITE_KEY)
385393
click.echo("\n" + message)
386394

387-
run_execution_steps(settings.PROJECT_KEY, settings.DEFAULT_TEST_SUITE_KEY, minutes_offset=minutes_offset)
395+
run_test_execution(test_suite_id, run_date=now_date + time_delta)
388396

389-
for iteration in range(1, 4):
390-
click.echo(f"Running iteration: {iteration} / 3")
391-
minutes_offset = -10*24*60 * (3-iteration)
397+
total_iterations = 3
398+
for iteration in range(1, total_iterations + 1):
399+
click.echo(f"Running iteration: {iteration} / {total_iterations}")
400+
run_date = now_date + timedelta(days=-10 * (total_iterations - iteration)) # 10 day increments
392401
run_quick_start_increment(iteration)
393-
run_execution_steps(settings.PROJECT_KEY, settings.DEFAULT_TEST_SUITE_KEY, minutes_offset=minutes_offset)
402+
run_test_execution(test_suite_id, run_date=run_date)
394403

395404
click.echo("Quick start has successfully finished.")
396405

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# UNUSED CODE - TO BE REVIVED LATER
2+
3+
import dataclasses
4+
from uuid import UUID
5+
6+
from testgen.common import read_template_sql_file
7+
from testgen.common.database.database_service import quote_csv_items, replace_params
8+
9+
10+
@dataclasses.dataclass
11+
class ContingencyTable:
12+
schema_name: str
13+
table_name: str
14+
contingency_columns: str
15+
16+
17+
class ContingencySQL:
18+
19+
contingency_max_values = 6
20+
21+
def _get_query(
22+
self,
23+
template_file_name: str,
24+
sub_directory: str | None = "contingency",
25+
params: dict | None = None,
26+
) -> tuple[str | None, dict]:
27+
query = read_template_sql_file(template_file_name, sub_directory)
28+
query = replace_params(query, params or {})
29+
30+
return query, params
31+
32+
def get_contingency_columns(self, profiling_run_id: UUID) -> tuple[str, dict]:
33+
# Runs on App database
34+
return self._get_query(
35+
"contingency_columns.sql",
36+
params={
37+
"PROFILE_RUN_ID": profiling_run_id,
38+
"CONTINGENCY_MAX_VALUES": self.contingency_max_values,
39+
},
40+
)
41+
42+
def get_contingency_counts(self, contingency_table: ContingencyTable) -> tuple[str, dict]:
43+
# Runs on Target database
44+
return self._get_query(
45+
"contingency_counts.sql",
46+
params={
47+
"DATA_SCHEMA": contingency_table.schema_name,
48+
"DATA_TABLE": contingency_table.table_name,
49+
"CONTINGENCY_COLUMNS": quote_csv_items(contingency_table.contingency_columns),
50+
},
51+
)

testgen/commands/queries/execute_cat_tests_query.py

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)