ensembl.vep.config package#

Configuration declarations, sections and loaders.

Subpackages#

Submodules#

ensembl.vep.config.base module#

Configuration roots and layer loading.

class ensembl.vep.config.base.Config(*, annotation=AnnotationConfig(), bench=BenchConfig(), bench_endtoend=BenchEndToEndConfig(), bench_matrix=BenchMatrixConfig(), bench_oracle=BenchOracleConfig(), bench_sweep=BenchSweepConfig(), catalogue=CatalogueConfig(), catalogue_add=CatalogueAddConfig(), catalogue_costs=CatalogueCostsConfig(), catalogue_remove=CatalogueRemoveConfig(), catalogue_show=CatalogueShowConfig(), catalogue_validate=CatalogueValidateConfig(), catalogue_write=CatalogueWriteConfig(), corpus=CorpusConfig(), corpus_describe=CorpusDescribeConfig(), corpus_golden=CorpusGoldenConfig(), corpus_save=CorpusSaveConfig(), explain=ExplainConfig(), execution=ExecutionConfig(), logging=LoggingConfig(), run=RunConfig(), source=SourceConfig(), stats=StatsConfig(), command='', sources=dict())[source]#

Bases: object

The assembled configuration and its value sources.

annotation: AnnotationConfig#
as_mapping()[source]#

Return the declared options as section -> field -> value.

Return type:

dict[str, dict[str, object]]

bench: BenchConfig#
bench_endtoend: BenchEndToEndConfig#
bench_matrix: BenchMatrixConfig#
bench_oracle: BenchOracleConfig#
bench_sweep: BenchSweepConfig#
classmethod build_section(section_type, values)[source]#

Build one section class from its merged values.

Return type:

ConfigSection

catalogue: CatalogueConfig#
catalogue_add: CatalogueAddConfig#
catalogue_costs: CatalogueCostsConfig#
catalogue_remove: CatalogueRemoveConfig#
catalogue_show: CatalogueShowConfig#
catalogue_validate: CatalogueValidateConfig#
catalogue_write: CatalogueWriteConfig#
command: str#
corpus: CorpusConfig#
corpus_describe: CorpusDescribeConfig#
corpus_golden: CorpusGoldenConfig#
corpus_save: CorpusSaveConfig#
execution: ExecutionConfig#
explain: ExplainConfig#
classmethod for_command(command, **options)[source]#

Return the configuration for one command, named as the command line names its options.

The command’s own sections decide where each option belongs, so a caller gives flat option names and never has to know which section declares which. Values are coerced as the command line coerces them, so a path may be given as a string.

Parameters:
  • command (str) – A registered command, such as run.default.

  • **options (object) – Option values, named by field or by flag.

Returns:

The command’s sections built from these options, every other section left at

its defaults.

Return type:

Config

Raises:

ValueError – If the command is not registered, or an option is not one it reads.

logging: LoggingConfig#
run: RunConfig#
section(name)[source]#

Return a configured section by its declared name.

Return type:

ConfigSection

section_types: ClassVar[dict[str, type[ConfigSection]]] = {'annotation': <class 'ensembl.vep.config.sections.common.annotation.AnnotationConfig'>, 'bench': <class 'ensembl.vep.config.sections.bench.bench.BenchConfig'>, 'bench_endtoend': <class 'ensembl.vep.config.sections.bench.endtoend.BenchEndToEndConfig'>, 'bench_matrix': <class 'ensembl.vep.config.sections.bench.matrix.BenchMatrixConfig'>, 'bench_oracle': <class 'ensembl.vep.config.sections.bench.oracle.BenchOracleConfig'>, 'bench_sweep': <class 'ensembl.vep.config.sections.bench.sweep.BenchSweepConfig'>, 'catalogue': <class 'ensembl.vep.config.sections.catalogue.catalogue.CatalogueConfig'>, 'catalogue_add': <class 'ensembl.vep.config.sections.catalogue.add.CatalogueAddConfig'>, 'catalogue_costs': <class 'ensembl.vep.config.sections.catalogue.costs.CatalogueCostsConfig'>, 'catalogue_remove': <class 'ensembl.vep.config.sections.catalogue.remove.CatalogueRemoveConfig'>, 'catalogue_show': <class 'ensembl.vep.config.sections.catalogue.show.CatalogueShowConfig'>, 'catalogue_validate': <class 'ensembl.vep.config.sections.catalogue.validate.CatalogueValidateConfig'>, 'catalogue_write': <class 'ensembl.vep.config.sections.catalogue.write.CatalogueWriteConfig'>, 'corpus': <class 'ensembl.vep.config.sections.common.corpus.CorpusConfig'>, 'corpus_describe': <class 'ensembl.vep.config.sections.corpus.describe.CorpusDescribeConfig'>, 'corpus_golden': <class 'ensembl.vep.config.sections.corpus.golden.CorpusGoldenConfig'>, 'corpus_save': <class 'ensembl.vep.config.sections.corpus.save.CorpusSaveConfig'>, 'execution': <class 'ensembl.vep.config.sections.common.execution.ExecutionConfig'>, 'explain': <class 'ensembl.vep.config.sections.explain.explain.ExplainConfig'>, 'logging': <class 'ensembl.vep.config.sections.common.logging.LoggingConfig'>, 'run': <class 'ensembl.vep.config.sections.run.run.RunConfig'>, 'source': <class 'ensembl.vep.config.sections.common.source.SourceConfig'>, 'stats': <class 'ensembl.vep.config.sections.stats.stats.StatsConfig'>}#

