Is there a afterAll-like listener function for batch jobs?

2 vues (au cours des 30 derniers jours)
Andre Zeug
Andre Zeug le 13 Mai 2020
Commenté : Andre Zeug le 15 Mai 2020
I want to run processes in background using batch, such as for figure and video generation and file saving, and want to execute a control function right after the job is finished, to check whether the job was successful or not. For parfeval one can use afterEach and afterAll. Is there something similar for batch? Sure I don't want to stop my main function and wait for the job to be finished.

Réponse acceptée

Jason Ross
Jason Ross le 13 Mai 2020
There are a few ways to approach this.
You could periodically check the job state and then do something. The job will know if it's finished or failed and you could act accordingly. See the properties of the job for more information.
If you are using the MathWorks job scheduler you can set up callbacks that run when the job finishes. Those are described on the job properties page and there's an example here.
  1 commentaire
Andre Zeug
Andre Zeug le 15 Mai 2020
Dear Jason,
thanks for your reply. If I understand it right, there is no (easy) way to use the 'FinishedFcn' property on a simple local cluster. I tried
cc = parcluster;
job1 = batch(cc,'batchtest');
job1.FinishedFcn = @(job,eventdata) disp([job.Name ' now ' job.State]);
which end up with
Unrecognized property 'FinishedFcn' for class 'parallel.job.CJSIndependentJob'.
since "...CJS independent job objects do not have any properties beyond the properties common to all job types...."
So far I see no other option than frequently run
[pending queued running completed] = findJob(parallel.cluster.local);
Question: is there a chance to use a "MATLAB Job Scheduler" on a local cluster? (I do not want to waste one tread for a job, continuously checking if a batch job completed.)
Thanks, Andre

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Parallel Computing Fundamentals dans Help Center et File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by