Skip to content

Commit c8096cd

Browse files
Merge pull request #39 from DataKitchen/release/4.0.12
Release/4.0.12
2 parents 5ceaddc + 090459e commit c8096cd

File tree

8 files changed

+27
-11
lines changed

8 files changed

+27
-11
lines changed

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 = "4.0.9"
11+
version = "4.0.12"
1212
description = "DataKitchen's Data Quality DataOps TestGen"
1313
authors = [
1414
{ "name" = "DataKitchen, Inc.", "email" = "[email protected]" },

testgen/commands/run_refresh_score_cards_results.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import time
44

5-
from testgen.common.models import with_database_session
5+
from testgen.common.models import get_current_session, with_database_session
66
from testgen.common.models.scores import (
77
SCORE_CATEGORIES,
88
ScoreCard,
@@ -36,6 +36,7 @@ def run_refresh_score_cards_results(
3636
LOG.exception("CurrentStep: Stopping scorecards results refresh after unexpected error")
3737
return
3838

39+
db_session = get_current_session()
3940
for definition in definitions:
4041
LOG.info(
4142
"CurrentStep: Refreshing results for scorecard %s in project %s",
@@ -45,6 +46,10 @@ def run_refresh_score_cards_results(
4546

4647
try:
4748
fresh_score_card = definition.as_score_card()
49+
definition.results = []
50+
definition.breakdown = []
51+
db_session.flush([definition])
52+
4853
definition.results = _score_card_to_results(fresh_score_card)
4954
definition.breakdown = _score_definition_to_results_breakdown(definition)
5055
if add_history_entry:

testgen/common/logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def configure_logging(
3333

3434
file_handler = ConcurrentTimedRotatingFileHandler(
3535
get_log_full_path(),
36-
when="D",
36+
when="MIDNIGHT",
3737
interval=1,
3838
backupCount=int(settings.LOG_FILE_MAX_QTY),
3939
)

testgen/common/models/scores.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,22 @@ def recalculate_scores_history(self) -> None:
361361
)
362362
overall_scores = get_current_session().execute(query).mappings().all()
363363
current_history: dict[tuple[datetime, str, str], ScoreDefinitionResultHistoryEntry] = {}
364-
for entry in self.history:
365-
current_history[(entry.last_run_time, entry.category,)] = entry
366-
367364
renewed_history: dict[tuple[datetime, str, str], float] = {}
365+
368366
for scores in overall_scores:
369367
renewed_history[(scores["last_run_time"], "score",)] = scores["score"]
370368
renewed_history[(scores["last_run_time"], "cde_score",)] = scores["cde_score"]
371369

370+
for entry in self.history:
371+
entry_key = (entry.last_run_time, entry.category,)
372+
if entry_key in renewed_history:
373+
current_history[entry_key] = entry
374+
372375
for key, entry in current_history.items():
373376
entry.score = renewed_history[key]
374377

378+
self.history = list(current_history.values())
379+
375380
def _get_raw_query_filters(self, cde_only: bool = False, prefix: str | None = None) -> list[str]:
376381
values_by_field = defaultdict(list)
377382
for filter_ in self.filters:

testgen/common/process_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def get_current_process_id():
1313

1414

1515
def kill_profile_run(process_id):
16-
keywords = ["run-profile"]
16+
keywords = ["/dk/bin/testgen", "run-profile"]
1717
status, message = kill_process(process_id, keywords)
1818
return status, message
1919

2020

2121
def kill_test_run(process_id):
22-
keywords = ["run-tests"]
22+
keywords = ["/dk/bin/testgen", "run-tests"]
2323
status, message = kill_process(process_id, keywords)
2424
return status, message
2525

@@ -31,7 +31,7 @@ def kill_process(process_id, keywords=None):
3131
return False, msg
3232
try:
3333
process = psutil.Process(process_id)
34-
if process.name().lower() != "testgen":
34+
if process.name().lower() not in ["testgen", "python3"]:
3535
message = f"The process was not killed because the process_id {process_id} is not a testgen process. Details: {process.name()}"
3636
LOG.error(f"kill_process: {message}")
3737
return False, message
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SET SEARCH_PATH TO {SCHEMA_NAME};
2+
3+
UPDATE job_schedules
4+
SET kwargs = kwargs - 'project_code' || jsonb_build_object('project_key', kwargs->'project_code')
5+
WHERE key = 'run-tests';

testgen/ui/views/score_explorer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datetime import datetime
12
from io import BytesIO
23
from typing import ClassVar
34

@@ -246,7 +247,7 @@ def save_score_definition(_) -> None:
246247
latest_run = max(
247248
profiling_queries.get_latest_run_date(project_code),
248249
test_run_queries.get_latest_run_date(project_code),
249-
key=lambda run: getattr(run, "run_time", 0),
250+
key=lambda run: getattr(run, "run_time", datetime.min),
250251
)
251252

252253
refresh_kwargs = {

testgen/ui/views/test_runs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def arg_value_input(self) -> tuple[bool, list[typing.Any], dict[str, typing.Any]
133133
display_column="test_suite",
134134
required=True,
135135
)
136-
return bool(ts_name), [], {"project_code": self.project_code, "test_suite_key": ts_name}
136+
return bool(ts_name), [], {"project_key": self.project_code, "test_suite_key": ts_name}
137137

138138

139139
def render_empty_state(project_code: str, user_can_run: bool) -> bool:

0 commit comments

Comments
 (0)