hpcflow.sdk.monitoring.registry.SubmissionRegistry#

class hpcflow.sdk.monitoring.registry.SubmissionRegistry(app)#

Bases: object

Persist submission history independently of workflow-store readability.

The host-scoped JSON registry retains job references needed for monitoring and cancellation. Read legacy history without changing its source file. Mutations use an OS lock and atomic replacement. Inactive and unknown records have separate retention limits; active records are protected. Only explicit unregistering releases IDs; automatic pruning leaves them retired.

Methods

add_job

Append one successful job reference immediately and advance the record revision.

begin

Register a submission part before jobs are launched and return its local ID.

finish

Clear submission-in-progress tracking and advance the record revision.

read

Read typed records, or import legacy text history in memory if JSON is absent.

transaction

Yield mutable registry data under an exclusive lock and commit on success.

unregister

Remove one submission part and make its ID explicitly reusable.

unregister_all

Release all inactive entries, or every entry when explicitly requested.

unregister_many

Validate and remove explicit IDs atomically, resolving -1 under the lock.

update

Merge observations only when their record revisions still match the registry.

Attributes

Parameters:

app (BaseApp)

SCHEMA_VERSION = 1#
add_job(local_id, job)#

Append one successful job reference immediately and advance the record revision.

Parameters:
Return type:

None

begin(submission, part)#

Register a submission part before jobs are launched and return its local ID.

Save workflow/template names and submitting-process identity immediately so a partial or interrupted submission can still be monitored.

Parameters:
Return type:

int

finish(local_id)#

Clear submission-in-progress tracking and advance the record revision.

Remove a record with no successfully registered jobs, including submissions that failed before launching anything. Existing local IDs remain allocated.

Parameters:

local_id (int)

Return type:

None

read()#

Read typed records, or import legacy text history in memory if JSON is absent.

Repair legacy display names without loading workflows or writing files. Malformed or unsupported JSON raises ValueError rather than silently discarding registered job references.

Return type:

RegistryData

transaction(*, prune=True)#

Yield mutable registry data under an exclusive lock and commit on success.

After the caller finishes, apply separate inactive and unknown retention limits, retain every active record, and atomically replace the JSON document. Unknown records are ordered by submission time, then local ID; rechecking a stale record does not make it recent. Explicit removal uses prune=False to preserve records outside its selection. Exceptions skip the commit.

Parameters:

prune (bool)

unregister(local_id)#

Remove one submission part and make its ID explicitly reusable.

Do not load/delete workflows or query/cancel jobs. Reject removal while submission writes are in progress. Save the next revision for a reused ID so previously collected observations cannot overwrite its new owner. Automatically pruned IDs never enter this reuse pool.

Parameters:

local_id (int)

Return type:

SubmissionRecord

unregister_all(include_active=False)#

Release all inactive entries, or every entry when explicitly requested.

Selection uses last recorded activity without querying schedulers. Including active entries also includes unknown entries, which may still be running. Validate the whole selection before removing anything; a live submitter aborts the transaction. Do not prune records outside the selected activity states, even when retention settings have since been lowered.

Parameters:

include_active (bool)

Return type:

list[SubmissionRecord]

unregister_many(local_ids)#

Validate and remove explicit IDs atomically, resolving -1 under the lock.

Only the named submission parts are removed. Unknown IDs and submitting records reject the entire selection before any IDs are released.

Parameters:

local_ids (int | str | Sequence[int])

Return type:

list[SubmissionRecord]

update(records)#

Merge observations only when their record revisions still match the registry.

Preserve concurrent submission/job updates rather than overwriting them with older observations. Apply normal retention and return the IDs still retained.

Parameters:

records (list[SubmissionRecord])

Return type:

set[int]