@@ -337,13 +337,36 @@ def _promote_one(*, to: str, from_splits: set[str]) -> None:
337337 else :
338338 t .split = "train"
339339
340+ import logging
341+
340342 # Guarantee val (the gate) is non-empty when we have >=2 real tasks.
341- # Only promote from train so hash-assigned test tasks stay untouched.
343+ # Only promote from train so hash-assigned test tasks stay untouched,
344+ # UNLESS train is also empty, in which case we must borrow from test.
342345 if len (real ) >= 2 and not any (t .split == "val" for t in real ):
343- _promote_one (to = "val" , from_splits = {"train" })
344- # Guarantee a train pool exists when possible; never borrow from test.
346+ if not any (t .split == "train" for t in real ):
347+ logging .getLogger ("skillopt_sleep" ).warning (
348+ f"assign_splits: all { len (real )} real tasks hashed into test "
349+ f"(val_fraction={ val_fraction } , test_fraction={ test_fraction } , seed={ seed } ). "
350+ "Borrowing from test to satisfy non-empty val."
351+ )
352+ _promote_one (to = "val" , from_splits = {"test" })
353+ else :
354+ _promote_one (to = "val" , from_splits = {"train" })
355+
356+ # Guarantee a train pool exists when possible; never borrow from test
357+ # UNLESS val has only 1 task (so taking from val would re-empty the gate)
358+ # and test tasks are available.
345359 if not any (t .split == "train" for t in tasks ) and len (real ) >= 2 :
346- _promote_one (to = "train" , from_splits = {"val" })
360+ val_count = sum (1 for t in real if t .split == "val" )
361+ if val_count <= 1 and any (t .split == "test" for t in real ):
362+ logging .getLogger ("skillopt_sleep" ).warning (
363+ f"assign_splits: pulling from test to satisfy non-empty train "
364+ f"because val has only { val_count } real task "
365+ f"(val_fraction={ val_fraction } , test_fraction={ test_fraction } , seed={ seed } )."
366+ )
367+ _promote_one (to = "train" , from_splits = {"test" })
368+ else :
369+ _promote_one (to = "train" , from_splits = {"val" })
347370 return tasks
348371
349372
0 commit comments