Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control pip timeout duration via environment variable #1694

Merged
merged 6 commits into from
Feb 20, 2024
Merged

Control pip timeout duration via environment variable #1694

merged 6 commits into from
Feb 20, 2024

Conversation

Di-Is
Copy link
Contributor

@Di-Is Di-Is commented Feb 19, 2024

Summary

Add the environment variable UV_REQUEST_TIMEOUT to allow control over pip timeouts.

Closes #1549

Test Plan

I built uv in the repository top Dockerfile, set the timeout to 3 seconds, and ran uv pip install torch.
I measured the execution time with the time command and confirmed that the process finished at a value close to the timeout we set.

root@037c69228cdc:~# time UV_REQUEST_TIMEOUT=3 /uv pip install torch
Resolved 22 packages in 25ms
error: Failed to download distributions
  Caused by: Failed to fetch wheel: nvidia-cusolver-cu12==11.4.5.107
  Caused by: Failed to extract source distribution
  Caused by: request or response body error: operation timed out
  Caused by: operation timed out

real    0m3.064s
user    0m0.225s
sys     0m0.240s

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! I have a couple minor questions.

@zanieb zanieb added the configuration Settings and such label Feb 19, 2024
match value.parse::<u64>() {
Ok(parsed) => parsed,
Err(_) => {
eprintln!("Warning: UV_REQUEST_TIMEOUT is an invalid value. Using default value.");
Copy link
Member

Choose a reason for hiding this comment

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

We have a warn_user_once! macro that we should use instead here.

Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to use .map_err instead of a match here?

Copy link
Member

Choose a reason for hiding this comment

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

I'd also probably be a little clearer here, maybe:

Ignoring invalid value for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got "{value}".

}
Err(_) => default_timeout,
};
debug!("Pip request timeout is {}.", timeout);
Copy link
Member

Choose a reason for hiding this comment

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

We should probably not say "Pip" this is our general registry client

Suggested change
debug!("Pip request timeout is {}.", timeout);
debug!("Using registry request timeout of {}s", timeout);

@Di-Is
Copy link
Contributor Author

Di-Is commented Feb 20, 2024

@zanieb
Sorry, I deleted some commits because I had the wrong user to push.
I have re-committed it and would appreciate it if you could check it.

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

Thanks!

@zanieb zanieb merged commit 36edaee into astral-sh:main Feb 20, 2024
7 checks passed
zanieb added a commit that referenced this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Settings and such
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Operation Timeout on Pip Install
2 participants