Implementation reference. These symbols describe how the project works; their presence here does not make them supported application imports. Use the documented entry points and support policy.
@contextmanagerdefreceipt_writer(destination:Path|None,*,field:str="run"):"""Check local storage before submission and publish without replacing an existing file."""iffieldnotin{"run","server"}:raiseValueError("Unsupported receipt field")ifdestinationisNone:yieldlambdarun:Nonereturndestination=destination.expanduser().absolute()ifos.path.lexists(destination):raiseFileExistsError("Receipt destination already exists; choose a new file")descriptor,temporary=tempfile.mkstemp(prefix=".spark-receipt-",dir=destination.parent)try:withos.fdopen(descriptor,"w",encoding="utf-8")asstream:defwrite(run):json.dump({"schema_version":1,field:run.to_dict()},stream)stream.write("\n")stream.flush()os.fsync(stream.fileno())# Hard-link publication is atomic and never replaces an existing path.os.link(temporary,destination)yieldwritefinally:os.unlink(temporary)