@@ -222,8 +222,9 @@ def test_description(
222222 environment YAML file based on the model weights description.
223223 - A `BioimageioCondaEnv` or a path to a conda environment YAML file.
224224 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"`.
227228 """
228229 if runtime_env == "currently-active" :
229230 rd = load_description_and_test (
@@ -371,8 +372,6 @@ def _test_in_env(
371372 except Exception as e :
372373 raise RuntimeError ("Conda not available" ) from e
373374
374- working_dir .mkdir (parents = True , exist_ok = True )
375- summary_path = working_dir / "summary.json"
376375 try :
377376 run_command (["conda" , "activate" , env_name ])
378377 except Exception :
@@ -404,28 +403,39 @@ def _test_in_env(
404403 )
405404 return summary
406405
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"
407409 cmd = []
410+ cmd_error = None
408411 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+ )
424429 )
425- )
430+ except Exception as e :
431+ cmd_error = f"Failed to run command '{ ' ' .join (cmd )} ': { e } ."
432+
426433 if summary_path .exists ():
427434 break
428435 else :
436+ if cmd_error is not None :
437+ logger .warning (cmd_error )
438+
429439 return ValidationSummary (
430440 name = "calling bioimageio test command" ,
431441 source_name = str (source ),
@@ -448,7 +458,7 @@ def _test_in_env(
448458 env = set (),
449459 )
450460
451- return ValidationSummary .model_validate_json (summary_path . read_bytes () )
461+ return ValidationSummary .load_json (summary_path )
452462
453463
454464@overload
0 commit comments