Skip to content

Commit 6a7382f

Browse files
authored
Log glibc version and Python version (#178)
* Log glibc version and Python version This helps determining which ABI versions are still used * Ooops
1 parent 10753bd commit 6a7382f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/kernels/_system.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import platform
2+
from typing import Optional
3+
4+
5+
def glibc_version() -> Optional[str]:
6+
libc_version = platform.libc_ver()
7+
8+
if len(libc_version) == 2 and libc_version[0] == "glibc":
9+
return libc_version[1]
10+
11+
return None

src/kernels/utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from huggingface_hub import file_exists, snapshot_download
1717
from packaging.version import parse
1818

19+
from kernels._system import glibc_version
1920
from kernels._versions import select_revision_or_version
2021
from kernels.lockfile import KernelLock, VariantLock
2122

@@ -527,17 +528,28 @@ def _get_user_agent(
527528
if os.getenv("DISABLE_TELEMETRY", "false").upper() in ENV_VARS_TRUE_VALUES:
528529
return None
529530

531+
glibc = glibc_version()
532+
python = ".".join(platform.python_version_tuple()[:2])
533+
530534
if user_agent is None:
531535
user_agent = {}
536+
532537
if isinstance(user_agent, dict):
533538
user_agent.update(
534539
{
535540
"kernels": __version__,
541+
"python": python,
536542
"torch": torch.__version__,
537543
"build_variant": build_variant(),
538544
"file_type": "kernel",
539545
}
540546
)
547+
if glibc is not None:
548+
user_agent["glibc"] = glibc
549+
541550
elif isinstance(user_agent, str):
542-
user_agent += f"; kernels/{__version__}; torch/{torch.__version__}; build_variant/{build_variant()}; file_type/kernel"
551+
user_agent += f"; kernels/{__version__}; python/{python}; torch/{torch.__version__}; build_variant/{build_variant()}; file_type/kernel"
552+
if glibc is not None:
553+
user_agent += f"; glibc/{glibc}"
554+
543555
return user_agent

0 commit comments

Comments
 (0)