Repository navigation
fix: keep runtime locks outside the working directory - #311
Liuchenbing-2026 wants to merge 1 commit into
Conversation
Use a per-user temporary directory, with TWINKLE_HOME as an override, and create it only when locks are used. Add real filesystem and cross-process regressions for read-only working directories. Signed-off-by: liuchenbing <chenliumail@163.com>
|
@Yunnglin could you please review this focused fix for the read-only working-directory part of #298? I reran the committed regression tests against the original base (
Rechecked on Linux/aarch64 with Python 3.12.13 and datasets 4.8.4, running as an unprivileged user so the read-only-directory cases really exercise This addresses only the lock-directory subproblem, not all of #298. Multi-host deployment and the full Tinker training workflow were not exercised in this rerun. Thanks! |
PR type
PR information
Importing
twinkle.utils.parallelcurrently creates.locksin the working directory, causingPermissionErrorwhen that directory is read-only.Move runtime locks to an absolute path under
TWINKLE_HOME, defaulting to<tempdir>/twinkle/<user>/.locks, and create the directory only when a processing lock or one-shot claim is used. Processes sharing this runtime directory coordinate across different working directories. Multi-host runs should setTWINKLE_HOMEto a writable shared filesystem.Addresses the read-only working-directory lock problem in #298. Add filesystem and subprocess regressions for both default/custom runtime paths, import without directory creation, cross-directory locking and claims, session rollover, and exception cleanup.
Experiment results
Validated on macOS arm64, CPython 3.12.13, datasets 5.1.0, filelock 4.1.1, and pytest 9.1.1:
ec8fd1f0660b09ed60938d02d2439533a5aa5c65: 5 failed, 1 passed, including real read-only-directoryPermissionErrorfailures.0de02dfe4103ef9033befdc72f90d1e4a1ce93b3: 6 passed, no skips.The tests load the real utility module directly and use real FileLock/filesystem/subprocess behavior. Read-only permission cases skip for root or non-POSIX environments. Validation covers this CPU utility; full training/SDK integration and hardware tests remain untested.
AI assistance: Codex assisted with the implementation and regression tests.