File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1616from huggingface_hub import file_exists , snapshot_download
1717from packaging .version import parse
1818
19+ from kernels ._system import glibc_version
1920from kernels ._versions import select_revision_or_version
2021from 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
You can’t perform that action at this time.
0 commit comments