getTask - noetl/noetl GitHub Wiki

E.g. exitCode = getTask(taskInstance)

Parameters

  • task: current task instance

Key Variables

  • exitCode: records the success or failure of getTask
  • merge: key in the task.start dictionary that is a join step
  • mergeStep: step instance of join
  • mergeBranch: branch instance starting with the joinStep
  • branchName: branchName that forks from the task and joins at joinStep
  • newBranch: branch instance associated with branchName
  • firstStep: firstStep in the new branch
  • lastStep: last step in the new branch

Functionality

The exitCode is initialized to the taskName.

  • If the taskName is not start or exit, then the program enters an if block which initializes and validates the task.
    • If the task forks branches (task.start has multiple values), then:
      • getTask iterates through each of the keys in the task.start dictionary, retrieving the merge step. If the merge step is not "0" (the filler value), then the branches actually merge later on. The mergeStep is created as and instance of Step, and a mergeBranch is an instance of the Branch class. The mergeStep is added to the branch's steps dictionary and the task's step dictionary, and the branch is added to the task.branchValidDict with the value of False, indicating that the branch has not been fully validated yet.
        • Iterating through the branches in under each of the merge steps, they are added as dependencies to the merge branches.
      • getTask also iterates through each step in the values of task.start, creating a new branch and step instance for each. It adds the step to the branch and task's step dictionaries, and adds the branch to the task's branchDict. The exitCode is set to the return value of calling makeBranches on each of the branches.
    • Otherwise if the task starts of with a sequence of steps (only one value in task.start dictionary), then the firstStep of the branch is recorded from the task.start value, and a step instance is created with the firstStep name, and a branch is initialized using the firstStep name and "0" as a filler value for the last step. The step is added to the branch steps and the task steps, and the branch is added to the task's branchDict and the task branchValidDict. The exitCode is set to the return value of calling makeBranches on the new branch.

If the taskName is "exit" or "CONF_NOT_FOUND", then the exitCode is set to the taskName. Otherwise, the exitCode is set to the result of calling runTask on the current task. After running the task, if the task's restart list is not empty, then a notification of the task, the failed steps, and the failed cursors for each of the steps is recorded in the log file, and getTask is called on the nextFail task. If the task was successful, then getTask is called on the nextTask.

Except Statement

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

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

Return Value

Returns the exitCode.