Skip to content

Commit 33983dc

Browse files
Merge pull request #29 from DataKitchen/release/3.1.2
Release/3.1.2
2 parents b3b4f35 + 6bc99d4 commit 33983dc

13 files changed

Lines changed: 62 additions & 56 deletions

pyproject.toml

Lines changed: 1 addition & 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 = "3.1.0"
11+
version = "3.1.2"
1212
description = "DataKitchen's Data Quality DataOps TestGen"
1313
authors = [
1414
{ "name" = "DataKitchen, Inc.", "email" = "info@datakitchen.io" },

testgen/__main__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
logs,
4444
version_service,
4545
)
46+
from testgen.ui.queries import profiling_run_queries, test_run_queries
4647
from testgen.utils import plugins
4748

4849
LOG = logging.getLogger("testgen")
@@ -606,6 +607,11 @@ def run(debug: bool):
606607
use_ssl = os.path.isfile(settings.SSL_CERT_FILE) and os.path.isfile(settings.SSL_KEY_FILE)
607608

608609
patch_streamlit.patch(force=True)
610+
try:
611+
profiling_run_queries.cancel_all_running()
612+
test_run_queries.cancel_all_running()
613+
except Exception:
614+
LOG.warning("Failed to cancel 'Running' profiling/test runs")
609615

610616
try:
611617
app_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "ui/app.py")

testgen/commands/run_profiling_bridge.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
RunActionQueryList,
1818
RunThreadedRetrievalQueryList,
1919
WriteListToDB,
20-
date_service,
21-
read_template_sql_file,
2220
)
2321
from testgen.common.database.database_service import empty_cache
2422

@@ -508,14 +506,3 @@ def run_profiling_queries(strTableGroupsID, spinner=None):
508506
str_error_status = "successfully."
509507
message += str_error_status
510508
return message
511-
512-
513-
def update_profile_run_status(profile_run_id, status):
514-
sql_template = read_template_sql_file("project_profile_run_record_update_status.sql", sub_directory="profiling")
515-
516-
sql_template = sql_template.replace("{STATUS}", status)
517-
sql_template = sql_template.replace("{NOW}", date_service.get_now_as_string())
518-
sql_template = sql_template.replace("{EXCEPTION_MESSAGE}", "")
519-
sql_template = sql_template.replace("{PROFILE_RUN_ID}", profile_run_id)
520-
521-
RunActionQueryList("DKTG", [sql_template])

testgen/template/profiling/project_profile_run_record_update_status.sql

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

testgen/template/score_cards/get_score_card_issues_by_column.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ anomalies AS (
1717
EXTRACT(
1818
EPOCH
1919
FROM runs.profiling_starttime
20-
) AS time,
20+
) * 1000 AS time,
2121
'' AS name,
2222
runs.id::text AS run_id,
2323
'hygiene' AS issue_type
@@ -50,7 +50,7 @@ tests AS (
5050
EXTRACT(
5151
EPOCH
5252
FROM test_time
53-
) AS time,
53+
) * 1000 AS time,
5454
test_suites.test_suite AS name,
5555
test_results.test_run_id::text AS run_id,
5656
'test' AS issue_type
@@ -80,4 +80,4 @@ ORDER BY
8080
WHEN 'Possible' THEN 4
8181
WHEN 'Warning' THEN 5
8282
ELSE 6
83-
END
83+
END

