@@ -379,40 +379,82 @@ for idx in 1:5
379379 end
380380 end
381381
382- @testset " DropBuffer ($scope_str )" begin
383- # TODO : Test that accumulator never gets called
384- @test ! test_finishes (" x (drop)-> A" ; ignore_timeout= true ) do
385- local x, A
386- Dagger. spawn_streaming () do
387- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
388- x = Dagger. @spawn scope= rand (scopes) rand ()
389- end
390- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
391- end
392- @test fetch (x) === nothing
393- @test_throws_unwrap InterruptException fetch (A) === nothing
394- end
395- @test ! test_finishes (" x ->(drop) A" ; ignore_timeout= true ) do
396- local x, A
397- Dagger. spawn_streaming () do
398- x = Dagger. @spawn scope= rand (scopes) rand ()
399- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
400- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
401- end
382+ # @testset "DropBuffer ($scope_str)" begin
383+ # # TODO : Test that accumulator never gets called
384+ # @test !test_finishes("x (drop)-> A"; ignore_timeout=false, max_evals=typemax(Int)) do
385+ # # ENV["JULIA_DEBUG"] = "Dagger"
386+
387+ # local x, A
388+ # Dagger.spawn_streaming() do
389+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
390+ # x = Dagger.@spawn scope=rand(scopes) rand()
391+ # end
392+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
393+ # end
394+ # @test fetch(x) === nothing
395+ # fetch(A)
396+ # @test_throws_unwrap InterruptException fetch(A)
397+ # end
398+
399+ # @test !test_finishes("x ->(drop) A"; ignore_timeout=true) do
400+ # local x, A
401+ # Dagger.spawn_streaming() do
402+ # x = Dagger.@spawn scope=rand(scopes) rand()
403+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
404+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
405+ # end
406+ # end
407+ # @test fetch(x) === nothing
408+ # @test_throws_unwrap InterruptException fetch(A) === nothing
409+ # end
410+
411+ # @test !test_finishes("x -(drop)> A"; ignore_timeout=true) do
412+ # local x, A
413+ # Dagger.spawn_streaming() do
414+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
415+ # x = Dagger.@spawn scope=rand(scopes) rand()
416+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
417+ # end
418+ # end
419+ # @test fetch(x) === nothing
420+ # @test_throws_unwrap InterruptException fetch(A) === nothing
421+ # end
422+ # end
423+
424+ @testset " Graceful finishing" begin
425+ @test test_finishes (" finish_stream() with one downstream task" ) do
426+ B = Dagger. spawn_streaming () do
427+ A = Dagger. @spawn scope= rand (scopes) Dagger. finish_stream (42 )
428+
429+ Dagger. @spawn scope= rand (scopes) accumulator (A)
402430 end
403- @test fetch (x) === nothing
404- @test_throws_unwrap InterruptException fetch (A) === nothing
431+
432+ fetch (B)
433+ values = copy (ACCUMULATOR); empty! (ACCUMULATOR)
434+ @test values[Dagger. task_id (B)] == [42 ]
405435 end
406- @test ! test_finishes (" x -(drop)> A" ; ignore_timeout= true ) do
407- local x, A
408- Dagger. spawn_streaming () do
409- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
410- x = Dagger. @spawn scope= rand (scopes) rand ()
411- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
412- end
436+
437+ @test test_finishes (" finish_stream() with multiple downstream tasks" ; max_evals= 2 ) do
438+ D, E = Dagger. spawn_streaming () do
439+ A = Dagger. @spawn scope= rand (scopes) Dagger. finish_stream (1 )
440+ B = Dagger. @spawn scope= rand (scopes) A + 1
441+ C = Dagger. @spawn scope= rand (scopes) A + 1
442+ D = Dagger. @spawn scope= rand (scopes) accumulator (B, C)
443+
444+ E = Dagger. @spawn scope= rand (scopes) accumulator ()
445+
446+ D, E
413447 end
414- @test fetch (x) === nothing
415- @test_throws_unwrap InterruptException fetch (A) === nothing
448+
449+ fetch (D)
450+ fetch (E)
451+ values = copy (ACCUMULATOR); empty! (ACCUMULATOR)
452+
453+ # D should only execute once since it depends on A/B/C
454+ @test values[Dagger. task_id (D)] == [4 ]
455+
456+ # E should run max_evals times since it has no dependencies
457+ @test length (values[Dagger. task_id (E)]) == 2
416458 end
417459 end
418460
0 commit comments