|
6 | 6 | import logging |
7 | 7 | import re |
8 | 8 | import threading |
9 | | -import time |
10 | 9 | from pathlib import Path |
11 | 10 | from time import sleep |
12 | 11 | from typing import Union |
@@ -109,7 +108,6 @@ def execute(self) -> _TaskResult: |
109 | 108 |
|
110 | 109 |
|
111 | 110 | class TestMultiBackendJobManager: |
112 | | - |
113 | 111 | @pytest.fixture |
114 | 112 | def job_manager_root_dir(self, tmp_path): |
115 | 113 | return tmp_path / "job_mgr_root" |
@@ -582,7 +580,6 @@ def start_job(row, connection_provider, connection, **kwargs): |
582 | 580 | 12 * 60 * 60, |
583 | 581 | "finished", |
584 | 582 | ), |
585 | | -
|
586 | 583 | ], |
587 | 584 | ) |
588 | 585 | def test_automatic_cancel_of_too_long_running_jobs( |
@@ -672,30 +669,28 @@ def test_status_logging(self, tmp_path, job_manager, job_manager_root_dir, sleep |
672 | 669 | needle = re.compile(r"Job status histogram:.*'finished': 5.*Run stats:.*'job_queued_for_start': 5") |
673 | 670 | assert needle.search(caplog.text) |
674 | 671 |
|
675 | | - |
676 | | - |
677 | 672 | @pytest.mark.parametrize( |
678 | | - ["create_time", "start_time", "running_start_time", "end_time", "end_status", "cancel_after_seconds"], |
679 | | - [ |
680 | | - # Scenario 1: Missing running_start_time (None) |
681 | | - ( |
682 | | - "2024-09-01T09:00:00Z", # Job creation time |
683 | | - "2024-09-01T09:00:00Z", # Job start time (should be 1 hour after create_time) |
684 | | - None, # Missing running_start_time |
685 | | - "2024-09-01T20:00:00Z", # Job end time |
686 | | - "finished", # Job final status |
687 | | - 6 * 60 * 60, # Cancel after 6 hours |
688 | | - ), |
689 | | - # Scenario 2: NaN running_start_time |
690 | | - ( |
691 | | - "2024-09-01T09:00:00Z", |
692 | | - "2024-09-01T09:00:00Z", |
693 | | - float("nan"), # NaN running_start_time |
694 | | - "2024-09-01T20:00:00Z", # Job end time |
695 | | - "finished", # Job final status |
696 | | - 6 * 60 * 60, # Cancel after 6 hours |
697 | | - ), |
698 | | - ] |
| 673 | + ["create_time", "start_time", "running_start_time", "end_time", "end_status", "cancel_after_seconds"], |
| 674 | + [ |
| 675 | + # Scenario 1: Missing running_start_time (None) |
| 676 | + ( |
| 677 | + "2024-09-01T09:00:00Z", # Job creation time |
| 678 | + "2024-09-01T09:00:00Z", # Job start time (should be 1 hour after create_time) |
| 679 | + None, # Missing running_start_time |
| 680 | + "2024-09-01T20:00:00Z", # Job end time |
| 681 | + "finished", # Job final status |
| 682 | + 6 * 60 * 60, # Cancel after 6 hours |
| 683 | + ), |
| 684 | + # Scenario 2: NaN running_start_time |
| 685 | + ( |
| 686 | + "2024-09-01T09:00:00Z", |
| 687 | + "2024-09-01T09:00:00Z", |
| 688 | + float("nan"), # NaN running_start_time |
| 689 | + "2024-09-01T20:00:00Z", # Job end time |
| 690 | + "finished", # Job final status |
| 691 | + 6 * 60 * 60, # Cancel after 6 hours |
| 692 | + ), |
| 693 | + ], |
699 | 694 | ) |
700 | 695 | def test_ensure_running_start_time_is_datetime( |
701 | 696 | self, |
@@ -726,10 +721,12 @@ def get_status(job_id, current_status): |
726 | 721 | job_manager.add_backend("foo", connection=dummy_backend_foo.connection) |
727 | 722 |
|
728 | 723 | # Create a DataFrame representing the job database |
729 | | - df = pd.DataFrame({ |
730 | | - "year": [2024], |
731 | | - "running_start_time": [running_start_time], # Initial running_start_time |
732 | | - }) |
| 724 | + df = pd.DataFrame( |
| 725 | + { |
| 726 | + "year": [2024], |
| 727 | + "running_start_time": [running_start_time], # Initial running_start_time |
| 728 | + } |
| 729 | + ) |
733 | 730 |
|
734 | 731 | # Move the time machine to the job creation time |
735 | 732 | time_machine.move_to(create_time) |
@@ -871,6 +868,7 @@ def execute(self): |
871 | 868 | assert any("Skipping invalid db_update" in msg for msg in caplog.messages) |
872 | 869 | assert any("Skipping invalid stats_update" in msg for msg in caplog.messages) |
873 | 870 |
|
| 871 | + |
874 | 872 | JOB_DB_DF_BASICS = pd.DataFrame( |
875 | 873 | { |
876 | 874 | "numbers": [3, 2, 1], |
@@ -986,7 +984,6 @@ def test_count_by_status(self, tmp_path, db_class): |
986 | 984 |
|
987 | 985 |
|
988 | 986 | class TestCsvJobDatabase: |
989 | | - |
990 | 987 | def test_repr(self, tmp_path): |
991 | 988 | path = tmp_path / "db.csv" |
992 | 989 | db = CsvJobDatabase(path) |
@@ -1153,7 +1150,6 @@ def test_read_with_crs_column(self, tmp_path): |
1153 | 1150 |
|
1154 | 1151 |
|
1155 | 1152 | class TestParquetJobDatabase: |
1156 | | - |
1157 | 1153 | def test_repr(self, tmp_path): |
1158 | 1154 | path = tmp_path / "db.pq" |
1159 | 1155 | db = ParquetJobDatabase(path) |
|
0 commit comments