You can use FileDependencies inside of a deployed application as well. However, note that all MATLAB files and classes used by the deployed application, even those run on the workers on the cluster, have to be embedded inside of the deployed application. Thus you cannot use FileDependencies to point to a random directory of MATLAB code and classes on the client. Instead, you have to use FileDependencies to point to MATLAB files that you want to run on the cluster embedded inside of the application CTF repository.
Consider the following example contained in the CustomerExample.zip (see file attachment at the bottom of the page).
The application in this example consists of two directories located in the same parent directory:
parent directory
|
|->ExampleForCustomer
|->ClassesForCustomer
Open the compileTest.m file inside of the ExampleForCustomer directory.
function compileTest()
sched = findResource('scheduler','configuration','KONRADM1');
job = createJob(sched)
task = createTask(job, @clusterTestFunction, 0, {});
set(task, 'CaptureCommandWindowOutput',1);
if isdeployed
fd = {fullfile(ctfroot,'1-F1K7QO', 'ClassesForCustomer'),which('clusterTestFunction.m')};
else
fd = {'../ClassesForCustomer','clusterTestFunction.m'};
end
set(job, 'FileDependencies',fd);
submit(job);
waitForState(job);
get(task, 'CommandWindowOutput')
end
Note that when specifying path dependencies for the compiled application, the paths have to specified relative to the CTFROOT. Also note that in a deployed application (code inside of the if isdeployed branch) you need to specify a full path (minus the letter drive on Windows) for directories that are not subdirectories of the build directory. In this example the ClassesForCustomer directory was located at T:\1-F1K7QO\ClassesForCustomer, while the ExampleForCustomer directory was located at T:\1-F1K7QO\ExampleForCustomer.
To compile this example navigate to the ExampleForCustomer directory and modify the findResource command inside of compileTest.m to match your cluster configuration. Then compile the program within ExampleForCustomer directory using the following command:
>> mcc -m compileTest.m -I \full\path\to\the\ClassesForCustomer
for example:
>> mcc -m compileTest.m -I T:\1-F1K7QO\ClassesForCustomer
Now consider the example in ExampleForCustomer2.zip (see attachment at the bottom of the page). The directory structure for this example is shown below.
parent_directory
|
|->ExampleForCustomer
|
|->ClassesForCustomer
Since the files on which the distributed job depends are specified in a subdirectory of the ExampleForCustomer, we now have to specify FileDependencies for the job using ctfroot and the path components relative to the ExampleForCustomer directory.
In this example the FileDependencies would be built as follows:
function compileTest()
sched = findResource('scheduler','configuration','KONRADM1');
job = createJob(sched)
task = createTask(job, @clusterTestFunction, 0, {});
set(task, 'CaptureCommandWindowOutput',1);
if isdeployed
fd = {fullfile(ctfroot,'ClassesForCustomer'), which('clusterTestFunction.m')};
else
fd = {fullfile(pwd,'ClassesForCustomer'), ''clusterTestFunction.m'};
end
set(job, 'FileDependencies',fd);
submit(job);
waitForState(job);
get(task, 'CommandWindowOutput')
end
To compile this variant use the following command line within ExampleForCustomer directory:
>> mcc -m compileTest.m -I ClassesForCustomer
After the compilation completes, test either variant of the application from MATLAB Command Prompt by typing:
>> !compileTest
You should receive the following output after successful execution:
>> !compileTest
job =
Job ID 20 Information
=====================
UserName : USER
AuthorizedUsers : {}
State : pending
SubmitTime :
StartTime :
Running Duration :
- Data Dependencies
FileDependencies : {}
PathDependencies : {}
- Associated Task(s)
Number Pending : 0
Number Running : 0
Number Finished : 0
TaskID of errors :
- Jobmanager Dependent Properties
MaximumNumberOfWorkers : Inf
MinimumNumberOfWorkers : 1
Timeout : Inf
RestartWorker : false
QueuedFcn :
RunningFcn :
FinishedFcn :
ans =
sally =
Person handle
Properties:
gender: 'Female'
name: 'Sally Sales'
Methods, Events, Superclasses
joe =
Employee handle
Properties:
salary: '2010'
startDate: '100000'
gender: 'Male'
name: 'Joe Jones'
Methods, Events, Superclasses
tom =
Manager handle
Properties:
bonus: '10000'
salary: '2011'
startDate: '200000'
gender: 'Male'
name: 'Tom Sawyer'
Methods, Events, Superclasses
For more information on CTF, DEPFUN and specifying paths in deployed applications please refere to the following documentation pages:
Best Answer