Skip to content

Commit

Permalink
Merge pull request #37 from MineralsCloud:shouldrun
Browse files Browse the repository at this point in the history
Change `prepare!` & `shouldrun` for `AbstractJob` instead of `Executor`s
  • Loading branch information
singularitti authored Jun 16, 2023
2 parents 68e543d + a95d8ba commit c1abd19
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions EasyJobsBase/src/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,21 @@ function _run!(job::AbstractJob) # Do not export!
return job
end

prepare!(::Executor) = nothing # No op
function prepare!(exec::Executor{ArgDependentJob})
prepare!(::AbstractJob) = nothing # No op
function prepare!(job::ArgDependentJob)
# Use previous results as arguments
args = if countparents(exec.job) == 1
something(getresult(only(eachparent(exec.job))))
args = if countparents(job) == 1
something(getresult(only(eachparent(job))))
else # > 1
Set(something(getresult(parent)) for parent in eachparent(exec.job))
Set(something(getresult(parent)) for parent in eachparent(job))
end
setargs!(exec.job.core, args)
setargs!(job.core, args)
return nothing
end

shouldrun(::Executor) = true
shouldrun(exec::Executor{ConditionalJob}) =
countparents(exec.job) >= 1 && all(issucceeded(parent) for parent in exec.job.parents)
shouldrun(::AbstractJob) = true
shouldrun(job::ConditionalJob) =
countparents(job) >= 1 && all(issucceeded(parent) for parent in eachparent(job))

"""
kill!(exec::Executor)
Expand Down

0 comments on commit c1abd19

Please sign in to comment.