@@ -222,8 +222,9 @@ def test_description(
222
222
environment YAML file based on the model weights description.
223
223
- A `BioimageioCondaEnv` or a path to a conda environment YAML file.
224
224
Note: The `bioimageio.core` dependency will be added automatically if not present.
225
- run_command: (Experimental feature!) Function to execute (conda) terminal commands in a subprocess
226
- (ignored if **runtime_env** is `"currently-active"`).
225
+ run_command: (Experimental feature!) Function to execute (conda) terminal commands in a subprocess.
226
+ The function should raise an exception if the command fails.
227
+ **run_command** is ignored if **runtime_env** is `"currently-active"`.
227
228
"""
228
229
if runtime_env == "currently-active" :
229
230
rd = load_description_and_test (
@@ -371,8 +372,6 @@ def _test_in_env(
371
372
except Exception as e :
372
373
raise RuntimeError ("Conda not available" ) from e
373
374
374
- working_dir .mkdir (parents = True , exist_ok = True )
375
- summary_path = working_dir / "summary.json"
376
375
try :
377
376
run_command (["conda" , "activate" , env_name ])
378
377
except Exception :
@@ -404,28 +403,39 @@ def _test_in_env(
404
403
)
405
404
return summary
406
405
406
+ working_dir .mkdir (parents = True , exist_ok = True )
407
+ summary_path = working_dir / "summary.json"
408
+ assert not summary_path .exists (), "Summary file already exists"
407
409
cmd = []
410
+ cmd_error = None
408
411
for summary_path_arg_name in ("summary" , "summary-path" ):
409
- run_command (
410
- cmd := (
411
- [
412
- "conda" ,
413
- "run" ,
414
- "-n" ,
415
- env_name ,
416
- "bioimageio" ,
417
- "test" ,
418
- str (source ),
419
- f"--{ summary_path_arg_name } ={ summary_path .as_posix ()} " ,
420
- f"--determinism={ determinism } " ,
421
- ]
422
- + ([f"--expected-type={ expected_type } " ] if expected_type else [])
423
- + (["--stop-early" ] if stop_early else [])
412
+ try :
413
+ run_command (
414
+ cmd := (
415
+ [
416
+ "conda" ,
417
+ "run" ,
418
+ "-n" ,
419
+ env_name ,
420
+ "bioimageio" ,
421
+ "test" ,
422
+ str (source ),
423
+ f"--{ summary_path_arg_name } ={ summary_path .as_posix ()} " ,
424
+ f"--determinism={ determinism } " ,
425
+ ]
426
+ + ([f"--expected-type={ expected_type } " ] if expected_type else [])
427
+ + (["--stop-early" ] if stop_early else [])
428
+ )
424
429
)
425
- )
430
+ except Exception as e :
431
+ cmd_error = f"Failed to run command '{ ' ' .join (cmd )} ': { e } ."
432
+
426
433
if summary_path .exists ():
427
434
break
428
435
else :
436
+ if cmd_error is not None :
437
+ logger .warning (cmd_error )
438
+
429
439
return ValidationSummary (
430
440
name = "calling bioimageio test command" ,
431
441
source_name = str (source ),
@@ -448,7 +458,7 @@ def _test_in_env(
448
458
env = set (),
449
459
)
450
460
451
- return ValidationSummary .model_validate_json (summary_path . read_bytes () )
461
+ return ValidationSummary .load_json (summary_path )
452
462
453
463
454
464
@overload
0 commit comments