makeBranches - noetl/noetl GitHub Wiki

E.g. exitCode = makeBranches(taskInstance, currentBranchInstance, stepInstance)

Parameters

  • task: current task instance
  • curBranch: current branch instance
  • step: current step instance

Key Variables

  • exitCode: records the success or failure of makeBranches
  • next: name of the next step
  • nextStep: next step instance
  • nextBranch: branch instance for new branch
  • mergeReady: Boolean if join step's dependencies have been validated
  • mergeStep: join step instance
  • mergeBranch: join branch instance for the join step

Functionality

The exitCode is initialized to 0.

If there is only one value in the step.success dictionary, makeBranches retrieves the next step from the success dictionary, and instantiates the nextStep Step object.

  • If the next step is "exit", then the lastStep field in the branch is set to the current step, and the current branch is marked True in the branchValidDict because the branch has been successfully validated. The exitCode is returned.
  • Else if the next step is the same as the branch's mergeStep, then makeBranches is done creating the current branch and starts the new branch(es). The lastStep field for the current branch is set to the current step, and the branch is marked True in the task's branchValidDict. The nextBranch is retrieved from the task's branchesDict dictionary using the nextStep step name as the key. MakeBranches then checks if the nextBranch is ready to be called/validated. Initializing a mergeReady boolean as True, makeBranches iterates through each branch in the nextBranch dependencies. If any branch in the dependencies list is not marked as True in the tasks' branchValidDict dictionary, then the mergeReady boolean is set to False. After iterating through the dependencies, if mergeReady is True, then makeBranches is called on the nextBranch and the exitCode is set equal to the result of the call.
  • Otherwise, the next step is just a continuation of the sequence of steps in the same branch. The next step is added to the branch's dictionary of steps and the task's dictionary of steps. The exitCode is set equal to the return value of calling makeBranches on the same branch and the nextStep.

Otherwise, if there are multiple values in the step.success dictionary, the lastStep field for the current branch is set to the current step, and the branch is marked True in the task's branchValidDict.

  • To set up the join steps and branches, makeBranches first iterates through each of the join step names in the step's success dictionary key set. If the join step is not "0" (the filler value), then the mergeStep Step object is initialized, a mergeBranch Branch object is initialized, the mergeStep is added to the branch's and the task's dictionary of steps, the mergeBranch is added to the task's branchesDict, and the branch is added to the task's branchesValidDict. For each of the branches that merge at the mergeStep, the branches are added to the mergeBranch's dependencies list and are added to the task's branchValidDict as False.
  • MakeBranches iterates through the step.success dictionary keys again, and the steps in each of the mergeStep's value lists to set up the branches to be forked. For each step in the values of the step.success dictionary, a nextStep Step object and a newBranch Branch object are initialized, the nextStep is added to the branch's and the task's step dictionaries, and the newBranch is added to the task's branchesDict dictionary. For each of the new branches, the exitCode is set to the return value of calling makeBranches on the newBranch and the nextStep.

Except Statement

If an error arises, the except block writes to the log file, recording the time, current task, and the error message.

The exitCode is set equal to -1, indicating a failure.

Return Value

Returns the exitCode.