Skip to content

Commit aed2512

Browse files
Require functions at the top.
Add periodic memory logging
1 parent f8a5396 commit aed2512

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ line-length = 89
138138
indent-width = 4
139139

140140
[tool.ruff.lint]
141-
select = ["E", "F", "B", "W", "I", "N", "UP", "A", "PT"]
141+
select = ["E", "F", "B", "W", "I", "N", "UP", "A", "PT", "PLC0415"]
142142

143143
ignore = [
144144
"A001", "A002", "RUF",

tsinfer/pipeline.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ def _process_group(
375375
disable=not progress,
376376
)
377377
results = []
378+
last_mem_log = time_.monotonic()
379+
mem_log_interval = 30 # seconds
378380
for job, result in match_iter:
379381
if match_fh is not None:
380382
doc = {
@@ -396,6 +398,18 @@ def _process_group(
396398
match_fh.write(json.dumps(doc) + "\n")
397399
results.append((job, result))
398400
pbar.update(1)
401+
now = time_.monotonic()
402+
if now - last_mem_log >= mem_log_interval:
403+
rss_mib = psutil.Process().memory_info().rss / (1024 * 1024)
404+
reader.log_cache_state()
405+
logger.info(
406+
"Group %d progress: %d/%d haplotypes, RSS=%.1f MiB",
407+
group_idx,
408+
len(results),
409+
len(job_list),
410+
rss_mib,
411+
)
412+
last_mem_log = now
399413
pbar.close()
400414
paired_results = sorted(results, key=lambda pair: pair[0].haplotype_index)
401415

tsinfer/vcz.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from __future__ import annotations
4343

4444
import dataclasses
45+
import functools
4546
import logging
4647
import math
4748
import pathlib
@@ -2325,8 +2326,6 @@ def __init__(
23252326
sources,
23262327
ancestral_state,
23272328
):
2328-
from functools import reduce
2329-
23302329
if isinstance(sources, config.Source):
23312330
sources = [sources]
23322331

@@ -2384,7 +2383,7 @@ def __init__(
23842383
if len(valid_per_source) == 1:
23852384
all_positions = valid_per_source[0]
23862385
else:
2387-
all_positions = reduce(np.union1d, valid_per_source)
2386+
all_positions = functools.reduce(np.union1d, valid_per_source)
23882387
self._positions = all_positions.astype(np.int32)
23892388

23902389
# Build source_has_site mask via searchsorted

0 commit comments

Comments
 (0)