This approach is useful when tasks depend on a file that is not present anymore.
Create a new job using the default cluster profile. In this example, it is the local parallel pool.
Create several tasks. In particular, create a task that depends on a MAT-file that does not exist.
Submit the job, and wait for it to finish. Because the MAT-file in the second task does not exist, the job fails. If you call fetchOutputs
on job
to retrieve the results, you get an error. Check the error using the Error
property of the corresponding task.
ans =
ParallelException with properties:
identifier: 'MATLAB:load:couldNotReadFile'
message: 'Unable to find file or directory 'myData.mat'.'
cause: {}
remotecause: {[1×1 MException]}
stack: [1×1 struct]
Correction: []
Create the MAT-file referenced from the second task using the save
function. To create a new job with the tasks that resulted in an error, use the 'Tasks'
name-value pair in recreate
, and provide the hasError
function. If you want to select a different set of tasks, you can define your own function.
Submit the new job, wait for its completion, and fetch the outputs. Because the MAT-file now exists, the job does not fail.
ans = struct with fields:
str: 'Task2'