in source/src/molecule-unfolding/cdk/construct-benchmark.ts [92:188]
constructor(scope: Construct, id: string, props: BatchProps) {
super(scope, id);
this.props = props;
this.images = ECRImageUtil.newInstance(scope, this.props)
this.roleUtil = RoleUtil.newInstance(scope, this.props)
this.lambdaUtil = LambdaUtil.newInstance(scope, this.props, {
roleUtil: this.roleUtil,
imageUtil: this.images
});
this.batchUtil = BatchUtil.newInstance(scope, this.props, {
roleUtil: this.roleUtil,
imageUtil: this.images
})
this.logKey = new kms.Key(scope, 'stepFuncsLogKey', {
enableKeyRotation: true
});
this.taskParamLambda = this.lambdaUtil.createTaskParametersLambda()
this.waitForTokenLambda = this.lambdaUtil.createWaitForTokenLambda()
const checkInputParamsStep = this.createCheckInputStep()
const createModelStep = this.createCreateModelStep();
const hpcStateMachine = this.createHPCStateMachine();
const qcStateMachine = this.createQCStateMachine()
const qcAndHPCStateMachine = this.createHPCAndQCStateMachine(hpcStateMachine, qcStateMachine)
const aggResultStep = this.createAggResultStep();
const notifyStep = this.createSNSNotifyStep();
const postSteps = sfn.Chain.start(aggResultStep).next(notifyStep)
const hpcBranch = new tasks.StepFunctionsStartExecution(this, "Run HPC", {
stateMachine: hpcStateMachine,
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
associateWithParent: true,
input: sfn.TaskInput.fromObject({
"execution_id": sfn.JsonPath.stringAt("$.execution_id")
}),
resultPath: "$.hpcBranch"
}).next(postSteps)
const qcBranch = new tasks.StepFunctionsStartExecution(this, "Run QC", {
stateMachine: qcStateMachine,
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
associateWithParent: true,
input: sfn.TaskInput.fromObject({
"execution_id": sfn.JsonPath.stringAt("$.execution_id")
}),
resultPath: "$.qcBranch"
}).next(postSteps)
const qcAndHpcBranch = new tasks.StepFunctionsStartExecution(this, "Run QC and HPC", {
stateMachine: qcAndHPCStateMachine,
integrationPattern: sfn.IntegrationPattern.RUN_JOB,
associateWithParent: true,
input: sfn.TaskInput.fromObject({
"execution_id": sfn.JsonPath.stringAt("$.execution_id")
}),
resultPath: "$.qcAndHpcBranch"
}).next(postSteps)
const choiceStep = new sfn.Choice(this, "Select Running Mode")
.when(sfn.Condition.isNotPresent("$.runMode"), qcAndHpcBranch)
.when(sfn.Condition.stringEquals("$.runMode", 'HPC'), hpcBranch)
.when(sfn.Condition.stringEquals("$.runMode", 'QC'), qcBranch)
.otherwise(qcAndHpcBranch)
const statchMachineChain = sfn.Chain.start(checkInputParamsStep).next(createModelStep)
.next(choiceStep)
const logGroupName = `${this.props.stackName}-BenchmarkStateMachineLogGroup`
grantKmsKeyPerm(this.logKey, logGroupName)
const logGroup = new logs.LogGroup(this, 'BenchmarkStateMachineLogGroup', {
encryptionKey: this.logKey,
logGroupName,
removalPolicy: cdk.RemovalPolicy.DESTROY,
retention: logs.RetentionDays.THREE_MONTHS
});
const benchmarkStateMachine = new sfn.StateMachine(this, 'BenchmarkStateMachine', {
definition: statchMachineChain,
timeout: cdk.Duration.hours(36),
logs: {
destination: logGroup,
level: sfn.LogLevel.ALL,
},
});
logGroup.grantWrite(benchmarkStateMachine)
// Output //////////////////////////
new cdk.CfnOutput(this, "stateMachineURL", {
value: `https://console.aws.amazon.com/states/home?region=${this.props.region}#/statemachines/view/${benchmarkStateMachine.stateMachineArn}`,
description: "State Machine URL"
});
}