httk.workflow.transfers¶
Crash-recoverable detached job transfer.
Attributes¶
Classes¶
One job a transfer offer or resume can actually inspect. |
Functions¶
|
Fence and seal one job, leaving no schedulable source marker. |
|
Validate a sealed bundle and return its manifest. |
|
Idempotently import a sealed bundle and publish its prior state. |
|
Validate an acknowledgement and retire the sealed source bundle. |
|
Finish source sealing and inventory every retained bundle. |
|
Select sealed and live jobs without changing transfer state. |
|
Seal every finished job of workspace into a bundle for one destination. |
|
Retire the sealed source bundle of every named job. |
|
Drop a staged incoming bundle whose payload the workspace now owns. |
Module Contents¶
- class httk.workflow.transfers.TransferCandidate[source]¶
One job a transfer offer or resume can actually inspect.
- Parameters:
job_id – Identify the job.
job_key – Preserve the stable job key.
prior_kind – State the job had before transfer.
source_placement – Placement in the source workspace.
bundle – Sealed payload, when this is a resumed transfer.
marker – Live source marker, when this is a new offer.
job – Readable immutable job definition, when available.
manifest – Validated sealed-bundle manifest, when available.
problem – Readability problem, if the candidate cannot be validated.
- source_placement: pathlib.PurePosixPath[source]¶
- bundle: pathlib.Path | None[source]¶
- manifest: collections.abc.Mapping[str, Any] | None = None[source]¶
- httk.workflow.transfers.detach_job(workspace, job_id, *, destination_workspace_id, destination_remote=None, destination_placement=None, transfer_id=None)[source]¶
Fence and seal one job, leaving no schedulable source marker.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the source workspace.
job_id (str) – Identify the job to detach.
destination_workspace_id (str) – Identify the destination workspace.
destination_remote (str | None) – Preserve the destination’s remote identifier.
destination_placement (str | pathlib.PurePosixPath | None) – Override the destination placement.
transfer_id (str | None) – Reuse a transfer id when resuming sealing.
- Returns:
The sealed source bundle path.
- Raises:
ValueError – If the job is missing, active, joined, or already transferring incompatibly.
- Return type:
- httk.workflow.transfers.validate_bundle(bundle)[source]¶
Validate a sealed bundle and return its manifest.
- Parameters:
bundle (str | os.PathLike[str]) – Locate the sealed transfer bundle.
- Returns:
The validated transfer manifest.
- Raises:
httk.workflow.errors.FormatError – If the bundle format, digest, marker, or runner is invalid.
- Return type:
- httk.workflow.transfers.import_bundle(workspace, bundle)[source]¶
Idempotently import a sealed bundle and publish its prior state.
Runners are installed and verified before the imported job becomes schedulable; the returned acknowledgement identifies the imported payload and transfer.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the destination workspace.
bundle (str | os.PathLike[str]) – Locate the sealed source bundle.
- Returns:
The destination acknowledgement.
- Raises:
httk.workflow.errors.FormatError – If the bundle or copied payload fails validation.
ValueError – If the bundle names another destination workspace.
- Return type:
- httk.workflow.transfers.acknowledge_transfer(workspace, acknowledgement)[source]¶
Validate an acknowledgement and retire the sealed source bundle.
An acknowledgement that carries an identity signature must carry a valid one: retiring a source is irreversible enough that a damaged or forged attribution is refused rather than recorded. An acknowledgement with no signature is accepted exactly as before, so a destination without an identity key keeps working.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the source workspace.
acknowledgement (collections.abc.Mapping[str, object]) – Supply the destination acknowledgement.
- Returns:
The retired source bundle path.
- Raises:
httk.workflow.errors.FormatError – If the acknowledgement format, signature, or identity is invalid.
- Return type:
- httk.workflow.transfers.recover_transfers(workspace)[source]¶
Finish source sealing and inventory every retained bundle.
- httk.workflow.transfers.select_transfer_jobs(workspace, *, destination_workspace_id, states=DEFAULT_OFFER_STATES, placement=None, job_ids=None, destination_remote=None, include_transferring=False)[source]¶
Select sealed and live jobs without changing transfer state.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the source workspace.
destination_workspace_id (str) – Select one destination’s sealed ledgers.
states (collections.abc.Iterable[str]) – Select quiescent states eligible for offering.
placement (str | pathlib.PurePosixPath | None) – Restrict source placements by normalized prefix.
job_ids (collections.abc.Iterable[str] | None) – Restrict selection to explicit job ids when supplied.
destination_remote (str | None) – Restrict sealed ledgers to one remote name.
include_transferring (bool) – Include live interrupted-transfer markers for advisory checks.
- Returns:
Candidates in the same placement/key order as
offer_transfers().- Raises:
ValueError – If the destination id or requested states are invalid.
- Return type:
- httk.workflow.transfers.offer_transfers(workspace, *, destination_workspace_id, states=DEFAULT_OFFER_STATES, placement=None)[source]¶
Seal every finished job of workspace into a bundle for one destination.
This is the far side of a results fetch: the remote that ran the work offers what stopped there, and the workspace that asked pulls each bundle and imports it. Offering is idempotent because a sealed bundle is reported from its ledger rather than sealed again, so the jobs a first call detached — which no longer have a schedulable marker — are exactly the jobs a second call re-offers, and an interrupted fetch resumes by simply asking again.
A job that cannot leave right now is skipped rather than fatal: one still referenced by an unresolved join keeps the campaign it belongs to consistent, and reporting the rest lets the fetch make progress.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the source workspace.
destination_workspace_id (str) – Identify the destination workspace.
states (collections.abc.Iterable[str]) – Select quiescent states eligible for offering.
placement (str | pathlib.PurePosixPath | None) – Restrict offers to this placement prefix.
- Returns:
Offered transfer records in placement order.
- Raises:
ValueError – If the destination id or requested states are invalid.
- Return type:
- httk.workflow.transfers.retire_transfers(workspace, job_ids, *, destination_workspace_id=None)[source]¶
Retire the sealed source bundle of every named job.
A fetch retires at the source only once the destination holds an acknowledgement, so the identity of the job is all this side needs; naming the destination as well refuses to retire a bundle that was sealed for somebody else. Retirement moves the bundle rather than deleting it, and a bundle already retired is reported as such, so calling this twice is the same as calling it once.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the source workspace.
job_ids (collections.abc.Sequence[str]) – Identify the jobs whose bundles to retire.
destination_workspace_id (str | None) – Restrict retirement to one destination.
- Returns:
Retirement records for the named jobs.
- Raises:
ValueError – If a job id has no matching detached transfer.
- Return type:
- httk.workflow.transfers.discard_staged_bundle(workspace, staging)[source]¶
Drop a staged incoming bundle whose payload the workspace now owns.
The staging tree is renamed out of the incoming directory before it is removed, so an interrupted removal can never leave a partial bundle where a resumed fetch would find one and mistake it for the real thing.
- Parameters:
workspace (httk.workflow.workspace.Workspace) – Provide the workspace owning the staging directory.
staging (pathlib.Path) – Locate the staged bundle to discard.