Map section attribute names to their classes.

classmethod section_types_for(names)[source]#

Return the section class types for the given section names.

Return type:

tuple[type[ConfigSection], ...]

sections()[source]#

Return the configured sections in declaration order.

Return type:

tuple[ConfigSection, ...]

source: SourceConfig#
source_of(section, field_name)[source]#

Return the winning source for a given section name and field.

Return type:

ConfigSource

sources: dict[str, dict[str, ConfigSource]]#
classmethod sources_for(layers)[source]#

Return the winning source for each option given the configuration layers for different sources.

Return type:

dict[str, dict[str, ConfigSource]]

stats: StatsConfig#
ensembl.vep.config.base.load(argv=None, *, command='', section_names=(), config_file=None, environ=None, parser=None)[source]#

Load configuration from the available layers.

Return type:

Config

ensembl.vep.config.option_spec module#

Option declarations for configuration sections.

class ensembl.vep.config.option_spec.OptionSpec(*, help, flag=None, short=None, synonyms=(), constants=dict(), choices=None, metavar=None, env=None, hidden=False, repeatable=False)[source]#

Bases: object

How one option is exposed.

Variables:
  • help (str) – One-line description, used as the argparse help text.

  • flag (str | None) – Long flag spelling without the dashes, or None for the field name.

  • short (str | None) – Single-character short flag, without the dash.

  • synonyms (tuple[str, ...]) – Further long spellings that set the same option, for the names Perl VEP uses. They work on the command line and in a config file; the environment variable keeps the canonical name.

  • constants (Mapping[str, object]) – Flags that set this option to a fixed value, such as Perl VEP’s --vcf for --output_format vcf, as flag name -> value.

  • choices (Sequence[object] | Callable[[], Sequence[object]] | None) – The permitted values, or a callable returning them for a vocabulary another package owns.

  • metavar (str | None) – argparse metavar override.

  • env (str | None) – Environment variable name, or None to derive one.

  • hidden (bool) – True to keep the option out of --help.

  • repeatable (bool) – True for a tuple option given once per item, as Perl VEP’s --custom is. Each occurrence is kept whole, with no comma splitting.

choices: Sequence[object] | Callable[[], Sequence[object]] | None#
constants: Mapping[str, object]#
env: str | None#
flag: str | None#
help: str#
hidden: bool#
metavar: str | None#
repeatable: bool#
resolved_choices()[source]#

Return the permitted values, calling choices if needed.

Return type:

tuple[object, ...] | None

short: str | None#
synonyms: tuple[str, ...]#
ensembl.vep.config.option_spec.option(help, *, flag=None, short=None, synonyms=(), constants=None, choices=None, metavar=None, env=None, hidden=False, repeatable=False)[source]#

Return attrs field metadata for one option.

Parameters:
  • help (str) – One-line description, used as the argparse help text.

  • flag (str | None, default: None) – Long flag spelling without the dashes, or None for the field name.

  • short (str | None, default: None) – Single-character short flag, without the dash.

  • synonyms (tuple[str, ...], default: ()) – Further long spellings that set the same option.

  • constants (Mapping[str, object] | None, default: None) – Flags that set this option to a fixed value, as flag name -> value.

  • choices (Sequence[object] | Callable[[], Sequence[object]] | None, default: None) – The permitted values, or a callable returning them.

  • metavar (str | None, default: None) – argparse metavar override.

  • env (str | None, default: None) – Environment variable name, or None to derive one.

  • hidden (bool, default: False) – True to keep the option out of --help.

  • repeatable (bool, default: False) – True for a tuple option given once per item, each kept whole.

