Coverage for src/python/ensembl/vep/config/sections/corpus/save.py: 100%

14 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 exporting a registered corpus to disk.""" 

15 

16from __future__ import annotations 

17 

18from typing import ClassVar 

19 

20from attrs import define, field 

21 

22from ensembl.vep.config.option_spec import option 

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

24 

25__all__ = ["CorpusSaveConfig"] 

26 

27 

28def _exporter_names() -> tuple[str, ...]: 

29 """Return registered exporter names. 

30 

31 Resolved lazily so this module never imports ensembl.vep.exporter. 

32 

33 Returns: 

34 tuple[str, ...]: Every registered corpus name, sorted. 

35 """ 

36 # pylint: disable=import-outside-toplevel 

37 from ensembl.vep.corpus.exporter.registry import available_exporters 

38 

39 return available_exporters() 

40 

41 

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

43class CorpusSaveConfig(ConfigSection): 

44 """How to export a corpus. The destination is ``corpus.corpus_dir``. 

45 

46 Attributes: 

47 exporter (str): Registered corpus exporter to use. 

48 force (bool): Overwrite the corpus files if the directory already holds them. 

49 """ 

50 

51 section_name: ClassVar[str] = "corpus_save" 

52 

53 exporter: str = field( 

54 default="file", metadata=option("registered corpus exporter", choices=_exporter_names) 

55 ) 

56 force: bool = field(default=False, metadata=option("overwrite an existing saved corpus"))