ensembl.vep.workflow package#

Executable workflows composed from annotation tracks.

Subpackages#

Submodules#

ensembl.vep.workflow.base module#

An annotation workflow over an input buffer.

class ensembl.vep.workflow.base.Workflow(*, name, tracks)[source]#

Bases: object

Ordered annotation tracks for an input buffer.

A workflow owns its tracks, and a track owns the source it reads, so a workflow holds live per-worker state and is built inside the process that annotates with it.

Variables:
  • name (str) – Workflow implementation name.

  • tracks (tuple[AnnotationTrack[Any], ...]) – Ordered runtime tracks.

annotate(input_buffer, *, threads=1)[source]#

Return ordered results from every track.

Parameters:
  • input_buffer (VariationAlleleBuffer) – Read-only input for every track.

  • threads (int, default: 1) – Maximum independently runnable tracks.

Returns:

Results ordered by declared track order.

Return type:

list[TrackResult[Any]]

Raises:

ValueError – If threads is less than one.

begin_payload(input_buffer)[source]#

Release the previous payload’s state and prime each track for this one.

The whole payload is passed, not one annotation window, so a track fetches and caches what the payload needs once rather than once per window.

close()[source]#

Close every track’s source.

name: str#
track(identifier)[source]#

Return the track that produced results under identifier.

Raises:

KeyError – If no track in this workflow has that identifier.

Return type:

AnnotationTrack[Any]

tracks: tuple[AnnotationTrack[Any], ...]#

ensembl.vep.workflow.executor module#

Payload execution: who runs the work, and how the work is grouped into payloads.

Three things, one per step of a run’s spine. ExecutionSpec is what the configuration asked for. PayloadIterator groups a source’s records into the payloads one unit of work holds. Executor runs them against a Worker, serially or across processes, and yields the results in payload order whatever order they finish in.

class ensembl.vep.workflow.executor.ExecutionSpec(*, processes=1, start_method=StartMethod.AUTO, threads=1, buffer_size=5000, annotation_window=1024, max_in_flight=None)[source]#

Bases: object

Worker-local annotation execution settings.

The payload and result types are deliberately absent from this value object. They must be serialisable transport values whenever processes exceeds one; live model objects remain inside a worker.

Variables:
  • processes (int) – Number of independent worker processes.

  • start_method (StartMethod) – Multiprocessing context, or auto for the platform default.

  • threads (int) – Threads available to independent tracks in each worker.

  • buffer_size (int) – Maximum records in one sequence-region input buffer.

  • annotation_window (int) – Maximum variations retaining overlap graphs at one time.

  • max_in_flight (int | None) – Explicit submitted-payload cap, or None to match workers.

annotation_window: int#
buffer_size: int#
property effective_max_in_flight: int#

Return the explicit queue cap, defaulting to one payload per worker.

classmethod from_config(config)[source]#

Build a specification from the declared execution options.

Return type:

ExecutionSpec

max_in_flight: int | None#
multiprocessing_context()[source]#

Return the multiprocessing context to run workers in.

auto means fork wherever a forked worker is safe, which is what keeps the parallel path fast: a forked worker inherits the loaded package, its catalogue and its caches, while a spawned one re-imports all of it. Measured on 10,000 ClinVar variants across four workers, spawning cost about 30% of wall time. Threads are the exception – forking a process that already has them is unsafe – so a threaded run takes the platform default instead.

Return type:

BaseContext | None

processes: int#
start_method: StartMethod#
threads: int#
class ensembl.vep.workflow.executor.Executor[PayloadT, ResultT](*, specification, worker_factory, payload_iterator)[source]#

Bases: Generic[PayloadT, ResultT]

Ordered payload executor with one worker per process.

A worker is built after its process starts and then reused, so what the executor transports is the factory rather than the worker: a worker holds open sources and warm caches that neither cross a process boundary nor survive a rebuild. The serial path runs the same way, against a worker of its own in the calling process, so there is one execution contract rather than two.

Variables:
  • specification (ExecutionSpec) – Process and queue configuration.

  • worker_factory (Callable[[], Worker[PayloadT, ResultT]]) – Construct one worker. It is what crosses to a worker process, so it has to pickle; the worker it builds does not.

  • payload_iterator (Iterable[PayloadT]) – The payloads to run, in input order, each serialisable whenever processes exceeds one. A run passes a PayloadIterator.

execute()[source]#

Yield every payload’s result in payload order, while limiting queued work.

Yields:

Iterator[ResultT] – Results in the order payload_iterator produced the payloads.

payload_iterator: Iterable[PayloadT]#
specification: ExecutionSpec#
worker_factory: Callable[[], Worker[PayloadT, ResultT]]#
class ensembl.vep.workflow.executor.PayloadIterator[RecordT](*, records, batch_size, region_of=None)[source]#

Bases: Generic[RecordT]

One source’s records, grouped into the payloads an executor runs.

Here rather than in the source being read: a source says what a record is and which region it sits on, and how many records make one unit of work is an execution setting (buffer_size).

Variables:
  • records (Iterable[RecordT]) – The records to group, in input order. Closed with this iterator, since reading them is what holds the input open.

  • batch_size (int) – The most records one payload may hold.

  • region_of (Callable[[RecordT], str] | None) – Name the sequence region a record sits on. A payload then never spans two regions, which is what a worker’s annotation tracks prime from – one region’s features, fetched once for the whole payload. None groups by size alone, for records that name no region.

batch_size: int#
payloads()[source]#

Yield payloads of at most batch_size records, in input order.

Yields:

Iterator[tuple[RecordT, …]] – Each payload, closed by its size or by a region change.

records: Iterable[RecordT]#
region_of: Callable[[RecordT], str] | None#