Skip to content

Comments

Only lock when actually downloading a model and per model_path#790

Merged
simo-prior merged 4 commits intomainfrom
eng-509/lock-download-model
Feb 19, 2026
Merged

Only lock when actually downloading a model and per model_path#790
simo-prior merged 4 commits intomainfrom
eng-509/lock-download-model

Conversation

@simo-prior
Copy link
Contributor

@simo-prior simo-prior commented Feb 18, 2026

Issue

https://linear.app/priorlabs/issue/ENG-509/filenotfounderror-level-error-errno-2-no-such-file-or-directory-tabpfn

Motivation and Context

Previously we were applying a global lock on every load_model_criterion_config() call to prevent race conditions while downloading models. This call would not necessarily result in a download and different model_paths do not require a shared lock.

@simo-prior simo-prior requested a review from a team as a code owner February 18, 2026 14:37
@simo-prior simo-prior requested review from oscarkey and removed request for a team February 18, 2026 14:37
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@CLAassistant
Copy link

CLAassistant commented Feb 18, 2026

CLA assistant check
All committers have signed the CLA.

@simo-prior simo-prior requested a review from noahho February 18, 2026 14:38
@simo-prior simo-prior changed the title Granular lock on download_model() Lock only when actually downloading a model and only per model_path Feb 18, 2026
@simo-prior simo-prior changed the title Lock only when actually downloading a model and only per model_path Only lock when actually downloading a model and only per model_path Feb 18, 2026
@simo-prior simo-prior changed the title Only lock when actually downloading a model and only per model_path Only lock when actually downloading a model and per model_path Feb 18, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the model download locking mechanism from a single global lock to a more granular, per-file lock, which is a great improvement for concurrent downloads of different models. However, a security audit identified a medium-severity path traversal vulnerability in the download locking mechanism, which could be exploited for Denial of Service attacks. Additionally, this change will likely break the existing concurrency test test__load_model_criterion_config__parallel_downloads_do_not_crash because the @_with_download_lock decorator was moved from load_model_criterion_config to download_model, and the test currently mocks download_model directly, bypassing the new locking mechanism. The test needs to be updated to correctly verify the new locking mechanism. A suggestion has also been provided to improve the robustness of the new decorator.

Copy link
Collaborator

@noahho noahho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't go very deep but this looks good to me and very well engineeered

@simo-prior simo-prior merged commit 803f7c2 into main Feb 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants