Skip to content

Commit 4e54943

Browse files
committed
fix(runs): update Running runs to Canceled on startup
1 parent d01f27e commit 4e54943

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

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/ui/queries/profiling_run_queries.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ def update_status(profile_run_id: str, status: str) -> None:
1616
"""
1717
db.execute_sql(sql)
1818
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ def update_status(test_run_id: str, status: str) -> None:
3939
"""
4040
db.execute_sql(sql)
4141
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+
""")

0 commit comments

Comments
 (0)