@@ -372,16 +372,38 @@ def _test_in_env(
372
372
raise RuntimeError ("Conda not available" ) from e
373
373
374
374
working_dir .mkdir (parents = True , exist_ok = True )
375
+ summary_path = working_dir / "summary.json"
375
376
try :
376
377
run_command (["conda" , "activate" , env_name ])
377
378
except Exception :
378
379
path = working_dir / "env.yaml"
379
- _ = path .write_bytes (encoded_env )
380
- logger .debug ("written conda env to {}" , path )
381
- run_command (["conda" , "env" , "create" , f"--file={ path } " , f"--name={ env_name } " ])
382
- run_command (["conda" , "activate" , env_name ])
380
+ try :
381
+ _ = path .write_bytes (encoded_env )
382
+ logger .debug ("written conda env to {}" , path )
383
+ run_command (
384
+ ["conda" , "env" , "create" , f"--file={ path } " , f"--name={ env_name } " ]
385
+ )
386
+ run_command (["conda" , "activate" , env_name ])
387
+ except Exception as e :
388
+ summary = descr .validation_summary
389
+ summary .add_detail (
390
+ ValidationDetail (
391
+ name = "Conda environment creation" ,
392
+ status = "failed" ,
393
+ loc = ("weights" , weight_format ),
394
+ recommended_env = conda_env ,
395
+ errors = [
396
+ ErrorEntry (
397
+ loc = ("weights" , weight_format ),
398
+ msg = str (e ),
399
+ type = "conda" ,
400
+ with_traceback = True ,
401
+ )
402
+ ],
403
+ )
404
+ )
405
+ return summary
383
406
384
- summary_path = working_dir / "summary.json"
385
407
run_command (
386
408
[
387
409
"conda" ,
0 commit comments