Skip to content

Commit

Permalink
bug: Set Step function log group prefix + fix deployment when not def…
Browse files Browse the repository at this point in the history
…ault embeded is set.
  • Loading branch information
charles-marion committed Oct 29, 2024
1 parent 9607ef8 commit 8bb61b0
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 7 deletions.
4 changes: 4 additions & 0 deletions lib/rag-engines/aurora-pgvector/create-aurora-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ export class CreateAuroraWorkspace extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/CreateAuroraWorkspace-${this.node.addr}`,
}
);

Expand Down
4 changes: 4 additions & 0 deletions lib/rag-engines/data-import/file-import-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export class FileImportWorkflow extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/FileImportStateMachine-${this.node.addr}`,
});

const workflow = setProcessing.next(fileImportJob).next(setProcessed);
Expand Down
4 changes: 4 additions & 0 deletions lib/rag-engines/data-import/website-crawling-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class WebsiteCrawlingWorkflow extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/WebsiteCrawling-${this.node.addr}`,
});

const workflow = setProcessing.next(webCrawlerJob).next(setProcessed);
Expand Down
4 changes: 4 additions & 0 deletions lib/rag-engines/kendra-retrieval/create-kendra-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export class CreateKendraWorkspace extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/CreateKendraWorkspace-${this.node.addr}`,
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class CreateOpenSearchWorkspace extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/CreateOpenSearchWorkspace-${this.node.addr}`,
}
);

Expand Down
4 changes: 4 additions & 0 deletions lib/rag-engines/workspaces/delete-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ export class DeleteWorkspace extends Construct {
? cdk.RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
: cdk.RemovalPolicy.DESTROY,
retention: props.config.logRetention,
// Log group name should start with `/aws/vendedlogs/` to not exceed Cloudwatch Logs Resource Policy
// size limit.
// https://docs.aws.amazon.com/step-functions/latest/dg/bp-cwl.html
logGroupName: `/aws/vendedlogs/states/DeleteWorkspace-${this.node.addr}`,
});

const stateMachine = new sfn.StateMachine(this, "DeleteWorkspace", {
Expand Down
5 changes: 3 additions & 2 deletions lib/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export abstract class Utils {
}
}

static getDefaultEmbeddingsModel(config: SystemConfig): string {
static getDefaultEmbeddingsModel(config: SystemConfig): string | undefined {
const defaultModel = config.rag.embeddingsModels.find(
(model) => model.default === true
);

if (!defaultModel) {
throw new Error("No default embeddings model found");
// No default embdeding is set in the config when Aurora or Opensearch are not used.
return undefined;
}

return `${defaultModel.provider}::${defaultModel.dimensions}::${defaultModel.name}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ export default function Embeddings() {
validate: (form) => {
const errors: Record<string, string | string[]> = {};

if (!form.embeddingsModel) {
errors.embeddingsModel = "Embeddings model is required";
}

for (let i = 0; i < form.input.length; i++) {
const input = form.input[i];
if (input.trim().length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/user-interface/react-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
define: {
"process.env": {},
// Prevents replacing global in the import strings.
global: "global",
global: isDev ? {} : "global",
},
plugins: [
isDev && {
Expand Down
6 changes: 6 additions & 0 deletions tests/__snapshots__/cdk-app.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7995,6 +7995,7 @@ schema {
"RagEnginesAuroraPgVectorCreateAuroraWorkspaceCreateAuroraWorkspaceSMLogGroup3134E68A": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateAuroraWorkspace-c85defe1059e7fe274e5d32dfa5fbf22bf25029784",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -9261,6 +9262,7 @@ schema {
"RagEnginesDataImportFileImportWorkflowFileImportSMLogGroupACEA6D66": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/FileImportStateMachine-c8cf719aab95cd313558c24b954a4d64738cc90e28",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -12512,6 +12514,7 @@ schema {
"RagEnginesDataImportWebsiteCrawlingWorkflowWebsiteCrawlingSMLogGroup0C0F0231": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/WebsiteCrawling-c84284c45e3cc190f86fcddfefa098795bf6057ea6",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -12579,6 +12582,7 @@ schema {
"RagEnginesKendraRetrievalCreateKendraWorkspaceCreateKendraWorkspaceSMLogGroupC9D4A635": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateKendraWorkspace-c82d1f0bddb3f281b5b0d41fbdc8dd5ce18a954f60",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -13593,6 +13597,7 @@ schema {
"RagEnginesOpenSearchVectorCreateOpenSearchWorkspaceCreateOpenSearchWorkspaceSMLogGroupB97A0992": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateOpenSearchWorkspace-c80c40855b0079b324a7fd75085c6a2e70b9e6eeae",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -17211,6 +17216,7 @@ schema {
"RagEnginesWorkspacesDeleteWorkspaceDeleteWorkspaceSMLogGroup6EA3524F": {
"DeletionPolicy": "RetainExceptOnCreate",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c8d0f97b477041b4948603d16e0499afeaa5361c9c",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5853,6 +5853,7 @@ schema {
"RagEnginesAuroraPgVectorCreateAuroraWorkspaceCreateAuroraWorkspaceSMLogGroup3134E68A": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateAuroraWorkspace-c8452d5c1e50beef6ce7711a12b5b2b94c06ab63c9",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -7033,6 +7034,7 @@ schema {
"RagEnginesDataImportFileImportWorkflowFileImportSMLogGroupACEA6D66": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/FileImportStateMachine-c8dccfec6c46c17fc1838ad79ebf8db898b8909b9c",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -10280,6 +10282,7 @@ schema {
"RagEnginesDataImportWebsiteCrawlingWorkflowWebsiteCrawlingSMLogGroup0C0F0231": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/WebsiteCrawling-c84c2dc1c7dcbb91f090053c5011b698fba19f95c3",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -10347,6 +10350,7 @@ schema {
"RagEnginesKendraRetrievalCreateKendraWorkspaceCreateKendraWorkspaceSMLogGroupC9D4A635": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateKendraWorkspace-c8fb806c7befce2813b20d937db829309c4304e20d",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -11357,6 +11361,7 @@ schema {
"RagEnginesOpenSearchVectorCreateOpenSearchWorkspaceCreateOpenSearchWorkspaceSMLogGroupB97A0992": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/CreateOpenSearchWorkspace-c8a01fbc6e0a5b466bef32a0f428525db17267e978",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down Expand Up @@ -14699,6 +14704,7 @@ schema {
"RagEnginesWorkspacesDeleteWorkspaceDeleteWorkspaceSMLogGroup6EA3524F": {
"DeletionPolicy": "Delete",
"Properties": {
"LogGroupName": "/aws/vendedlogs/states/DeleteWorkspace-c8407881c0ca4430481731ee6b0a7f7f73e6028115",
"RetentionInDays": 731,
},
"Type": "AWS::Logs::LogGroup",
Expand Down

0 comments on commit 8bb61b0

Please sign in to comment.