testgen/template/score_cards/get_score_card_issues_by_dimension.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ anomalies AS (
1717
EXTRACT(
1818
EPOCH
1919
FROM runs.profiling_starttime
20-
) AS time,
20+
) * 1000 AS time,
2121
'' AS name,
2222
runs.id::text AS run_id,
2323
'hygiene' AS issue_type
@@ -51,7 +51,7 @@ tests AS (
5151
EXTRACT(
5252
EPOCH
5353
FROM test_time
54-
) AS time,
54+
) * 1000 AS time,
5555
test_suites.test_suite AS name,
5656
test_results.test_run_id::text AS run_id,
5757
'test' AS issue_type
@@ -82,4 +82,4 @@ ORDER BY
8282
WHEN 'Possible' THEN 4
8383
WHEN 'Warning' THEN 5
8484
ELSE 6
85-
END
85+
END
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import streamlit as st
2+
3+
import testgen.ui.services.database_service as db
4+
from testgen.common import date_service
5+
6+
7+
def update_status(profile_run_id: str, status: str) -> None:
8+
schema: str = st.session_state["dbschema"]
9+
now = date_service.get_now_as_string()
10+
11+
sql = f"""
12+
UPDATE {schema}.profiling_runs
13+
SET status = '{status}',
14+
profiling_endtime = '{now}'
15+
WHERE id = '{profile_run_id}'::UUID;
16+
"""
17+
db.execute_sql(sql)
18+
st.cache_data.clear()
19+
20+
21+
def cancel_all_running() -> None:
22+
schema: str = db.get_schema()
23+
db.execute_sql(f"""
24+
UPDATE {schema}.profiling_runs
25+
SET status = 'Cancelled'
26+
WHERE status = 'Running';
27+
""")

testgen/ui/queries/test_run_queries.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import testgen.ui.services.database_service as db
55

66

7-
def cascade_delete(schema: str, test_suite_ids: list[str]) -> None:
7+
def cascade_delete(test_suite_ids: list[str]) -> None:
88
if not test_suite_ids:
99
raise ValueError("No Test Suite is specified.")
1010

11+
schema: str = st.session_state["dbschema"]
1112
ids_str = ", ".join([f"'{item}'" for item in test_suite_ids])
1213
sql = f"""
1314
DELETE
@@ -23,10 +24,11 @@ def cascade_delete(schema: str, test_suite_ids: list[str]) -> None:
2324
st.cache_data.clear()
2425

2526

26-
def update_status(schema: str, test_run_id: str, status: str) -> None:
27+
def update_status(test_run_id: str, status: str) -> None:
2728
if not all([test_run_id, status]):
2829
raise ValueError("Missing query parameters.")
2930

31+
schema: str = st.session_state["dbschema"]
3032
now = date_service.get_now_as_string()
3133

3234
sql = f"""
@@ -37,3 +39,12 @@ def update_status(schema: str, test_run_id: str, status: str) -> None:
3739
"""
3840
db.execute_sql(sql)
3941
st.cache_data.clear()
42+
43+
44+
def cancel_all_running() -> None:
45+
schema: str = db.get_schema()
46+
db.execute_sql(f"""
47+
UPDATE {schema}.test_runs
48+
SET status = 'Cancelled'
49+
WHERE status = 'Running';
50+
""")

testgen/ui/services/test_definition_service.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import testgen.ui.services.connection_service as connection_service
55
import testgen.ui.services.database_service as database_service
66
import testgen.ui.services.table_group_service as table_group_service
7-
import testgen.ui.services.test_run_service as test_run_service
7+
from testgen.ui.queries import test_run_queries
88

99

1010
def update_attribute(test_definition_ids, attribute, value):
@@ -54,7 +54,7 @@ def delete(test_definition_ids, dry_run=False):
5454

5555
def cascade_delete(test_suite_ids: list[str]):
5656
schema = st.session_state["dbschema"]
57-
test_run_service.cascade_delete(test_suite_ids)
57+
test_run_queries.cascade_delete(test_suite_ids)
5858
test_definition_queries.cascade_delete(schema, test_suite_ids)
5959

6060

@@ -138,7 +138,7 @@ def validate_test(test_definition):
138138
)
139139

140140

141-
def move(test_definitions, target_table_group, target_test_suite):
141+
def move(test_definitions, target_table_group, target_test_suite):
142142
schema = st.session_state["dbschema"]
143143
test_definition_queries.move(schema, test_definitions, target_table_group, target_test_suite)
144144

@@ -152,4 +152,3 @@ def copy(test_definitions, target_table_group, target_test_suite):
152152
def get_test_definitions_collision(test_definitions, target_table_group, target_test_suite):
153153
schema = st.session_state["dbschema"]
154154
return test_definition_queries.get_test_definitions_collision(schema, test_definitions, target_table_group, target_test_suite)
155-

testgen/ui/services/test_run_service.py

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

0 commit comments

Comments
 (0)