Skip to content

Commit 1639a65

Browse files
committed
Fixing pre-commit checks
There was an unused import.
1 parent 1dc5c3d commit 1639a65

1 file changed

Lines changed: 11 additions & 42 deletions

File tree

scripts/run-ci-docker-worker-matrix.py

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import subprocess
2727
import sys
2828
import threading
29-
import time
3029
from dataclasses import dataclass
3130
from pathlib import Path
3231
from typing import Iterable, List, Sequence
@@ -51,9 +50,7 @@ def run(
5150
return subprocess.run(command, cwd=cwd, env=env, check=check, text=True)
5251

5352

54-
def shell(
55-
command: str, *, cwd: Path, env: dict | None = None, check: bool = True
56-
) -> subprocess.CompletedProcess:
53+
def shell(command: str, *, cwd: Path, env: dict | None = None, check: bool = True) -> subprocess.CompletedProcess:
5754
return subprocess.run(command, cwd=cwd, env=env, check=check, text=True, shell=True)
5855

5956

@@ -77,9 +74,7 @@ def ensure_docker_available(repo_root: Path) -> None:
7774

7875
def discover_test_files(repo_root: Path) -> List[str]:
7976
test_dir = repo_root / "bluesky_httpserver" / "tests"
80-
files = sorted(
81-
str(path.relative_to(repo_root)) for path in test_dir.glob("test_*.py")
82-
)
77+
files = sorted(str(path.relative_to(repo_root)) for path in test_dir.glob("test_*.py"))
8378
return files
8479

8580

@@ -101,12 +96,7 @@ def start_redis_container(repo_root: Path, name: str) -> None:
10196

10297

10398
def start_ldap_compose(repo_root: Path) -> None:
104-
compose_file = (
105-
repo_root
106-
/ "continuous_integration"
107-
/ "docker-configs"
108-
/ "ldap-docker-compose.yml"
109-
)
99+
compose_file = repo_root / "continuous_integration" / "docker-configs" / "ldap-docker-compose.yml"
110100
env = os.environ.copy()
111101
env["LDAP_COMPOSE_FILE"] = str(compose_file)
112102
env["LDAP_COMPOSE_PROJECT"] = "bhs-ci-ldap"
@@ -123,12 +113,7 @@ def start_ldap_compose(repo_root: Path) -> None:
123113

124114

125115
def stop_ldap_compose(repo_root: Path) -> None:
126-
compose_file = (
127-
repo_root
128-
/ "continuous_integration"
129-
/ "docker-configs"
130-
/ "ldap-docker-compose.yml"
131-
)
116+
compose_file = repo_root / "continuous_integration" / "docker-configs" / "ldap-docker-compose.yml"
132117
run(
133118
[
134119
"docker",
@@ -150,9 +135,7 @@ def make_worker_name(python_version: str, index: int) -> str:
150135
return f"bhs-ci-py{v}-worker{index}"
151136

152137

153-
def start_worker_container(
154-
repo_root: Path, python_version: str, worker_name: str
155-
) -> None:
138+
def start_worker_container(repo_root: Path, python_version: str, worker_name: str) -> None:
156139
run(docker_cmd("rm", "-f", worker_name), cwd=repo_root, check=False)
157140
run(
158141
docker_cmd(
@@ -176,9 +159,7 @@ def start_worker_container(
176159
)
177160

178161

179-
def exec_in_worker(
180-
repo_root: Path, worker_name: str, command: str, *, log_path: Path
181-
) -> int:
162+
def exec_in_worker(repo_root: Path, worker_name: str, command: str, *, log_path: Path) -> int:
182163
full_cmd = ["docker", "exec", worker_name, "bash", "-lc", command]
183164
with log_path.open("w", encoding="utf-8") as log_file:
184165
process = subprocess.run(
@@ -254,9 +235,7 @@ def run_test_matrix(
254235

255236
for python_version in python_versions:
256237
print(f"\n=== Python {python_version}: preparing workers ===", flush=True)
257-
workers = [
258-
make_worker_name(python_version, i + 1) for i in range(workers_per_version)
259-
]
238+
workers = [make_worker_name(python_version, i + 1) for i in range(workers_per_version)]
260239

261240
for worker in workers:
262241
start_worker_container(repo_root, python_version, worker)
@@ -266,10 +245,7 @@ def run_test_matrix(
266245
bootstrap_worker(repo_root, worker)
267246

268247
if tests_per_chunk and tests_per_chunk > 0:
269-
chunks = [
270-
test_files[i : i + tests_per_chunk]
271-
for i in range(0, len(test_files), tests_per_chunk)
272-
]
248+
chunks = [test_files[i : i + tests_per_chunk] for i in range(0, len(test_files), tests_per_chunk)]
273249
else:
274250
n_chunks = (
275251
chunks_per_version
@@ -295,12 +271,8 @@ def worker_loop(worker_name: str) -> None:
295271
"QSERVER_TEST_LDAP_PORT=1389 "
296272
f"coverage run -m pytest -vv {chunk_args}"
297273
)
298-
log_path = (
299-
artifacts_dir / f"{worker_name}-chunk{chunk_index:03d}.log"
300-
)
301-
rc = exec_in_worker(
302-
repo_root, worker_name, command, log_path=log_path
303-
)
274+
log_path = artifacts_dir / f"{worker_name}-chunk{chunk_index:03d}.log"
275+
rc = exec_in_worker(repo_root, worker_name, command, log_path=log_path)
304276
with results_lock:
305277
all_results.append(
306278
ChunkResult(
@@ -314,10 +286,7 @@ def worker_loop(worker_name: str) -> None:
314286
)
315287
work_queue.task_done()
316288

317-
threads = [
318-
threading.Thread(target=worker_loop, args=(worker,), daemon=True)
319-
for worker in workers
320-
]
289+
threads = [threading.Thread(target=worker_loop, args=(worker,), daemon=True) for worker in workers]
321290
for t in threads:
322291
t.start()
323292
for t in threads:

0 commit comments

Comments
 (0)