improved table

pull/835/head
Jingyi 2024-06-26 15:33:51 +08:00
commit c64cb75891
13 changed files with 20 additions and 111 deletions

View File

@ -1446,25 +1446,26 @@ if is_on_sagemaker:
sync_script = sync_item['sync_script']
logger.info(f"sync_script {sync_script}")
# sync_script.startswith('s5cmd') 不允许
# try:
# if sync_script and (
# sync_script.startswith("python3 -m pip") or sync_script.startswith("python -m pip")
# or sync_script.startswith("pip install") or sync_script.startswith("apt")
# or sync_script.startswith("os.environ") or sync_script.startswith("ls")
# or sync_script.startswith("env") or sync_script.startswith("source")
# or sync_script.startswith("curl") or sync_script.startswith("wget")
# or sync_script.startswith("print") or sync_script.startswith("cat")
# or sync_script.startswith("sudo chmod") or sync_script.startswith("chmod")
# or sync_script.startswith("/home/ubuntu/ComfyUI/venv/bin/python")):
# os.system(sync_script)
# elif sync_script and (sync_script.startswith("export ") and len(sync_script.split(" ")) > 2):
# sync_script_key = sync_script.split(" ")[1]
# sync_script_value = sync_script.split(" ")[2]
# os.environ[sync_script_key] = sync_script_value
# logger.info(os.environ.get(sync_script_key))
# except Exception as e:
# logger.error(f"Exception while execute sync_scripts : {sync_script}")
# rlt = False
try:
if sync_script and (
sync_script.startswith("cat") or sync_script.startswith("os.environ")
or sync_script.startswith("print") or sync_script.startswith("ls")
# or sync_script.startswith("python3 -m pip") or sync_script.startswith("python -m pip")
# or sync_script.startswith("pip install") or sync_script.startswith("apt")
# or sync_script.startswith("curl") or sync_script.startswith("wget")
# or sync_script.startswith("env") or sync_script.startswith("source")
# or sync_script.startswith("sudo chmod") or sync_script.startswith("chmod")
# or sync_script.startswith("/home/ubuntu/ComfyUI/venv/bin/python")
):
os.system(sync_script)
elif sync_script and (sync_script.startswith("export ") and len(sync_script.split(" ")) > 2):
sync_script_key = sync_script.split(" ")[1]
sync_script_value = sync_script.split(" ")[2]
os.environ[sync_script_key] = sync_script_value
logger.info(os.environ.get(sync_script_key))
except Exception as e:
logger.error(f"Exception while execute sync_scripts : {sync_script}")
rlt = False
need_reboot = True if ('need_reboot' in sync_item and sync_item['need_reboot']
and str(sync_item['need_reboot']).lower() == 'true') else False
global reboot

View File

