after some iteration i found the following works

function run_slurm_helper(ex,num_workers)
 println(ex)
    addprocs(SlurmManager(num_workers), partition="quick", t="00:01:00")

    output = []
    for i in workers()
        out = fetch(@spawnat i eval(ex))
        push!(output, out)
    end

    for i in workers()
        rmprocs(i)
    end

    return output
end


run_slurm(f::Function;num_workers = 5) = run_slurm_helper(code_lowered(f
,())[1].args[3],num_workers)

run_slurm() do
 return (gethostname(), getpid())
end

but there might be a cleaner way.

On Thursday, March 17, 2016 at 11:04:40 AM UTC-5, Jonathan Anderson wrote:
>
> After reading the following post ( 
> https://groups.google.com/forum/#!searchin/julia-users/addprocs$20output$20SlurmManager/julia-users/VNjshcRJYR8/uJz0FkkQAAAJ
>  
> ) I decided to try the following
>
> function run_slurm(f::Function;num_workers = 5)
>
>     addprocs(SlurmManager(num_workers), partition="quick", t="00:01:00")
>
>     @everywhere f
>
>     output = []
>     for i in workers()
>         out = fetch(@spawnat i f())
>         push!(output, out)
>     end
>
>     for i in workers()
>         rmprocs(i)
>     end
>
>     return output
> end
>
> run_slurm() do
>  return (gethostname(), getpid())
> end
>
> but it looks like i get the following error:
>
> UndefVarError: f not defined
>
> I've been looking into trying to get the definition and redefining it 
> using something like the following, but i'm lost as to how i could use this
>
> julia> lambda_info = eval(code_lowered(f,())[1])
> AST(:($(Expr(:lambda, Any[symbol("#self#")], Any[Any[Any[symbol("#self#"
> ),:Any,0]],Any[],0], :(begin  # none, line 1:
>         return (top(tuple))((Main.gethostname)(),(Main.getpid)())
>     end)))))
>
> From (
> https://stackoverflow.com/questions/14124456/access-the-ast-for-generic-functions-in-julia)
>  
> I've tried the following with no luck.
>
> julia> ccall(:jl_uncompress_ast, Any, (Any, Any), lambda_info, lambda_info
> .ast)
> 35
>
>

Reply via email to