Mandatory Requirements

The only mandatory requirement for jobs is that they must complete a defined amount of work and then terminate, as job execution is considered complete once this work is done. To specify the amount of work a job must perform, the user must define the following function:

async def checkCompleteness(lambdaContext: LambdaContext) -> bool:
    jobDone: bool = ...
    return jobDone

The function must return a boolean value.

For details on interacting with lambdaContext, see the corresponding chapter.

For details on additional helpers available within this function, see the corresponding chapter.

This function must indicate whether there is remaining work to be completed in the current or subsequent job execution runs. Although there is no restriction preventing the function from always returning True (indicating that work is still pending), its presence in lambda_main.py is a mandatory requirement for creating a workflow and, consequently, for creating jobs within that workflow.

Additional Requirements

There are also several optional functions that users may define for more granular control over the job lifecycle, enables more flexible control over the execution time of each specific job, allowing resources to be freed up and utilized more optimally across all jobs:

Execution completeness check

Following the same principle as defining the total amount of completed work, users may define a function that reports whether the portion of work scheduled for the current job execution run has been completed. Regardless of whether this function is defined, the maximum execution time for a single job is governed by the luna-lambda service settings.

async def checkExecutionCompleteness(lambdaContext: LambdaContext) -> bool:
    batchDone: bool = ...
    return batchDone

The function must return a boolean value.

For details on interacting with lambdaContext, see the corresponding chapter.

For details on additional helpers available within this function, see the corresponding chapter.

Job busyness check

To determine whether a job can be terminated, the checkExecutionCompleteness function is used. However, there are cases where checkExecutionCompleteness reports that the current work is done, but some background processes still need to be completed before the job can be stopped. In such cases, the checkBusy function can be used. A job will not be considered complete — taking into account all other constraints — as long as checkBusy returns True instead of False:

async def checkBusy(lambdaContext: LambdaContext) -> bool:
    jobIsBusy: bool = ...
    return jobIsBusy

The function must return a boolean value.

For details on interacting with lambdaContext, see the corresponding chapter.

For details on additional helpers available within this function, see the corresponding chapter