Skip to content

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
zanieb added a commit that referenced this pull request Feb 21, 2024
ashwinb pushed a commit to llamastack/llama-stack that referenced this pull request Feb 3, 2025
This fixes the following timeout issue when installing PyTorch via uv.
Also see reference: astral-sh/uv#1694,
astral-sh/uv#1549

```
Installing pip dependencies
Using Python 3.10.16 environment at: /home/yutang/.conda/envs/distribution-myenv
  × Failed to download and build `antlr4-python3-runtime==4.9.3`
  ├─▶ Failed to extract archive
  ├─▶ failed to unpack
  │   `/home/yutang/.cache/uv/sdists-v7/.tmpDWX4iK/antlr4-python3-runtime-4.9.3/src/antlr4/ListTokenSource.py`
  ├─▶ failed to unpack
  │   `antlr4-python3-runtime-4.9.3/src/antlr4/ListTokenSource.py` into
  │   `/home/yutang/.cache/uv/sdists-v7/.tmpDWX4iK/antlr4-python3-runtime-4.9.3/src/antlr4/ListTokenSource.py`
  ├─▶ error decoding response body
  ├─▶ request or response body error
  ╰─▶ operation timed out
  help: `antlr4-python3-runtime` (v4.9.3) was included because `torchtune`
        (v0.5.0) depends on `omegaconf` (v2.3.0) which depends on
        `antlr4-python3-runtime>=4.9.dev0, <4.10.dev0`
Failed to build target distribution-myenv with return code 1
```

---------

Signed-off-by: Yuan Tang <[email protected]>
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