Allow Chains to continue after failure

This read-only archive contains discussions from the Adding Feature forum.
New feature request may be posted to the Adding Feature forum.
Technical support is available via the Help forum.
Locked
Edgar
Forum Crew
Posts: 2041
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Allow Chains to continue after failure

Post by Edgar » Sun Nov 01, 2015 5:57 pm

Allow Chains to optionally continue processing the next file after processing a file fails.

Code: Select all

   bool continueOnError;
   gPrefs->Read(wxT("/AudioFiles/ContinueChaining"), &continueOnError;)
   for (size_t i = 0; i < filesToProcess; i++) {
      project->OnRemoveTracks();
      bool successfulImport = project->Import(files[i]);
      project->OnSelectAll();
      bool chainApplied = mBatchCommands.ApplyChain();
      if (!continueOnError)
         break;
      if (mAbort)
         break;
      project->GetUndoManager()->ClearStates();
   }
Currently, when a batch process encounters a problem with one of the files in its list of files-to-process, the entire batch process aborts. For unattended operations this can be inconvenient.

Note also that there is a potential for serious problems in the existing code:

Code: Select all

   for (i = 0; i < (int)files.GetCount(); i++) {
      wxWindowDisabler wd(&d);
      if (i > 0) {
         //Clear the arrow in previous item.
         mList->SetItemImage(i - 1, 0, 0);
      }
      mList->SetItemImage(i, 1, 1);
      mList->EnsureVisible(i);

      project->Import(files[i]);
      project->OnSelectAll();
      if (!mBatchCommands.ApplyChain()) {
         break;
      }

      if (!d.IsShown() || mAbort) {
         break;
      }
      UndoManager *um = project->GetUndoManager();
      um->ClearStates();
      project->OnSelectAll();
      project->OnRemoveTracks();
   }
project->Import(files);
returns a Boolean value which should be tested:

Code: Select all

bool successfulImport = project->Import(files[i]);
if (!successfulImport)
   break;
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

steve
Site Admin
Posts: 80326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Allow Chains to continue after failure

Post by steve » Sun Nov 01, 2015 6:13 pm

Edgar wrote: Allow Chains to optionally continue processing the next file after processing a file fails.
I think that if we did that, then errors would need to be logged and a clear message presented to the user on completion of the batch informing them of which files were processed successfully. which files failed, and what the failure was in each failed command.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Edgar
Forum Crew
Posts: 2041
Joined: Thu Sep 03, 2009 9:13 pm
Operating System: Windows 10

Re: Allow Chains to continue after failure

Post by Edgar » Sun Nov 01, 2015 10:47 pm

steve wrote:
Edgar wrote: Allow Chains to optionally continue processing the next file after processing a file fails.
I think that if we did that, then errors would need to be logged and a clear message presented to the user on completion of the batch informing them of which files were processed successfully. which files failed, and what the failure was in each failed command.
I chose to go the route of only listing the files which were NOT processed successfully – for my purposes just adding them to Audacity's Log was sufficient (I commented out all existing wxLog…() calls to make my life easier). Originally I tried using a wxTextFile (wx 2.8* - never tried 3.x) but got very sporadic results creating a new text file or even opening an existing one.

The only meaningful error that I trap is a failure to Import (I have never experienced a failure to Export).

*I cannot use Chains in the most current version of Audacity because some plug-ins "fail" (and thus cause the complete process to abort) even though they are not really failing. Imagine running Click Repair as part of a chain; currently (2.1), if no clicks are repaired the effect returns "failed". In Audacity 2.0.6 this was not considered a failure and thus the process continues.
-Edgar
running Audacity personally customized 2.0.6 daily in a professional audio studio
occasionally using current Audacity alpha for testing and support situations
64-bit Windows Pro 10

steve
Site Admin
Posts: 80326
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: Allow Chains to continue after failure

Post by steve » Mon Nov 02, 2015 1:18 am

Not a general solution, but in the case of Nyquist plug-ins it is possible to suppress error messages in the plug-in code. The best way to do that is to return "NIL" on error. The downside is that there is no indication that it has failed.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Gale Andrews
Quality Assurance
Posts: 41763
Joined: Fri Jul 27, 2007 12:02 am
Operating System: Windows 10

Re: Allow Chains to continue after failure

Post by Gale Andrews » Mon Nov 02, 2015 6:04 pm

Edgar wrote:I cannot use Chains in the most current version of Audacity because some plug-ins "fail" (and thus cause the complete process to abort) even though they are not really failing. Imagine running Click Repair as part of a chain; currently (2.1), if no clicks are repaired the effect returns "failed". In Audacity 2.0.6 this was not considered a failure and thus the process continues.
+1 to the feature request, but as you say, the Click Removal error isn't really an error any more than Truncate Silence failing to find any silences would be. It's just an information prompt. It's an example where we want the effect to show errors when running in a project but not when running in a Chain, so really it ought to be coded like that in the absence of Chains being able to ignore errors.

With your "continue after failure" code, is it still necessary to put Click Removal last in a Chain so that the other commands in the Chain get a chance to complete?

Although it may be good to show errors in the Log, could we not use the dialogue that lists the Chain steps and files as they progress to indicate if an error occurred? If an error does occur, leave that dialogue open when the Chain completes, instead of closing it.


Gale
________________________________________FOR INSTANT HELP: (Click on Link below)
* * * * * Tips * * * * * Tutorials * * * * * Quick Start Guide * * * * * Audacity Manual

Locked