@ -19,7 +19,6 @@ import {
export interface ExecuteApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
configTable: aws_dynamodb.Table;
executeTable: aws_dynamodb.Table;
endpointTable: aws_dynamodb.Table;
mergeQueue: aws_sqs.Queue;
@ -32,7 +31,6 @@ export class CreateExecuteApi {
private readonly httpMethod: string;
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly configTable: aws_dynamodb.Table;
private readonly executeTable: aws_dynamodb.Table;
private readonly endpointTable: aws_dynamodb.Table;
private readonly mergeQueue: aws_sqs.Queue;
@ -42,7 +40,6 @@ export class CreateExecuteApi {
this.httpMethod = props.httpMethod;
this.baseId = id;
this.router = props.router;
this.configTable = props.configTable;
this.executeTable = props.executeTable;
this.endpointTable = props.endpointTable;
this.mergeQueue = props.mergeQueue;
@ -198,7 +195,6 @@ export class CreateExecuteApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
this.executeTable.tableArn,
`${this.endpointTable.tableArn}`,
`${this.endpointTable.tableArn}/*`,
@ -265,7 +261,6 @@ export class CreateExecuteApi {
ephemeralStorageSize: Size.gibibytes(10),
environment: {
EXECUTE_TABLE: this.executeTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
MERGE_SQS_URL: this.mergeQueue.queueUrl,
},
layers: [this.layer],

View File

@ -12,7 +12,6 @@ export interface GetPrepareApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
syncTable: aws_dynamodb.Table;
instanceMonitorTable: aws_dynamodb.Table;
commonLayer: aws_lambda.LayerVersion;
@ -27,7 +26,6 @@ export class GetPrepareApi {
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly s3Bucket: s3.Bucket;
private readonly configTable: aws_dynamodb.Table;
private readonly syncTable: aws_dynamodb.Table;
private readonly instanceMonitorTable: aws_dynamodb.Table;
@ -37,7 +35,6 @@ export class GetPrepareApi {
this.baseId = id;
this.router = props.router;
this.s3Bucket = props.s3Bucket;
this.configTable = props.configTable;
this.syncTable = props.syncTable;
this.instanceMonitorTable = props.instanceMonitorTable;
this.layer = props.commonLayer;
@ -75,7 +72,6 @@ export class GetPrepareApi {
tracing: aws_lambda.Tracing.ACTIVE,
environment: {
SYNC_TABLE: this.syncTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
INSTANCE_MONITOR_TABLE: this.instanceMonitorTable.tableName,
},
layers: [this.layer],
@ -96,7 +92,6 @@ export class GetPrepareApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
this.syncTable.tableArn,
this.instanceMonitorTable.tableArn,
],

View File

@ -12,7 +12,6 @@ export interface GetSyncMsgApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
msgTable: aws_dynamodb.Table;
commonLayer: aws_lambda.LayerVersion;
}
@ -26,7 +25,6 @@ export class GetSyncMsgApi {
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly s3Bucket: s3.Bucket;
private readonly configTable: aws_dynamodb.Table;
private readonly msgTable: aws_dynamodb.Table;
constructor(scope: Construct, id: string, props: GetSyncMsgApiProps) {
@ -35,7 +33,6 @@ export class GetSyncMsgApi {
this.baseId = id;
this.router = props.router;
this.s3Bucket = props.s3Bucket;
this.configTable = props.configTable;
this.msgTable = props.msgTable;
this.layer = props.commonLayer;
@ -72,7 +69,6 @@ export class GetSyncMsgApi {
tracing: aws_lambda.Tracing.ACTIVE,
environment: {
MSG_TABLE: this.msgTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
},
layers: [this.layer],
});
@ -92,7 +88,6 @@ export class GetSyncMsgApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
this.msgTable.tableArn,
],
}));
@ -106,7 +101,6 @@ export class GetSyncMsgApi {
'dynamodb:BatchWriteItem',
],
resources: [
this.configTable.tableArn,
this.msgTable.tableArn,
],
}));

View File

