"""Small append-only progress events shared with the external launcher.""" import json import os from pathlib import Path def report(state, **details): target = os.environ.get("WORKSHOP_PROGRESS") if not target: return try: with Path(target).open("a", encoding="utf-8") as stream: stream.write(json.dumps(dict(state=state, **details), ensure_ascii=False) + "\n") except OSError: # Progress reporting must not interrupt a render or hide its result. pass