File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import contextlib
34import json
45import logging
6+ import os
57import socket
68import sys
79from dataclasses import dataclass , field
@@ -287,10 +289,15 @@ def _get_client() -> docker.DockerClient | None:
287289 client = None
288290
289291 try :
290- if Path ("/var/run/docker.sock" ).exists ():
291- client = docker .DockerClient (base_url = "unix://var/run/docker.sock" )
292- else :
293- client = docker .from_env ()
292+ with (
293+ Path (os .devnull ).open ("w" ) as dev_null ,
294+ contextlib .redirect_stdout (dev_null ),
295+ contextlib .redirect_stderr (dev_null ),
296+ ):
297+ if Path ("/var/run/docker.sock" ).exists ():
298+ client = docker .DockerClient (base_url = "unix://var/run/docker.sock" )
299+ else :
300+ client = docker .from_env ()
294301 except docker .errors .DockerException :
295302 if logger .isEnabledFor (logging .DEBUG ):
296303 logger .exception ("Failed to get Docker client" )
Original file line number Diff line number Diff line change 33import contextlib
44import hashlib
55import logging
6+ import os
67import socket
78from dataclasses import dataclass , field
89from enum import Enum
@@ -300,9 +301,14 @@ def _get_client() -> kubernetes.client.ApiClient | None:
300301 client = None
301302
302303 try :
303- kubernetes .config .load_kube_config ()
304- client = kubernetes .client .ApiClient ()
305- client .user_agent = "gpustack/runtime"
304+ with (
305+ Path (os .devnull ).open ("w" ) as dev_null ,
306+ contextlib .redirect_stdout (dev_null ),
307+ contextlib .redirect_stderr (dev_null ),
308+ ):
309+ kubernetes .config .load_config ()
310+ client = kubernetes .client .ApiClient ()
311+ client .user_agent = "gpustack/runtime"
306312 except kubernetes .config .config_exception .ConfigException :
307313 if logger .isEnabledFor (logging .DEBUG ):
308314 logger .exception ("Failed to get Kubernetes client" )
Original file line number Diff line number Diff line change 88from pathlib import Path
99
1010try :
11- with contextlib . redirect_stdout ( Path (os .devnull ).open ("w" )):
11+ with Path (os .devnull ).open ("w" ) as dev_null , contextlib . redirect_stdout ( dev_null ):
1212 from amdsmi import *
1313except (ImportError , KeyError , OSError ):
1414
You can’t perform that action at this time.
0 commit comments