Skip to content

Commit ef1a231

Browse files
committed
Update user_agent.py
1 parent 7ee550f commit ef1a231

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

runpod/user_agent.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,24 @@
55

66
from runpod.version import __version__ as runpod_version
77

8-
os_info = f"{platform.system()} {platform.release()}; {platform.machine()}"
98

10-
USER_AGENT = f"RunPod-Python-SDK/{runpod_version}"
11-
USER_AGENT += f" ({os_info})"
12-
USER_AGENT += f" Language/Python {platform.python_version()}"
9+
def construct_user_agent():
10+
""" Constructs the User-Agent string for the RunPod-Python-SDK """
11+
os_info = f"{platform.system()} {platform.release()}; {platform.machine()}"
12+
python_version = platform.python_version()
13+
integration_method = os.getenv('RUNPOD_UA_INTEGRATION')
1314

15+
ua_components = [
16+
f"RunPod-Python-SDK/{runpod_version}",
17+
f"({os_info})",
18+
f"Language/Python {python_version}"
19+
]
1420

15-
if os.environ.get('RUNPOD_UA_INTEGRATION') is not None:
16-
USER_AGENT += f" Integration/{os.environ.get('RUNPOD_UA_INTEGRATION')}"
21+
if integration_method:
22+
ua_components.append(f"Integration/{integration_method}")
23+
24+
user_agent = " ".join(ua_components)
25+
return user_agent
26+
27+
28+
USER_AGENT = construct_user_agent()

0 commit comments

Comments
 (0)