fetchOutputs - Retrieve output arguments from all tasks in job - MATLAB (original) (raw)
Main Content
Retrieve output arguments from all tasks in job
Syntax
Description
`data` = fetchOutputs([j](#mw%5F1ecf898f-ae21-44b0-9c4a-592d94a8d6dd))
retrieves the output arguments contained in the tasks of a finished job.
When you retrieve outputs from a job you create using createJob
orcreateCommunicatingJob
, each row of them
-by-n
cell array data
contains the output arguments for each of the m
tasks in the job. Each of the rows in data
has n
elements, where n
is the greatest number of output arguments from any one task in the job. Then
elements of a row are arrays containing the output arguments from that task. If a task has less than n
output arguments, the excess elements in the row for that task are empty.
When you retrieve outputs from a job you create using batch
:
- If you create the batch job using the
fcn
syntax and specifyN
outputs,data
is a1
-by-N
cell array. - If you create the batch job using the
script
orexpression
syntaxes,data
is a1
-by-1
cell array containing a structure scalar. If you specify thePool
argument when you create the batch job, the structure scalar contains the workspace of the worker that acts as the client. Otherwise, the structure scalar contains the workspace of the worker that runs the job.
The output data for a job is stored in the location given by theJobStorageLocation
property of the cluster that the job runs on. When you run fetchOutputs
, the output data is not removed from theJobStorageLocation
. To remove the output data, use the delete function to remove individual tasks or entire jobs.
The fetchOutputs
function throws an error if:
- The
State
property of the jobj
is not'finished'
. - The
State
property of the jobj
is'finished'
and one of the tasks given by theTasks
property of the jobj
encountered an error.
Tip
To see if any of the tasks on the job j
failed after encountering an error, check if j.Tasks.Error
is empty. If the returned array is empty, none of the tasks on the job j
encountered any errors.
If some tasks completed successfully, you can use theOutputArguments
property of a task to access the output arguments of that task directly.
Examples
Run a batch job, then retrieve outputs from that job.
Use batch
to create a job using the default cluster profile. In that job, run magic(3)
on a worker and store one output.
Wait for the job to complete. Then, use fetchOutputs
to retrieve output data from the job.
wait(j) data = fetchOutputs(j);
The data retrieved is a cell array containing one output frommagic(3)
. Index into the cell array to get that output.
Input Arguments
Version History
Introduced in R2012a