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

Add flexible worker management, pools and onworkers #11

Closed
wants to merge 64 commits into from
Closed

Conversation

oschulz
Copy link
Owner

@oschulz oschulz commented Apr 25, 2024

Follow-up of #10

@oschulz
Copy link
Owner Author

oschulz commented Apr 25, 2024

@theHenks, you can give this a try now, I think.

@oschulz
Copy link
Owner Author

oschulz commented Apr 25, 2024

Example:

using ParallelProcessingTools

@always_everywhere begin
    using Distributed
    function mytask(runtime::Real = 2, args...)
        sleep(runtime)
        #@info "Hello from worker $(myid()), have to do $args."
        return args
    end
end

addworkers(SlurmRun(slurm_flags = `--ntasks=92 --cpus-per-task=2 --mem-per-cpu=8G`))

processing_task = @async begin
    @sync begin
        # Let's assume directories can be processed in parallel:
        for diridx in 1:20
            @async begin
                @info "Processing dir $diridx."
                # Let's assume files can be processed in parallel:
                @sync for fileidx in 1:30
                    @async begin
                        @info "Processing run $diridx, file $fileidx."
                        # Steps that have to be done sequentially:
                        for stepidx in 1:4
                            @info "Processing run $diridx, file $fileidx, step $stepidx."
                            result = on_free_worker(mytask, 2, fileidx, stepidx, label = "someaction-$diridx-$fileidx-$stepidx", tries = 2)
                            @assert result == (fileidx, stepidx)
                        end
                        @info "Done with run $diridx, file $fileidx."
                    end
                end
                @info "Done with dir $diridx."
            end
        end
    end
    @info "Processing sucessful."
end

Copy link

codecov bot commented Apr 25, 2024

Codecov Report

Attention: Patch coverage is 71.29300% with 242 lines in your changes are missing coverage. Please review.

Project coverage is 69.84%. Comparing base (eb1cd88) to head (4805bb6).

Files Patch % Lines
src/workerpool.jl 70.80% 47 Missing ⚠️
src/custom_cluster_managers.jl 55.68% 39 Missing ⚠️
src/runworkers.jl 63.44% 34 Missing ⚠️
src/display.jl 0.00% 28 Missing ⚠️
src/onworkers.jl 71.42% 28 Missing ⚠️
src/procinit.jl 82.17% 23 Missing ⚠️
src/slurm.jl 0.00% 17 Missing ⚠️
ext/ParallelProcessingToolsThreadPinningExt.jl 0.00% 12 Missing ⚠️
src/exceptions.jl 69.23% 4 Missing ⚠️
src/states.jl 92.15% 4 Missing ⚠️
... and 2 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #11       +/-   ##
===========================================
+ Coverage   48.31%   69.84%   +21.53%     
===========================================
  Files          11       19        +8     
  Lines         563     1227      +664     
===========================================
+ Hits          272      857      +585     
- Misses        291      370       +79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oschulz oschulz force-pushed the onworkers branch 2 times, most recently from 8594307 to 8673363 Compare April 27, 2024 17:15
@oschulz oschulz changed the title Add on_free_worker (Julia >= v1.9 only) Add flexible worker management, pools and onworkers May 9, 2024
@oschulz
Copy link
Owner Author

oschulz commented May 10, 2024

Closed in favor of #13 .

@oschulz oschulz closed this May 10, 2024
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 this pull request may close these issues.

1 participant