Skip to content

discover and reconnect

Discover remote jobs and reconnect without submitting work again.

list_jobs() reads cached records unless an authenticated platform is supplied. sync() performs remote discovery and updates the cache. add() records a known UUID locally without verifying its existence. connect() wraps a cached record in a live-capable TrackedJob; authentication can be requested at that point.

from femora.jobs import list_jobs, connect

def inspect_cached_jobs():
    for record in list_jobs():
        print(record.id, record.state, record.checked_at)

def inspect_live_job(job_id):
    job = connect(job_id)  # Existing cached record; may prompt for login.
    return job.status()

Cached state is not necessarily current remote state. The registry saves safe identity/resource metadata, not credentials. Cancellation, ZIP downloads, remote cleanup, and local hiding are distinct operations; see TrackedJob and JobRegistry before using them.

Functions:

list_jobs

list_jobs(*, platform=None, registry=None)

List cached jobs, or discover remote jobs when given an authenticated adapter.

Parameters:

Name Type Description Default
platform JobDiscovery | None

Adapter for live discovery; None reads only the cache.

None
registry JobRegistry | None

Cache to use, or the default registry.

None

Returns:

Name Type Description
records list[JobRecord]

Cached records, or newly discovered/refreshed records.

Example
from femora.jobs import list_jobs
for record in list_jobs():
    print(record.id, record.state, record.checked_at)
Note

jobs.list is an alias for this function. Cached states can be stale; passing a platform performs remote discovery and updates the cache.

add

add(job_id, *, platform='tacc', name=None, connection=None, resources=None, registry=None)

Register an existing job without submitting or contacting the provider.

Parameters:

Name Type Description Default
job_id str

Existing provider UUID.

required
platform str

Tracking adapter name, currently tacc.

'tacc'
name str | None

Display name; defaults to job_id.

None
connection dict | None

Safe base_url, username, app_id, and app_version fields.

None
resources dict | None

Resource metadata; only approved fields are saved.

None
registry JobRegistry | None

Local cache or default registry.

None

Returns:

Name Type Description
record JobRecord

Existing or newly cached record.

Raises:

Type Description
ValueError

Identity, connection, or platform is invalid, or the key is hidden.

Note

Registration does not verify that the job exists. Never supply passwords or access tokens in connection fields.

sync

sync(platform, *, registry=None)

Discover remote jobs through an authenticated adapter and cache them.

Remote discovery never deletes cached jobs that a provider no longer lists. Only normalized summaries and safe connection fields are persisted.

Parameters:

Name Type Description Default
platform JobDiscovery

Authenticated adapter supporting discovery.

required
registry JobRegistry | None

Destination cache, or the default registry.

None

Returns:

Name Type Description
records list[JobRecord]

Refreshed records discovered during this call.

Note

This contacts the provider and writes the local cache, but does not submit jobs.

connect

connect(job_id, *, platform=None, registry=None)

Reconnect to a recorded job; optionally reuse an authenticated adapter.

Parameters:

Name Type Description Default
job_id str

Cached provider UUID or full registry key.

required
platform Platform | None

Authenticated adapter; None prompts via the stored provider.

None
registry JobRegistry | None

Local registry to search.

None

Returns:

Name Type Description
job TrackedJob

Live-capable handle wrapping the cached record.

Raises:

Type Description
ValueError

Record is missing/ambiguous or authenticated account does not match.

Note

This does not submit a job. Register an uncached existing UUID with add() first, or discover it using list_jobs(platform=authenticated_adapter).