Jobs
The section of the package is responsible for handle the jobs.
Index
ModelSelectionGUI.current_job
ModelSelectionGUI.finished_queue
ModelSelectionGUI.finished_task_condition
ModelSelectionGUI.interrupted_task
ModelSelectionGUI.jobs_files
ModelSelectionGUI.pending_queue
ModelSelectionGUI.pending_queue_condition
ModelSelectionGUI.add_job_file
ModelSelectionGUI.add_pending_job
ModelSelectionGUI.clear_all_jobs
ModelSelectionGUI.clear_current_job
ModelSelectionGUI.clear_finished_queue
ModelSelectionGUI.clear_pending_queue
ModelSelectionGUI.consume_pending_job
ModelSelectionGUI.consume_pending_jobs
ModelSelectionGUI.get_current_job
ModelSelectionGUI.get_finished_job
ModelSelectionGUI.get_job
ModelSelectionGUI.get_job
ModelSelectionGUI.get_job_file
ModelSelectionGUI.get_pending_job
ModelSelectionGUI.get_pending_queue_length
ModelSelectionGUI.job_notify
ModelSelectionGUI.run_job
ModelSelectionGUI.set_current_job
ModelSelectionGUI.start_task
ModelSelectionGUI.stop_task
Contents
ModelSelectionGUI.pending_queue
— Constantpending_queue::Vector{ModelSelectionJob}()
A vector to store pending model selection jobs.
ModelSelectionGUI.finished_queue
— Constantfinished_queue::Vector{ModelSelectionJob}()
A vector to store finished model selection jobs.
ModelSelectionGUI.jobs_files
— Constantjobs_files::Dict{String, Dict{Symbol, String}}()
A dictionary that maps job hashes to their corresponding file information.
ModelSelectionGUI.pending_queue_condition
— Constantpending_queue_condition::Condition()
A condition variable to signal changes in the pending job queue.
ModelSelectionGUI.finished_task_condition
— Constantfinished_task_condition::Condition()
A condition variable to signal changes in the finished job queue.
ModelSelectionGUI.current_job
— Constantcurrent_job::Union{ModelSelectionJob, Nothing}
A variable to store the current job being processed, or nothing
if no job is active.
ModelSelectionGUI.interrupted_task
— Constantinterrupted_task::Bool
A boolean flag indicating whether a task has been interrupted.
ModelSelectionGUI.add_pending_job
— Methodadd_pending_job(job::ModelSelectionJob)
Adds the given job to the pending queue. After adding the job, the function notifies condition
variable.
Parameters
job::ModelSelectionJob
: The job to be added to the pending queue.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.pending_queue_condition::Condition
: The condition variable for signaling changes in the pending job queue.
Returns
ModelSelectionJob
: TheModelSelectionJob
object.
Example
job = ModelSelectionJob(...)
add_pending_job(job)
ModelSelectionGUI.get_job_file
— Methodget_job_file(filehash::String)
Returns the tempfile and filename associated with the specified filehash
.
Parameters
filehash::String
: The file hash.
Globals
job_files::Dict{String, Dict{Symbol, String}}
: The dictionary that maps job hashes to their corresponding file information.
Returns
- Dict{Symbol, String}: A Dict with the tempfile and filename.
Example
get_job_file("441c3a47-c302-43b6-8a2d-fe145baa29eb")
ModelSelectionGUI.consume_pending_jobs
— Methodconsume_pending_jobs()
Consumes continuously pending jobs from the pending_queue
and processes them until interrupted.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.pending_queue_condition::Condition
: The condition variable for signaling changes in the pending job queue.finished_task_condition::Condition
: The condition variable for signaling changes in the finished job queue.interrupted_task::Bool
: A boolean flag indicating whether a task has been interrupted.
Example
consume_pending_jobs()
ModelSelectionGUI.consume_pending_job
— Methodconsume_pending_job()
Consume a pending job form the pending_queue
and executes it.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.current_job::ModelSelectionJob
: The current job being processed.
Example
consume_pending_job()
ModelSelectionGUI.run_job
— Methodrun_job(job::ModelSelectionJob)
Runs the specified ModelSelectionJob
, reads the necessary data from the job's tempfile, and performs model selection. In case of any exception, sets the job status to FAILED and saves the error message.
Parameters
job::ModelSelectionJob
: TheModelSelectionJob
instance to run.
Globals
finished_queue::Vector{ModelSelectionJob}
: The queue storing finished jobs.current_job::ModelSelectionJob
: The current job being processed.
Example
job = ModelSelectionJob(...) # job is an instance of ModelSelectionJob
run_job(job)
ModelSelectionGUI.get_pending_queue_length
— Methodget_pending_queue_length()
Returns the number of pending jobs.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.
Returns
Int64
: The number of pending jobs jobs.
Example
get_pending_queue_length()
ModelSelectionGUI.add_job_file
— Methodadd_job_file(filehash::String, tempfile::String, filename::String)
Stores a mapping from filehash
to the specified tempfile
and filename
.
Parameters
filehash::String
: The file hash.tempfile::String
: The temporary file path.filename::String
: The original file name.
Globals
job_files::Dict{String, Dict{Symbol, String}}
: The dictionary that maps job hashes to their corresponding file information.
Example
add_job_file("441c3a47-c302-43b6-8a2d-fe145baa29eb", "/tmp/data.csv", "data.csv")
ModelSelectionGUI.job_notify
— Functionjob_notify(message::String, data::Union{Dict{Any,Any},Nothing} = nothing)
Notifies all subscribers on the default WebSocket channel with the specified message
and data
.
Parameters
message::String
: The message to send.data::Union{Dict{Any,Any},Nothing}
: The data to send.
Example
job_notify("message", Dict("data" => "data"))
ModelSelectionGUI.get_job
— Methodget_job(queue::Vector{ModelSelectionJob}, id::String)
Searches for a job with the specified id
in the provided queue
and returns it. Returns nothing
if the job is not found.
Parameters
queue::Vector{ModelSelectionJob}
: The queue to search.id::String
: The job id.
Returns
ModelSelectionJob
: The job with the specifiedid
.Nothing
: If the job is not found.
Example
get_job(queue, "7182939d-c5a1-4e21-a06e-182195c961fa")
ModelSelectionGUI.get_job
— Methodget_job(id::String)
Returns the job with the specified id
from the pending jobs, the current job, or the finished jobs. Returns nothing
if the job is not found.
Parameters
id::String
: The job id.
Returns
ModelSelectionJob
: The job with the specifiedid
.Nothing
: If the job is not found.
Example
get_job("7182939d-c5a1-4e21-a06e-182195c961fa")
ModelSelectionGUI.set_current_job
— Methodset_current_job(job::ModelSelectionJob)
Sets the current job. If there is already a current job, it is replaced.
Parameters
job::ModelSelectionJob
: The job.
Globals
current_job::ModelSelectionJob
: The current job being processed.
Example
job = ModelSelectionJob(...)
set_current_job(job)
ModelSelectionGUI.get_pending_job
— Methodget_pending_job(id::String)
Returns the job with the specified id
from the pending jobs. Returns nothing
if the job is not found.
Parameters
id::String
: The job id.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.
Returns
ModelSelectionJob
: The job with the specifiedid
.Nothing
: If the job is not found.
Example
get_pending_job("3ea06b21-844e-4505-a912-34828fa827a1")
ModelSelectionGUI.get_current_job
— Functionget_current_job(id::Union{String,Nothing} = nothing)
Returns the current job. If id
is specified, only returns the current job if its id matches id
. Returns nothing
if there is no current job or if the id does not match.
Parameters
id::Union{String,Nothing}
: The job id.
Returns
ModelSelectionJob
: The current job or the current job with the specifiedid
.Nothing
: If the job is not found.
Globals
current_job::ModelSelectionJob
: The current job being processed.
Example
get_current_job()
ModelSelectionGUI.get_finished_job
— Methodget_finished_job(id::String)
Returns the job with the specified id
from the finished jobs. Returns nothing
if the job is not found.
Parameters
id::String
: The job id.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.
Returns
ModelSelectionJob
: The job with the specifiedid
.Nothing
: If the job is not found.
Example
get_finished_job("3ea06b21-844e-4505-a912-34828fa827a1")
ModelSelectionGUI.clear_pending_queue
— Methodclear_pending_queue()
Clear the jobs queue.
Globals
pending_queue::Vector{ModelSelectionJob}
: The queue storing pending jobs.
Example
clear_pending_queue()
ModelSelectionGUI.clear_current_job
— Methodclear_current_job()
Clear the current job.
Globals
current_job::ModelSelectionJob
: The current job being processed.
Example
clear_current_job()
ModelSelectionGUI.clear_finished_queue
— Methodclear_finished_queue()
Clear all the finished jobs.
Globals
finished_queue::Vector{ModelSelectionJob}
: The queue storing finished jobs.
Example
clear_finished_queue()
ModelSelectionGUI.clear_all_jobs
— Methodclear_all_jobs()
Clears all job queues (pending, current, finished).
Example
clear_all_jobs()
ModelSelectionGUI.start_task
— Methodstart_task()
Starts the task of consuming pending jobs from the job queue in an asynchronous way. If there's already a task running, the function simply returns without starting a new one.
Globals
JOB_TASK::Task
: The task consuming pending jobs.
Example
start_task()
ModelSelectionGUI.stop_task
— Methodstop_task()
Interrupts the currently running task of object. If no task is running, the function does nothing.
Globals
JOB_TASK::Task
: The task consuming pending jobs.interrupted_task::Bool
: Whether the task has been interrupted.pending_queue_condition::Condition
: The condition variable for the pending queue.finished_task_condition::Condition
: The condition variable for the finished task.
Example
stop_task()