Main Content

findTask

Find task in job

Description

tasks = findTask(j) returns a 1-by-N array of task objects in the job j. The tasks in the array are in order of their ID property, indicating the sequence in which they were created.

example

tasks = findTask(j,taskFcn) returns an array of task objects in the job j, filtered using the taskFcn property. taskFcn is a function handle that accepts the j.Tasks property as an input argument, and returns a logical array that indicates the tasks to return.

[pending,running,completed] = findTask(j) sorts all the tasks stored in the job j by state. Within the pending,running,completed array, the software returns the tasks in order of creation.

tasks = findTask(j,propertyName=Value) specifies properties and values to find, using one or more property name-value arguments. For a list of task properties, see parallel.Task.

The object property value must match the specified value exactly. For example, if the Name property value of a task is MyTask, then findTask does not find that object when it searches for a task with the Name property value of mytask.

Examples

collapse all

Create a job object on the default cluster.

c = parcluster;
j = createJob(c);

Create and add a task to the job object.

createTask(j,@rand,1,{10})

Find all task objects now part of job j.

t = findTask(j)

Input Arguments

collapse all

Job in which the software finds the task, specified as a parallel.Job object.

Function that findTask uses to filter the tasks from the job j, specified as a function handle.

Task object property name and value to find, specified as a parallel.task property name-value argument. If you specify more than one property name-value argument, findJob returns entries that meet all of the search criteria. For a full list of task object properties, see parallel.Task.

Example: findTask(job,Name="jsmith") finds task objects that have the Name property value of jsmith.

Output Arguments

collapse all

Tasks in the job that meet the search criteria, returned as an array of parallel.Task objects.

Tasks in a pending state on the job, returned as an array of parallel.Task objects.

Tasks in a running state on the job, returned as an array of parallel.Task objects.

Tasks in a completed or failed state on the job, returned as an array of parallel.Task objects.

Tips

If the job j is contained in a remote service, findTask results in a call to the remote service. This could result in findTask taking a long time to complete, depending on the number of tasks retrieved and the network speed. Also, if the remote service is no longer available, the software throws an error.

Version History

Introduced before R2006a