Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion autodata_tests/utils/test_native_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,25 @@ def native_setup(tmp_path):
"while not Path(os.environ['TEST_RELEASE']).exists():\n"
" time.sleep(0.01)\n"
"assert (cache / 'payload').exists(), 'Active cache was evicted'\n"
"failure = Path(os.environ['TEST_FAIL_ONCE'])\n"
"if failure.exists():\n"
" failure.unlink()\n"
" raise SystemExit(7)\n"
"raise SystemExit(int(os.environ.get('TEST_EXIT', '0')))\n"
)
uv.chmod(0o755)
root = tmp_path / "managed cache"
processes = []

def start(letter, *, hold=False, exit_code=0):
def start(letter, *, hold=False, exit_code=0, fail_once=False):
key = f"uv0.12.21-python3.12-cuda12.8.1-8.9-{letter * 64}"
started = tmp_path / f"started-{len(processes)}"
release = tmp_path / f"release-{len(processes)}"
failure = tmp_path / f"fail-once-{len(processes)}"
if not hold:
release.touch()
if fail_once:
failure.touch()
environment = os.environ.copy()
environment.pop("UV_CACHE_DIR", None)
process = subprocess.Popen(
Expand All @@ -68,6 +75,7 @@ def start(letter, *, hold=False, exit_code=0):
"NATIVE_CACHE_KEY": key,
"TEST_STARTED": str(started),
"TEST_RELEASE": str(release),
"TEST_FAIL_ONCE": str(failure),
"TEST_EXIT": str(exit_code),
},
start_new_session=True,
Expand Down Expand Up @@ -111,6 +119,12 @@ def test_interrupted_sync_keeps_fallback_and_partial_cache(native_setup, interru
assert set((root / "keys").iterdir()) == {b, d}


def test_sync_retries_a_failed_attempt(native_setup):
_, start = native_setup
_, cache, _, _ = start("a", fail_once=True)
assert (cache / ".last-success").is_file()


def test_concurrent_sync_protects_current_and_only_prunes_managed_keys(native_setup, tmp_path):
root, start = native_setup
_, a, _, _ = start("a")
Expand Down
3 changes: 2 additions & 1 deletion docker/setup/sync_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ args=(--locked)
while read -r package; do
args+=(--no-install-package "$package")
done <<< "$sim_packages"
uv sync "${args[@]}" "$@"
# ovrtx's PyPI sdist downloads its wheel while it builds, outside uv's download retries.
uv sync "${args[@]}" "$@" || { echo "uv sync failed with status $?; retrying once" >&2; uv sync "${args[@]}" "$@"; }
4 changes: 3 additions & 1 deletion scripts/ci/sync_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,7 @@ done
mkdir -p -- "$current"
# Failed or interrupted retries must not count as a successful cache use.
rm -f -- "$current/.last-success"
UV_CACHE_DIR="$current" UV_LINK_MODE=copy uv sync --locked --group curobo
sync_environment() { UV_CACHE_DIR="$current" UV_LINK_MODE=copy uv sync --locked --group curobo; }
# ovrtx's PyPI sdist downloads its wheel while it builds, outside uv's download retries.
sync_environment || { echo "uv sync failed with status $?; retrying once" >&2; sync_environment; }
touch -- "$current/.last-success"
Loading