API Reference
Core Types
DynamicWorkflow.Job — Type
A job that can be scheduled and run. The uuid is used to identify the job and the result.
Fields
nameuuidcontexttaskoutputstatus
DynamicWorkflow.JobContext — Type
Help to build the dependency graph.
Fields
curr_idparent_idchild_ids
DynamicWorkflow.JobState — Type
One of the following states a job can be in: PENDING, RUNNING, COMPLETED, FAILED, CANCELLED.
DynamicWorkflow.OutputRef — Type
Placeholder for a job result that may not exist yet (like Future). The UUID is the same as the associated job.
Fields
uuidresult
DynamicWorkflow.WTask — Type
A wrapper for a function and its arguments to be run as a task.
Fields
fargstask
DynamicWorkflow.JobScheduler — Type
The central scheduler for jobs. Only one global instance of JobScheduler should exist and is created by start_scheduler.
Fields
jobspendingrunningcompletedgnode2idid2nodelockmainloop
DynamicWorkflow.SuccessResult — Type
struct SuccessResult <: DynamicWorkflow.AbstractResultDynamicWorkflow.FailResult — Type
struct FailResult <: DynamicWorkflow.AbstractResultDynamicWorkflow.Unassigned — Type
struct Unassigned <: DynamicWorkflow.AbstractResultMain Functions
DynamicWorkflow.@job — Macro
@job f(args...)Wrap a function call and create a job which will be submitted immediately to the global JobScheduler. Functions are plain Julia functions — no special first argument needed.
Parent-child relationships are tracked automatically via task-local storage when @job is called inside a running job.
Examples
my_add(x, y) = x + y
j1 = @job my_add(1, 2)
j2 = @job my_add(3, 2)
j3 = @job my_add(j1, j2) # j3 depends on j1 and j2DynamicWorkflow.start_scheduler — Function
start_scheduler()
Start scheduler mainloop task, i.e. JS[].mainloop.
DynamicWorkflow.stop_scheduler — Function
stop_scheduler(js, shutdown)
Stop the passed scheduler.
stop_scheduler()
Stop the main scheduler task, i.e. JS[].mainloop.
DynamicWorkflow.status — Function
status(job::Job)Return one of the JobState enum values.
DynamicWorkflow.result — Function
result(job::Job)Get the result of a job without blocking.
Returns
The job's result or Unassigned if not ready
Base.fetch — Function
fetch(job::Job)Get the result of a job, blocking until the job is completed.
DynamicWorkflow.allcomplete — Function
allcomplete()Check if all jobs in the scheduler are completed.
DynamicWorkflow.cancel! — Function
cancel!(job, js)
Try to cancel a job from running.
Returns
true if the job was successfully cancelled, false otherwise
DynamicWorkflow.istasksuccess — Function
istasksuccess(job)
Check if a job has completed successfully (done and not failed).
DynamicWorkflow.isalive — Function
isalive(js)
Check if the scheduler's main loop is still running.
DynamicWorkflow.current_context — Function
current_context() -> Union{Nothing, JobContext}Return the JobContext of the currently executing job, or nothing if called outside a job. Uses Julia task_local_storage for implicit context propagation.
DynamicWorkflow.run! — Function
Non-blocking call to scheudle a Job to run with available threads.
DynamicWorkflow.head — Function
head(uuid::UUID) -> StringExtract the first part of a UUID string (before the first hyphen).
DynamicWorkflow.task_args — Function
task_args(j)
Extract task arguments from a job.
DynamicWorkflow.context — Function
context(j)
Extract the JobContext from a job.
Visualization
DynamicWorkflow.draw_graph — Function
draw_graph(js; layout)
Draw workflow graph. Default layout is hierarchical, can take layouts defined in NetworkLayout.jl.
DynamicWorkflow.hierarchical_layout — Function
Compute top-down hierarchical positions for a DAG similar to DOT. Each node's layer equals its longest path from any source. Nodes within the same layer are evenly spaced on the x-axis. Returns a Vector{Point2f} suitable for graphplot(layout=...).
DynamicWorkflow.status_color — Function
Return the Okabe-Ito background hex color for a job status.
DynamicWorkflow.status_text_color — Function
Return the text hex color (or "white") for a job status.
DynamicWorkflow.node_label — Function
Two-line node label: function name on line 1, last 5 chars of UUID on line 2.
DynamicWorkflow.node_width — Function
Rectangle width sized to the longest line in the label.
Internals
DynamicWorkflow._make_context — Function
Build a JobContext for a new job, linking it to the parent context if one exists.