Jobs

The section of the package is responsible for handle the jobs.

Index

Contents

ModelSelectionGUI.current_jobConstant
current_job::Union{ModelSelectionJob, Nothing}

A variable to store the current job being processed, or nothing if no job is active.

source
ModelSelectionGUI.add_pending_jobMethod
add_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: The ModelSelectionJob object.

Example

job = ModelSelectionJob(...)
add_pending_job(job)
source
ModelSelectionGUI.get_job_fileMethod
get_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")
source
ModelSelectionGUI.consume_pending_jobsMethod
consume_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()
source
ModelSelectionGUI.consume_pending_jobMethod
consume_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()
source
ModelSelectionGUI.run_jobMethod
run_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: The ModelSelectionJob 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)
source
ModelSelectionGUI.get_pending_queue_lengthMethod
get_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()
source
ModelSelectionGUI.add_job_fileMethod
add_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")
source
ModelSelectionGUI.job_notifyFunction
job_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"))
source
ModelSelectionGUI.get_jobMethod
get_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 specified id.
  • Nothing: If the job is not found.

Example

get_job(queue, "7182939d-c5a1-4e21-a06e-182195c961fa")
source
ModelSelectionGUI.get_jobMethod
get_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 specified id.
  • Nothing: If the job is not found.

Example

get_job("7182939d-c5a1-4e21-a06e-182195c961fa")
source
ModelSelectionGUI.set_current_jobMethod
set_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)
source
ModelSelectionGUI.get_pending_jobMethod
get_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 specified id.
  • Nothing: If the job is not found.

Example

get_pending_job("3ea06b21-844e-4505-a912-34828fa827a1")
source
ModelSelectionGUI.get_current_jobFunction
get_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 specified id.
  • Nothing: If the job is not found.

Globals

  • current_job::ModelSelectionJob: The current job being processed.

Example

get_current_job()
source
ModelSelectionGUI.get_finished_jobMethod
get_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 specified id.
  • Nothing: If the job is not found.

Example

get_finished_job("3ea06b21-844e-4505-a912-34828fa827a1")
source
ModelSelectionGUI.start_taskMethod
start_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()
source
ModelSelectionGUI.stop_taskMethod
stop_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()
source