@ -11,7 +11,6 @@ import {SqsEventSource} from "aws-cdk-lib/aws-lambda-event-sources";
export interface MergeExecuteApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
configTable: aws_dynamodb.Table;
executeTable: aws_dynamodb.Table;
mergeQueue: aws_sqs.Queue;
commonLayer: aws_lambda.LayerVersion;
@ -23,7 +22,6 @@ export class MergeExecuteApi {
private readonly httpMethod: string;
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly configTable: aws_dynamodb.Table;
private readonly executeTable: aws_dynamodb.Table;
private readonly mergeQueue: aws_sqs.Queue;
@ -32,7 +30,6 @@ export class MergeExecuteApi {
this.httpMethod = props.httpMethod;
this.baseId = id;
this.router = props.router;
this.configTable = props.configTable;
this.executeTable = props.executeTable;
this.mergeQueue = props.mergeQueue;
this.layer = props.commonLayer;
@ -81,7 +78,6 @@ export class MergeExecuteApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
`${this.executeTable.tableArn}`,
`${this.executeTable.tableArn}/*`,
],
@ -145,7 +141,6 @@ export class MergeExecuteApi {
ephemeralStorageSize: Size.gibibytes(10),
environment: {
EXECUTE_TABLE: this.executeTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
MERGE_SQS_URL: this.mergeQueue.queueUrl,
},
layers: [this.layer],

View File

@ -13,7 +13,6 @@ export interface PrepareApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
syncTable: aws_dynamodb.Table;
instanceMonitorTable: aws_dynamodb.Table;
endpointTable: aws_dynamodb.Table;
@ -27,7 +26,6 @@ export class PrepareApi {
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly s3Bucket: s3.Bucket;
private readonly configTable: aws_dynamodb.Table;
private readonly syncTable: aws_dynamodb.Table;
private readonly instanceMonitorTable: aws_dynamodb.Table;
private readonly endpointTable: aws_dynamodb.Table;
@ -38,7 +36,6 @@ export class PrepareApi {
this.baseId = id;
this.router = props.router;
this.s3Bucket = props.s3Bucket;
this.configTable = props.configTable;
this.syncTable = props.syncTable;
this.instanceMonitorTable = props.instanceMonitorTable;
this.endpointTable = props.endpointTable;
@ -85,7 +82,6 @@ export class PrepareApi {
'dynamodb:DeleteItem',
],
resources: [
this.configTable.tableArn,
this.syncTable.tableArn,
this.instanceMonitorTable.tableArn,
this.endpointTable.tableArn,
@ -142,7 +138,6 @@ export class PrepareApi {
tracing: aws_lambda.Tracing.ACTIVE,
environment: {
SYNC_TABLE: this.syncTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
INSTANCE_MONITOR_TABLE: this.instanceMonitorTable.tableName,
ENDPOINT_TABLE: this.endpointTable.tableName,
},

View File

@ -20,7 +20,6 @@ export interface QueryExecuteApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
executeTable: aws_dynamodb.Table;
commonLayer: aws_lambda.LayerVersion;
}
@ -34,7 +33,6 @@ export class QueryExecuteApi {
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly s3Bucket: s3.Bucket;
private readonly configTable: aws_dynamodb.Table;
private readonly executeTable: aws_dynamodb.Table;
constructor(scope: Construct, id: string, props: QueryExecuteApiProps) {
@ -43,7 +41,6 @@ export class QueryExecuteApi {
this.baseId = id;
this.router = props.router;
this.s3Bucket = props.s3Bucket;
this.configTable = props.configTable;
this.executeTable = props.executeTable;
this.layer = props.commonLayer;
@ -164,7 +161,6 @@ export class QueryExecuteApi {
tracing: aws_lambda.Tracing.ACTIVE,
environment: {
EXECUTE_TABLE: this.executeTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
},
layers: [this.layer],
});
@ -184,7 +180,6 @@ export class QueryExecuteApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
this.executeTable.tableArn,
],
}));

View File

@ -13,7 +13,6 @@ export interface SyncMsgApiProps {
httpMethod: string;
router: aws_apigateway.Resource;
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
msgTable: aws_dynamodb.Table;
queue: aws_sqs.Queue;
commonLayer: aws_lambda.LayerVersion;
@ -27,7 +26,6 @@ export class SyncMsgApi {
private readonly scope: Construct;
private readonly layer: aws_lambda.LayerVersion;
private readonly s3Bucket: s3.Bucket;
private readonly configTable: aws_dynamodb.Table;
private readonly msgTable: aws_dynamodb.Table;
private readonly queue: aws_sqs.Queue;
@ -37,7 +35,6 @@ export class SyncMsgApi {
this.baseId = id;
this.router = props.router;
this.s3Bucket = props.s3Bucket;
this.configTable = props.configTable;
this.msgTable = props.msgTable;
this.layer = props.commonLayer;
this.queue = props.queue;
@ -82,7 +79,6 @@ export class SyncMsgApi {
'dynamodb:Query',
],
resources: [
this.configTable.tableArn,
this.msgTable.tableArn,
],
}));
@ -96,7 +92,6 @@ export class SyncMsgApi {
'dynamodb:BatchWriteItem',
],
resources: [
this.configTable.tableArn,
this.msgTable.tableArn,
],
}));
@ -146,7 +141,6 @@ export class SyncMsgApi {
tracing: aws_lambda.Tracing.ACTIVE,
environment: {
MSG_TABLE: this.msgTable.tableName,
CONFIG_TABLE: this.configTable.tableName,
SQS_URL: this.queue.queueUrl,
},
layers: [this.layer],

View File

@ -26,7 +26,6 @@ import {GetExecuteLogsApi, GetExecuteLogsProps} from "../api/comfy/get_execute_l
export interface ComfyInferenceStackProps extends StackProps {
routers: { [key: string]: Resource };
s3Bucket: s3.Bucket;
configTable: aws_dynamodb.Table;
executeTable: aws_dynamodb.Table;
syncTable: aws_dynamodb.Table;
msgTable:aws_dynamodb.Table;
@ -45,7 +44,6 @@ export interface ComfyInferenceStackProps extends StackProps {
export class ComfyApiStack extends Construct {
private readonly layer: aws_lambda.LayerVersion;
private readonly configTable: aws_dynamodb.Table;
private readonly executeTable: aws_dynamodb.Table;
private readonly syncTable: aws_dynamodb.Table;
private readonly msgTable: aws_dynamodb.Table;
@ -58,7 +56,6 @@ export class ComfyApiStack extends Construct {
constructor(scope: Construct, id: string, props: ComfyInferenceStackProps) {
super(scope, id);
this.layer = props.commonLayer;
this.configTable = props.configTable;
this.executeTable = props.executeTable;
this.syncTable = props.syncTable;
this.msgTable = props.msgTable;
@ -88,7 +85,6 @@ export class ComfyApiStack extends Construct {
httpMethod: 'GET',
router: syncMsgGetRouter,
s3Bucket: props.s3Bucket,
configTable: this.configTable,
msgTable: this.msgTable,
commonLayer: this.layer,
});
@ -97,7 +93,6 @@ export class ComfyApiStack extends Construct {
httpMethod: 'POST',
router: props.routers.sync,
s3Bucket: props.s3Bucket,
configTable: this.configTable,
msgTable: this.msgTable,
queue: this.queue,
commonLayer: this.layer,
@ -108,7 +103,6 @@ export class ComfyApiStack extends Construct {
scope, 'Execute', <ExecuteApiProps>{
httpMethod: 'POST',
router: props.routers.executes,
configTable: this.configTable,
executeTable: this.executeTable,
endpointTable: this.endpointTable,
mergeQueue: this.mergeQueue,
@ -132,7 +126,6 @@ export class ComfyApiStack extends Construct {
httpMethod: 'GET',
router: props.routers.executes,
s3Bucket: props.s3Bucket,
configTable: this.configTable,
executeTable: this.executeTable,
queue: this.queue,
commonLayer: this.layer,
@ -143,7 +136,6 @@ export class ComfyApiStack extends Construct {
scope, 'MergeExecute', <ExecuteApiProps>{
httpMethod: 'POST',
router: props.routers.merge,
configTable: this.configTable,
executeTable: this.executeTable,
endpointTable: this.endpointTable,
mergeQueue: this.mergeQueue,
@ -157,7 +149,6 @@ export class ComfyApiStack extends Construct {
httpMethod: 'POST',
router: props.routers.prepare,
s3Bucket: props.s3Bucket,
configTable: this.configTable,
syncTable: this.syncTable,
instanceMonitorTable: this.instanceMonitorTable,
endpointTable: this.endpointTable,
@ -194,7 +185,6 @@ export class ComfyApiStack extends Construct {
httpMethod: 'GET',
router: prepareGetRouter,
s3Bucket: props.s3Bucket,
configTable: this.configTable,
syncTable: this.syncTable,
instanceMonitorTable: this.instanceMonitorTable,
commonLayer: this.layer,
@ -269,7 +259,6 @@ export class ComfyApiStack extends Construct {
props.endpointTable.tableArn,
props.executeTable.tableArn,
props.syncTable.tableArn,
props.configTable.tableArn,
props.multiUserTable.tableArn,
],
});

View File

@ -2,8 +2,6 @@ import { Table } from 'aws-cdk-lib/aws-dynamodb';
import { Construct } from 'constructs';
export class ComfyDatabase extends Construct {
public templateTable: Table;
public configTable: Table;
public executeTable: Table;
public syncTable: Table;
public msgTable: Table;
@ -11,9 +9,6 @@ export class ComfyDatabase extends Construct {
constructor(scope: Construct, baseId: string) {
super(scope, baseId);
this.templateTable = this.table(scope, baseId, 'ComfyTemplateTable');
this.configTable = this.table(scope, baseId, 'ComfyConfigTable');
this.executeTable = this.table(scope, baseId, 'ComfyExecuteTable');

View File

@ -235,7 +235,6 @@ export class Middleware extends Stack {
routers: restApi.routers,
// env: devEnv,
s3Bucket: s3Bucket,
configTable: ddbComfyTables.configTable,
executeTable: ddbComfyTables.executeTable,
syncTable: ddbComfyTables.syncTable,
msgTable: ddbComfyTables.msgTable,

View File

@ -214,26 +214,6 @@ async function createTables() {
type: AttributeType.STRING,
},
},
ComfyTemplateTable: {
partitionKey: {
name: 'template_name',
type: AttributeType.STRING,
},
sortKey: {
name: 'tag',
type: AttributeType.STRING,
},
},
ComfyConfigTable: {
partitionKey: {
name: 'config_name',
type: AttributeType.STRING,
},
sortKey: {
name: 'tag',
type: AttributeType.STRING,
},
},
ComfyExecuteTable: {
partitionKey: {
name: 'prompt_id',

View File

@ -4,24 +4,6 @@ from typing import Optional, List, Any
from libs.enums import ComfyEnvPrepareType, ComfySyncStatus
@dataclass
class ComfyTemplateTable:
template_name: str
tag: Optional[str]
s3_path: str
create_time: str
modify_time: Optional[str]
@dataclass
class ComfyConfigTable:
config_name: str
tag: Optional[str]
config_value: str
create_time: str
modify_time: Optional[str]
@dataclass
class InferenceResult:
instance_id: str