Skip to content

Reduce the worker-side discovery to an inert stub instead of rebuilding it #61

Description

@conradbzura

Description

Have the workflow discovery's pickle reduce target an inert stub on the worker side instead of faithfully reconstructing a functional EcsDiscovery/_EcsSubscriber.

wool serializes the dispatched task's WorkerProxy (task.to_protobufproxy_dumps → cloudpickle), and WorkerProxy.__wool_reduce__ drags the caller's discovery across the boundary into the worker. cfdb does single-level dispatch only — there is exactly one @wool.routine (src/cfdb/workflows/executor.py:182), and its body runs the preprocessing pipeline (processors shelling out to samtools/bgzip/tabix); it constructs no WorkerPool, holds no WorkerProxy, and calls no other routine. WorkerPool/discovery are constructed only dispatch-side (the API in src/cfdb/api/main.py, the LAN pool host in src/cfdb/workflows/worker_lan.py). So the discovery wool ships to the worker is never used worker-side.

Today's pickle fixes (#54 for EcsDiscovery, #60 for _EcsSubscriber) faithfully rebuild that unused object on unpickle: EcsDiscovery.__setstate__ calls build_ecs_client(...) to mint a fresh boto3 ECS client and fresh asyncio.Locks; _EcsSubscriber.__setstate__ mints a fresh queue. This is dead baggage — and worse, it forces the worker to be able to construct a boto3 ECS client (region resolution, credential chain) purely to reconstruct an object it never touches: a latent worker-side failure surface for zero functional benefit.

Proposed end state: the discovery reduces (via __reduce__) to an inert stub that satisfies wool's structural Discovery protocol but whose activation methods (__aenter__/__aexit__, subscribe, subscriber, publisher, poll_once) raise NotImplementedError("discovery is inert worker-side; nested dispatch is unsupported"). The stub needs no boto3 client, no region, no credentials, and no transient-field stripping. This is the natural terminus of the __reduce__ path and the cfdb-side counterpart of the durable factory-callable-discovery direction.

Motivation

Expected Outcome

  • The object wool drags to the worker deserializes into an inert stub; the worker constructs no boto3 ECS client and needs no AWS region/credentials to unpickle it.
  • Activating the stub worker-side (entering it / subscribe / poll_once / publisher) raises NotImplementedError naming nested dispatch as the unsupported case.
  • The interim __getstate__/__setstate__ hand-stripping on EcsDiscovery (Fix ECS workflow dispatch: unpicklable EcsDiscovery in proxy, cold-start TimeoutError, and exhausted subscriber #54) and _EcsSubscriber (Make _EcsSubscriber cloudpickle-safe so ECS workflow dispatch survives the wool reduce boundary #60) is removed in favor of the reduce-to-stub path (or kept only where still load-bearing).
  • A regression test asserts the reduced object is the inert stub (not a rebuilt discovery) and that its activation methods raise.
  • Verified precondition: wool does not enter/activate the proxy's discovery during normal single-level dispatch (only on nested dispatch). Confirm via the live GET /index/{dcc}/{local_id} E2E completing with the stub in place; if wool does touch it during normal dispatch, narrow which methods the stub must implement as functional no-ops rather than raisers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions