@@ -252,6 +252,7 @@ def test_my_telemetry(self):
252252
253253 def __init__ (
254254 self ,
255+ registry : str | None = None ,
255256 schema_version : str | None = None ,
256257 policies_dir : str | None = None ,
257258 inactivity_timeout : int = 30 ,
@@ -285,13 +286,14 @@ def __init__(
285286 if policies_dir :
286287 command += ["--advice-policies" , os .path .abspath (policies_dir )]
287288
288- if schema_version is None :
289- schema_version = list (Schemas )[- 1 ].value .rsplit ("/" , 1 )[- 1 ]
289+ if registry is None :
290+ if schema_version is None :
291+ schema_version = list (Schemas )[- 1 ].value .rsplit ("/" , 1 )[- 1 ]
292+ registry = f"https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v{ schema_version } .tar.gz[model]"
293+ elif os .path .isdir (registry ):
294+ registry = os .path .abspath (registry )
290295
291- command += [
292- "--registry" ,
293- f"https://github.com/open-telemetry/semantic-conventions/archive/refs/tags/v{ schema_version } .tar.gz[model]" ,
294- ]
296+ command += ["--registry" , registry ]
295297
296298 self ._command = command
297299 logger .debug ("Weaver command: %s" , command )
@@ -304,15 +306,15 @@ def __exit__(self, exc_type: Any, *_: Any) -> None:
304306 self ._stopped = True
305307 self .close ()
306308
307- def start (self , timeout : int = 60 ) -> "WeaverLiveCheck" :
309+ def start (self ) -> "WeaverLiveCheck" :
308310 logger .debug ("Starting WeaverLiveCheck process..." )
309311 self ._process = subprocess .Popen ( # pylint: disable=consider-using-with
310312 self ._command ,
311313 stdout = subprocess .PIPE ,
312314 stderr = subprocess .PIPE ,
313315 )
314316 try :
315- self ._wait_for_ready (timeout = timeout )
317+ self ._wait_for_ready ()
316318 self ._ready = True
317319 except Exception as exc : # pylint: disable=broad-except
318320 logs = self ._read_weaver_logs ()
@@ -322,22 +324,22 @@ def start(self, timeout: int = 60) -> "WeaverLiveCheck":
322324 raise
323325 return self
324326
325- def _wait_for_ready (self , timeout : int = 60 ) -> None :
327+ def _wait_for_ready (self ) -> None :
326328 retry = Retry (
327- total = timeout ,
329+ total = 10 ,
328330 backoff_factor = 1 ,
329331 backoff_max = 1 ,
330332 # Any non-2xx response from /health means weaver isn't ready yet.
331333 status_forcelist = list (range (300 , 600 )),
334+ raise_on_status = True ,
332335 allowed_methods = ["GET" ],
333336 )
334337 session = Session ()
335338 session .mount ("http://" , HTTPAdapter (max_retries = retry ))
336339 try :
337- response = session .get (
340+ session .get (
338341 f"http://localhost:{ self ._admin_port } /health" , timeout = 5
339342 )
340- response .raise_for_status ()
341343 except Exception as exc : # pylint: disable=broad-except
342344 if self ._process is not None and self ._process .poll () is not None :
343345 raise RuntimeError (
0 commit comments