nemo_gym.tasks.harbor.records
nemo_gym.tasks.harbor.records
The two record files prepare writes next to the task folders, and how they are read.
compose-images.json records image configurations, built-images.json records the images built per context digest and service. This module names the files and the service keys, takes the sidecar lock, replaces a file atomically, reads it with one retry against a torn write, and reads the per-service entries with the legacy main-only fallback. The loader, the recorders, the build modules and the environment server all read through it.
Module Contents
Functions
Data
API
The built images recorded in folder (the tasks’ parent), or {} when none were.
The image configurations recorded in folder (the tasks’ parent), or {} when none were.
The JSON object in the record file at path, or {} when the file is missing or not an object.
Writers replace the file atomically (write_json_record), so a torn read should not happen; as
belt and braces a file that does not parse is read once more after a short pause (a record an older
writer is still truncating and rewriting) and HarborTaskError names it if it stays invalid.
Hold an exclusive lock on path’s sidecar lock file (<file>.lock) for a read-modify-write of it.
Two Gym processes can share one datasets folder (gym eval run and gym dataset validate of one
harbor: ref both record into it), so every read, merge and replace of a record file happens under
this lock or a concurrent writer’s entries are lost. flock is per open file description, so threads
of one process are serialised as well. The lock file stays next to the record; it carries no content.
Replace the record file at path with data atomically: written sorted and indented to a temporary
file in the same directory, fsynced, then moved over path with os.replace, so a reader opens either
the old file or the new one and never a truncated one. Callers merging into an existing record hold
record_lock around the read, the merge and this call.