Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error for distributed loop #218

Closed
kafisatz opened this issue Sep 13, 2021 · 1 comment · Fixed by #302
Closed

Syntax error for distributed loop #218

kafisatz opened this issue Sep 13, 2021 · 1 comment · Fixed by #302

Comments

@kafisatz
Copy link

kafisatz commented Sep 13, 2021

It is not clear to me why the following produces a syntax error.
Without ProgressMeter.@showprogress things work fine (see second line in the function me)

using Distributed 
using ProgressMeter 

function simulateSensitivity(sett,sensmatinput,i,get_metrics,tmpoutputfldr)
    return nothing 
end

function me(sensmatinput,tmpoutputfldr,get_metrics,sett,i)
    keymetrics = ProgressMeter.@showprogress 2 "Running sensitivities..." Distributed.@distributed (vcat) for i in 1:size(sensmatinput,1) #does not work
    #keymetrics =                                                         Distributed.@distributed (vcat) for i in 1:size(sensmatinput,1) #works
    #do some work
         sett = deepcopy(mainsett)
         tmpoutputfldr = mkdir(joinpath(outputfld,string(i)))
         #.......
         keym = simulateSensitivity(sett,sensmatinput,i,get_metrics,tmpoutputfldr)
    end

    return nothing 
end

ERROR: LoadError: ArgumentError: Final argument to @showprogress must be a for loop, comprehension, map, reduce, or pmap; got #= REPL[14]:2 =# Distributed.@distributed vcat for i = 1:size(sensmatinput, 1)
        #= REPL[14]:5 =#
        sett = deepcopy(mainsett)
        #= REPL[14]:7 =#
        for nm = sensmatnames
            #= REPL[14]:8 =#
            sclr = nmdict[nm]
            #= REPL[14]:9 =#
            sett.parametersDf[:, sclr] .= sensmatinput[i, nm]
        end
        #= REPL[14]:12 =#
        tmpoutputfldr = mkdir(joinpath(outputfld, string(i)))
        #= REPL[14]:14 =#
        keym = simulateSensitivity(sett, sensmatinput, i, get_metrics, tmpoutputfldr)
    end
Stacktrace:
 [1] showprogress(::Int64, ::Vararg{Any, N} where N)
   @ ProgressMeter C:\Users\bernhard.konig\.julia\packages\ProgressMeter\l7LEt\src\ProgressMeter.jl:862
 [2] var"@showprogress"(__source__::LineNumberNode, __module__::Module, args::Vararg{Any, N} where N)
   @ ProgressMeter C:\Users\bernhard.konig\.julia\packages\ProgressMeter\l7LEt\src\ProgressMeter.jl:817
in expression starting at REPL[14]:2


@MarcMush
Copy link
Collaborator

@showprogress recognizes @distributed but not Distributed.@distributed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants