diff --git a/Project.toml b/Project.toml index 02e117c..71e2133 100644 --- a/Project.toml +++ b/Project.toml @@ -6,6 +6,8 @@ version = "0.1.0" [deps] EasyJobsBase = "db8ca866-b61f-4bd1-a9b9-75c107d645d4" GraphRecipes = "bd48cda9-67a9-57be-86fa-5b3c104eda73" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" +LayeredLayouts = "f4a74d36-062a-4d48-97cd-1356bad1de4e" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" SimpleWorkflows = "6a97d125-85da-4b66-b300-4bba10360563" diff --git a/src/SimpleWorkflowRecipes.jl b/src/SimpleWorkflowRecipes.jl index 0f28ffd..2a263e4 100644 --- a/src/SimpleWorkflowRecipes.jl +++ b/src/SimpleWorkflowRecipes.jl @@ -1,9 +1,11 @@ module SimpleWorkflowRecipes using EasyJobsBase: JobStatus, PENDING, RUNNING, SUCCEEDED, FAILED, getstatus +using Graphs: edges using GraphRecipes: GraphPlot, get_source_destiny_weight, get_adjacency_list -using RecipesBase: @userplot, @recipe -using SimpleWorkflows: eachjob, findjob +using LayeredLayouts: Zarate, solve_positions +using RecipesBase: @userplot, @recipe, @series +using SimpleWorkflows: Workflow, indexin function getcolor(status::JobStatus) if status == PENDING @@ -20,17 +22,53 @@ function getcolor(status::JobStatus) end @userplot WorkflowPlot -@recipe function f(plot::WorkflowPlot) - workflow = plot.args[end] - root := :bottom - curves --> false - nodeshape --> :ellipse - nodesize --> 0.2 - nodecolor --> map(getcolor ∘ getstatus, eachjob(workflow)) - names --> map(Base.Fix2(findjob, workflow), eachjob(workflow)) - fontsize --> 9 - method --> :spring - return GraphPlot(get_source_destiny_weight(get_adjacency_list(workflow.graph))) +@recipe function f( + plot::WorkflowPlot; + edgewidth=1, + edgestrokecolor=:black, + nodeshape=:circle, + nodesize=5, + root=:left, +) + if root == :right + # FIXME + elseif root == :bottom + permute --> (:x, :y) + elseif root == :top + # FIXME + elseif root == :left + # do nothing + else + throw(ArgumentError("unknown root `$root`!")) + end + workflow = only(plot.args) + framestyle --> :none + grid --> false + legend --> false + label --> "" + guide --> "" + nodes_x, nodes_y, paths = solve_positions(Zarate(), workflow.graph) + for edge in edges(workflow.graph) + edge_x, edge_y = paths[edge] + @series begin + seriestype --> :path + arrow --> true + linewidth --> edgewidth + linecolor --> edgestrokecolor + edge_x, edge_y + end + end + for (job, (x, y)) in zip(workflow, zip(nodes_x, nodes_y)) + @series begin + seriestype --> :scatter + markershape --> nodeshape + markersize --> nodesize + markerstrokewidth --> 0 + seriescolor --> getcolor(getstatus(job)) + series_annotations --> string(only(indexin(job, workflow))) + Base.vect(x), Base.vect(y) + end + end end end