Skip to content

Commit

Permalink
Merge branch 'main' into compathelper/new_version/2023-06-09-00-23-14…
Browse files Browse the repository at this point in the history
…-841-03581724947
  • Loading branch information
singularitti authored Jun 9, 2023
2 parents 7aa6909 + 4e169a2 commit 0d314b2
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 33 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Thinkers = "6d80a3f9-a943-41fa-97b3-3004c0daf7a3"
EasyJobsBase = "0.7"
Graphs = "1"
MetaGraphs = "0.7"
Thinkers = "0.2"
julia = "1"

[extras]
Expand Down
10 changes: 5 additions & 5 deletions docs/src/portability.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ wf = Workflow(k)
```

To save the `Workflow` instance to disk while running in case it failed or is interrupted,
use the `AutosaveWorkflow` type.
use the `serialize` function.

```@repl wf
using SimpleWorkflows: AutosaveWorkflow
wf = AutosaveWorkflow("saved.jls", k)
run!(wf; δt = 0, n = 1)
using Serialization: serialize
wf = serialize("wf.jls", wf)
run!(wf)
```

After the above steps are finished, a `saved.jls` file is saved to your local file system.
Expand All @@ -66,7 +66,7 @@ julia> using SimpleWorkflows
julia> using Serialization: deserialize
julia> deserialize("saved.jls")
julia> deserialize("wf.jls")
```

And voilà!
1 change: 0 additions & 1 deletion docs/src/public.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CurrentModule = SimpleWorkflows

```@docs
Workflow
AutosaveWorkflow
run!
execute!
getstatus
Expand Down
18 changes: 1 addition & 17 deletions src/SimpleWorkflows.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using Graphs:
DiGraph, add_edge!, nv, is_cyclic, is_connected, has_edge, topological_sort_by_dfs
using Serialization: serialize

export Workflow, AutosaveWorkflow
export Workflow

abstract type AbstractWorkflow end

Expand Down Expand Up @@ -77,27 +77,11 @@ function Workflow(jobs::AbstractJob...)
return Workflow(foundjobs, graph)
end

"""
AutosaveWorkflow(path, jobs::AbstractJob...)
Create a `AutosaveWorkflow` from a given series of `Job`s and a `path`.
When running, the status of the workflow will be automatically saved to `path`.
"""
struct AutosaveWorkflow{T} <: AbstractWorkflow
path::T
wf::Workflow
end
AutosaveWorkflow(path, jobs::AbstractJob...) = AutosaveWorkflow(path, Workflow(jobs...))

getjobs(wf::Workflow) = wf.jobs
getjobs(wf::AutosaveWorkflow) = getjobs(wf.wf)

getgraph(wf::Workflow) = wf.graph
getgraph(wf::AutosaveWorkflow) = getgraph(wf.wf)

save(::Workflow) = nothing
save(wf::AutosaveWorkflow) = serialize(wf.path, wf.wf)

include("eachjob.jl")
include("operations.jl")
Expand Down
8 changes: 0 additions & 8 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,3 @@ function Base.show(io::IO, wf::Workflow)
end
end
end
function Base.show(io::IO, wf::AutosaveWorkflow)
if get(io, :compact, false) || get(io, :typeinfo, nothing) == typeof(wf)
Base.show_default(IOContext(io, :limit => true), wf) # From https://github.com/mauro3/Parameters.jl/blob/ecbf8df/src/Parameters.jl#L556
else
print(io, "Autosave", wf.wf)
println(io, " path: ", wf.path)
end
end
2 changes: 0 additions & 2 deletions src/status.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ function getstatus(wf::Workflow)
end
return graph
end
getstatus(wf::AutosaveWorkflow) = getstatus(wf.wf)

"""
liststatus(wf::AbstractWorkflow)
Expand Down Expand Up @@ -62,6 +61,5 @@ for (func, adj) in zip(
Filter only the $($adj) jobs in a `Workflow`.
"""
$func(wf::Workflow) = $func(wf.jobs)
$func(wf::AutosaveWorkflow) = $func(wf.wf)
end
end

0 comments on commit 0d314b2

Please sign in to comment.