Skip to content

Commit

Permalink
fix: fixed issue with batch rescoring s3 trigger and small bug in /sc…
Browse files Browse the repository at this point in the history
…ore/community/address endpoint (#762)
  • Loading branch information
lucianHymer authored Jan 13, 2025
1 parent b3b523f commit 1e525f7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion api/ceramic_cache/api/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def handle_get_ui_score(
score.expiration_date is not None and score.expiration_date < now
):
# This will re-calculate the score and update the expiration date
ret = get_detailed_score_response_for_address(address)
ret = get_detailed_score_response_for_address(address, scorer_id)

return ret

Expand Down
17 changes: 9 additions & 8 deletions infra/aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1573,14 +1573,15 @@ const createdTask = createTask({
scorerSecretManagerArn: scorerSecret.arn,
});

export const s3TriggeredECSTask = createS3InitiatedECSTask(
`bulk-score-requests-${stack}`,
cluster.arn,
createdTask.task.arn,
vpcPrivateSubnetIds,
[secgrp.id],
createdTask.eventsStsAssumeRole.arn
);
export const s3TriggeredECSTask = createS3InitiatedECSTask({
bucketName: `bulk-score-requests-${stack}`,
clusterArn: cluster.arn,
taskDefinitionArn: createdTask.task.arn,
subnetIds: vpcPrivateSubnetIds,
securityGroupIds: [secgrp.id],
eventsStsAssumeRoleArn: createdTask.eventsStsAssumeRole.arn,
containerName: createdTask.containerName,
});

const PASSPORT_APP_GITHUB_URL =
"https://github.com/passportxyz/passport-scorer";
Expand Down
33 changes: 21 additions & 12 deletions infra/lib/scorer/s3_initiated_ecs_task.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import * as aws from "@pulumi/aws";
import { Input, Output } from "@pulumi/pulumi";
import {defaultTags} from "../tags";
import { defaultTags } from "../tags";

export function createS3InitiatedECSTask(
bucketName: string,
clusterArn: Output<string>,
taskDefinitionArn: Output<string>,
subnetIds: Output<any>,
securityGroupIds: Output<string>[],
eventsStsAssumeRoleArn: Input<string>
) {
export function createS3InitiatedECSTask({
bucketName,
clusterArn,
taskDefinitionArn,
subnetIds,
securityGroupIds,
eventsStsAssumeRoleArn,
containerName,
}: {
bucketName: string;
clusterArn: Output<string>;
taskDefinitionArn: Output<string>;
subnetIds: Output<any>;
securityGroupIds: Output<string>[];
eventsStsAssumeRoleArn: Input<string>;
containerName: string;
}) {
// Create S3 bucket
const bucket = new aws.s3.Bucket(bucketName, {
bucket: bucketName,
Expand All @@ -34,7 +43,7 @@ export function createS3InitiatedECSTask(
tags: {
...defaultTags,
Name: folder,
}
},
});
});

Expand All @@ -59,7 +68,7 @@ export function createS3InitiatedECSTask(
tags: {
...defaultTags,
Name: "s3-to-ecs-rule",
Scope: "MBD batch processing"
Scope: "MBD batch processing",
},
});

Expand All @@ -86,7 +95,7 @@ export function createS3InitiatedECSTask(
inputTemplate: JSON.stringify({
containerOverrides: [
{
name: "web", // Replace with actual container name or fetch dynamically
name: containerName,
environment: [
{
name: "S3_BUCKET",
Expand Down
5 changes: 4 additions & 1 deletion infra/lib/scorer/scheduledTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export function createTask({
},
});

const containerName = `${name}-container`;

const task = new aws.ecs.TaskDefinition(`${name}-1`, {
family: `${name}-1`,
cpu: (cpu ? cpu : 256).toString(),
Expand All @@ -94,7 +96,7 @@ export function createTask({
.apply(([env, secs, image, logGroupName, logGroupRegion]) =>
JSON.stringify([
{
name: `${name}-container`,
name: containerName,
image,
cpu: cpu ? cpu : 256,
memory: memory ? memory : 2048,
Expand Down Expand Up @@ -232,6 +234,7 @@ export function createTask({
subnets,
alertTopic,
commandSuccessMessage,
containerName,
};
}

Expand Down

0 comments on commit 1e525f7

Please sign in to comment.