Coverage for src/python/ensembl/vep/runner/base.py: 100%

19 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"""The runner contract.""" 

15 

16from __future__ import annotations 

17 

18from enum import IntEnum 

19from typing import ClassVar, Protocol, runtime_checkable 

20 

21from ensembl.vep.config import Config 

22 

23__all__ = ["ExitCode", "Runner"] 

24 

25 

26class ExitCode(IntEnum): 

27 """Process exit codes returned by runners.""" 

28 

29 OK = 0 

30 """The command completed successfully.""" 

31 FAILURE = 1 

32 """The command ran and reported a failure.""" 

33 USAGE = 2 

34 """The command was invoked incorrectly.""" 

35 

36 

37@runtime_checkable 

38class Runner(Protocol): 

39 """One command's execution. 

40 

41 Attributes: 

42 name (ClassVar[str]): The registry name, following ``<domain>.<verb>``. 

43 sections (ClassVar[tuple[str, ...]]): The configuration sections this runner reads, named 

44 by their attribute on ``Config``. The command line is derived from exactly these, 

45 so a runner sees only the options it declares an interest in. 

46 description (ClassVar[str]): One-line description, used as the subcommand's help text. 

47 """ 

48 

49 name: ClassVar[str] 

50 sections: ClassVar[tuple[str, ...]] 

51 description: ClassVar[str] 

52 

53 def __init__(self, config: Config) -> None: 

54 """Initialize the runner. 

55 

56 Args: 

57 config (Config): The populated configuration. 

58 """ 

59 raise NotImplementedError 

60 

61 def run(self) -> ExitCode: 

62 """Execute the command. 

63 

64 Returns: 

65 ExitCode: The process exit code. 

66 """ 

67 raise NotImplementedError