Returns:

The metadata to pass as field(metadata=...).

Return type:

dict[str, OptionSpec]

ensembl.vep.config.option_spec.section_options(section_type)[source]#

Return the declared options of a section, keyed by field name.

Parameters:

section_type (type[ConfigSection]) – The section class to inspect.

Returns:

Field name -> (field, spec), in declaration

order, for the fields carrying option() metadata.

Return type:

dict[str, tuple[Attribute, OptionSpec]]

ensembl.vep.config.option_spec.unwrap_optional_type(type_annotation)[source]#

Split X | None into X and a nullability flag.

Parameters:

type_annotation (Any) – The resolved field type.

Returns:

The non-None member and whether None was a member. A union of more than

one non-None type is returned unchanged and reported as not optional.

Return type:

tuple[Any, bool]

ensembl.vep.config.report module#

The formats a report can be rendered in, and which of them a request can combine.

One vocabulary for every reporting command, so --output_format means the same thing to explain, catalogue, corpus and bench. A report is a table unless --graph asks for a diagram, and a format belongs to one kind or the other: resolution refuses the combinations that cannot be drawn rather than quietly rendering something else.

ensembl.vep.config.report.GRAPH_FORMATS = ('svg', 'dot', 'mermaid')#

Formats that render a diagram. svg is wrapped in a navigable HTML document.

ensembl.vep.config.report.REPORT_FORMATS = ('text', 'markdown', 'confluence', 'html', 'svg', 'dot', 'mermaid')#

Every format --format accepts, whichever kind the command can render.

ensembl.vep.config.report.TABLE_FORMATS = ('text', 'markdown', 'confluence', 'html')#

Formats that render rows.

ensembl.vep.config.report.resolve_report_format(format_name, *, graph, table_default, graph_default='svg', graph_formats=('svg', 'dot', 'mermaid'))[source]#

Return the format to render in, or say why the request cannot be met.

Parameters:
  • format_name (str | None) – The requested format, or None to take the default for the kind of report asked for.

  • graph (bool) – Whether a diagram was asked for.

  • table_default (str) – The format a table takes when none was named.

  • graph_default (str, default: 'svg') – The format a diagram takes when none was named.

  • graph_formats (tuple[str, ...], default: ('svg', 'dot', 'mermaid')) – The diagram formats this report can draw; empty for a report that has no diagram form.

Returns:

One of REPORT_FORMATS.

Return type:

str

Raises:

ValueError – If a diagram was asked for in a table format or of a report that has none, or if a diagram format was named without asking for a diagram.

ensembl.vep.config.sources module#

Configuration layers (file, environment, command line etc.) and how they combine.

ensembl.vep.config.sources.ConfigLayer#

section name -> field name -> value, carrying only what it sets.

Type:

One layer of configuration

alias of dict[str, dict[str, object]]

class ensembl.vep.config.sources.ConfigSource(*values)[source]#

Bases: Enum

Where a configuration value came from.

COMMAND_LINE = 'command line'#
DEFAULT = 'default'#
ENVIRONMENT = 'environment'#
FILE = 'file'#
ensembl.vep.config.sources.coerce_layer(layer, section_types)[source]#

Coerce every value in a layer to its declared type and check it against its choices.

Unknown sections are dropped silently, since a layer may cover sections the command does not read. An unknown field in a known section is dropped with a warning.

Raises:

ValueError – If a value cannot be read as its declared type or is not a permitted choice. The message names the section and field.

Return type:

dict[str, dict[str, object]]

ensembl.vep.config.sources.coerce_value(raw, type_annotation)[source]#

Coerce a value read from a file or the environment to a field’s declared type.

Command-line values have already been converted by argparse. These have not: TOML gives real ints and bools but strings for paths, and the environment gives strings for everything.

Parameters:
  • raw (object) – The value as read.

  • type_annotation (Any) – The field’s resolved type.

Returns:

The coerced value.

Return type:

object

Raises:

ValueError – If a string cannot be read as the declared type.

ensembl.vep.config.sources.merge_layers(*layers)[source]#

Merge configuration layers in increasing precedence order.

Return type:

dict[str, dict[str, object]]