Coverage for src/python/ensembl/vep/config/sections/bench/endtoend.py: 100%

23 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-18 14:41 +0000

1# See the NOTICE file distributed with this work for additional information 

2# regarding copyright ownership. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# http://www.apache.org/licenses/LICENSE-2.0 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14"""Options for timing whole runs of the command line against each other.""" 

15 

16from __future__ import annotations 

17 

18from pathlib import Path 

19from typing import ClassVar 

20 

21from attrs import define, field 

22 

23from ensembl.vep.config.option_spec import option 

24from ensembl.vep.config.sections.base import ConfigSection 

25 

26__all__ = ["BenchEndToEndConfig"] 

27 

28 

29@define(frozen=True, kw_only=True, auto_attribs=True) 

30class BenchEndToEndConfig(ConfigSection): 

31 """Which configurations to run end to end, where to run them, and what to leave behind. 

32 

33 Attributes: 

34 strategies (tuple[str, ...]): Strategies to time, or empty for every registered 

35 ``consequence.*`` strategy. ``consequence.linear`` is run first, as the reference the 

36 speed-up column and the output gate are against. 

37 caches (tuple[str, ...]): Cache sets to cross every strategy with: ``none``, or a 

38 ``+``-joined set of ``zonemap``, ``codon`` and ``mapper``. The default matches 

39 ``bench matrix``, so a label means the same run in both tables. 

40 processes (tuple[int, ...]): Worker process counts to cross every configuration with. An 

41 axis only an end-to-end benchmark has: the in-process verbs never fork. 

42 batch_size (int): Overlaps per batch, passed to each run. 

43 work_dir (Path | None): Where the corpus, its indexes and the run outputs go. Defaults to 

44 ``corpus.corpus_dir`` when that is set, and to a temporary directory otherwise. 

45 clean (bool): Remove the files this run created when it finishes. Files that were already 

46 there are left alone either way. 

47 """ 

48 

49 section_name: ClassVar[str] = "bench_endtoend" 

50 

51 strategies: tuple[str, ...] = field( 

52 default=(), 

53 metadata=option("strategies to time (default: every consequence strategy)", metavar="NAME,..."), 

54 ) 

55 caches: tuple[str, ...] = field( 

56 default=("none", "zonemap", "zonemap+codon"), 

57 metadata=option("cache sets to cross each strategy with", metavar="SET,..."), 

58 ) 

59 processes: tuple[int, ...] = field( 

60 default=(1,), 

61 metadata=option("worker process counts to time each configuration with", metavar="N,..."), 

62 ) 

63 batch_size: int = field(default=256, metadata=option("overlaps per batch", metavar="N")) 

64 work_dir: Path | None = field( 

65 default=None, metadata=option("directory for the corpus, its indexes and the run outputs") 

66 ) 

67 clean: bool = field(default=True, metadata=option("remove the files this run created")) 

68 

69 def __attrs_post_init__(self) -> None: 

70 """Reject counts that cannot be run. 

71 

72 Raises: 

73 ValueError: If no process count was given, or any of them is below one, or the batch 

74 size is below one. 

75 """ 

76 if not self.processes: 

77 raise ValueError("processes must name at least one worker count") 

78 if any(count < 1 for count in self.processes): 

79 raise ValueError("every process count must be at least one") 

80 if self.batch_size < 1: 

81 raise ValueError("batch_size must be at least one")