@@ -370,40 +370,82 @@ for idx in 1:5
370370 end
371371 end
372372
373- @testset " DropBuffer ($scope_str )" begin
374- # TODO : Test that accumulator never gets called
375- @test ! test_finishes (" x (drop)-> A" ; ignore_timeout= true ) do
376- local x, A
377- Dagger. spawn_streaming () do
378- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
379- x = Dagger. @spawn scope= rand (scopes) rand ()
380- end
381- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
382- end
383- @test fetch (x) === nothing
384- @test_throws_unwrap InterruptException fetch (A) === nothing
385- end
386- @test ! test_finishes (" x ->(drop) A" ; ignore_timeout= true ) do
387- local x, A
388- Dagger. spawn_streaming () do
389- x = Dagger. @spawn scope= rand (scopes) rand ()
390- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
391- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
392- end
373+ # @testset "DropBuffer ($scope_str)" begin
374+ # # TODO : Test that accumulator never gets called
375+ # @test !test_finishes("x (drop)-> A"; ignore_timeout=false, max_evals=typemax(Int)) do
376+ # # ENV["JULIA_DEBUG"] = "Dagger"
377+
378+ # local x, A
379+ # Dagger.spawn_streaming() do
380+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
381+ # x = Dagger.@spawn scope=rand(scopes) rand()
382+ # end
383+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
384+ # end
385+ # @test fetch(x) === nothing
386+ # fetch(A)
387+ # @test_throws_unwrap InterruptException fetch(A)
388+ # end
389+
390+ # @test !test_finishes("x ->(drop) A"; ignore_timeout=true) do
391+ # local x, A
392+ # Dagger.spawn_streaming() do
393+ # x = Dagger.@spawn scope=rand(scopes) rand()
394+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
395+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
396+ # end
397+ # end
398+ # @test fetch(x) === nothing
399+ # @test_throws_unwrap InterruptException fetch(A) === nothing
400+ # end
401+
402+ # @test !test_finishes("x -(drop)> A"; ignore_timeout=true) do
403+ # local x, A
404+ # Dagger.spawn_streaming() do
405+ # Dagger.with_options(;stream_buffer_type=Dagger.DropBuffer) do
406+ # x = Dagger.@spawn scope=rand(scopes) rand()
407+ # A = Dagger.@spawn scope=rand(scopes) accumulator(x)
408+ # end
409+ # end
410+ # @test fetch(x) === nothing
411+ # @test_throws_unwrap InterruptException fetch(A) === nothing
412+ # end
413+ # end
414+
415+ @testset " Graceful finishing" begin
416+ @test test_finishes (" finish_stream() with one downstream task" ) do
417+ B = Dagger. spawn_streaming () do
418+ A = Dagger. @spawn scope= rand (scopes) Dagger. finish_stream (42 )
419+
420+ Dagger. @spawn scope= rand (scopes) accumulator (A)
393421 end
394- @test fetch (x) === nothing
395- @test_throws_unwrap InterruptException fetch (A) === nothing
422+
423+ fetch (B)
424+ values = copy (ACCUMULATOR); empty! (ACCUMULATOR)
425+ @test values[Dagger. task_id (B)] == [42 ]
396426 end
397- @test ! test_finishes (" x -(drop)> A" ; ignore_timeout= true ) do
398- local x, A
399- Dagger. spawn_streaming () do
400- Dagger. with_options (;stream_buffer_type= Dagger. DropBuffer) do
401- x = Dagger. @spawn scope= rand (scopes) rand ()
402- A = Dagger. @spawn scope= rand (scopes) accumulator (x)
403- end
427+
428+ @test test_finishes (" finish_stream() with multiple downstream tasks" ; max_evals= 2 ) do
429+ D, E = Dagger. spawn_streaming () do
430+ A = Dagger. @spawn scope= rand (scopes) Dagger. finish_stream (1 )
431+ B = Dagger. @spawn scope= rand (scopes) A + 1
432+ C = Dagger. @spawn scope= rand (scopes) A + 1
433+ D = Dagger. @spawn scope= rand (scopes) accumulator (B, C)
434+
435+ E = Dagger. @spawn scope= rand (scopes) accumulator ()
436+
437+ D, E
404438 end
405- @test fetch (x) === nothing
406- @test_throws_unwrap InterruptException fetch (A) === nothing
439+
440+ fetch (D)
441+ fetch (E)
442+ values = copy (ACCUMULATOR); empty! (ACCUMULATOR)
443+
444+ # D should only execute once since it depends on A/B/C
445+ @test values[Dagger. task_id (D)] == [4 ]
446+
447+ # E should run max_evals times since it has no dependencies
448+ @test length (values[Dagger. task_id (E)]) == 2
407449 end
408450 end
409451
0 commit comments