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

chore: support proxy environment variables in network requests #519

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions exo/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import aiohttp
import argparse
import asyncio
import atexit
Expand Down Expand Up @@ -59,6 +60,7 @@
parser.add_argument("--tailscale-api-key", type=str, default=None, help="Tailscale API key")
parser.add_argument("--tailnet-name", type=str, default=None, help="Tailnet name")
parser.add_argument("--node-id-filter", type=str, default=None, help="Comma separated list of allowed node IDs (only for UDP and Tailscale discovery)")
parser.add_argument("--trust-env", action="store_true", help="Enable aiohttp to trust environment variables for proxy settings")
args = parser.parse_args()
print(f"Selected inference engine: {args.inference_engine}")

Expand Down Expand Up @@ -163,6 +165,12 @@ def preemptively_start_download(request_id: str, opaque_status: str):

last_broadcast_time = 0

if args.trust_env:
original_init = aiohttp.ClientSession.__init__
def patched_init(self, *init_args, **init_kwargs):
init_kwargs['trust_env'] = True
original_init(self, *init_args, **init_kwargs)
aiohttp.ClientSession.__init__ = patched_init

def throttled_broadcast(shard: Shard, event: RepoProgressEvent):
global last_broadcast_time
Expand Down