Skip to content

Commit

Permalink
feat: support imageaccelerate
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpand0508 committed May 31, 2023
1 parent c4acb51 commit 72156eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
39 changes: 21 additions & 18 deletions src/modules/scf/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface FunctionCode {
RegistryId?: string;
Command?: string;
Args?: string;
ContainerImageAccelerate?: boolean;
};
}

Expand Down Expand Up @@ -69,11 +70,11 @@ export interface BaseFunctionConfig {
NodeSpec?: string;
SFType?: string;
GpuReservedQuota?: number;
//请求并发
// 请求并发
InstanceConcurrencyConfig?: {
DynamicEnabled?: boolean
MaxConcurrency?: number
}
DynamicEnabled?: boolean;
MaxConcurrency?: number;
};
}

export interface TriggerType {
Expand Down Expand Up @@ -235,6 +236,8 @@ export interface ScfCreateFunctionInputs {
command?: string;
// 启动命令参数
args?: string;
// 镜像加速
containerImageAccelerate?: boolean;
};

// 异步调用重试配置
Expand All @@ -244,15 +247,15 @@ export interface ScfCreateFunctionInputs {
protocolType?: string;
protocolParams?: ProtocolParams;

//sd应用类型
sFType?: string
//gpu并发数,默认是0
gpuReservedQuota?: number
//请求并发配置
instanceConcurrencyConfig?:{
dynamicEnabled?: boolean
maxConcurrency?: number
}
// sd应用类型
sFType?: string;
// gpu并发数,默认是0
gpuReservedQuota?: number;
// 请求并发配置
instanceConcurrencyConfig?: {
dynamicEnabled?: boolean;
maxConcurrency?: number;
};
}

export interface ScfUpdateAliasTrafficInputs {
Expand Down Expand Up @@ -408,25 +411,25 @@ export interface GetRequestStatusOptions {
/**
* 函数名称
*/
functionName: string
functionName: string;

/**
* 需要查询状态的请求id
*/
functionRequestId: string
functionRequestId: string;

/**
* 函数的所在的命名空间
*/
namespace?: string
namespace?: string;

/**
* 查询的开始时间,例如:2017-05-16 20:00:00,不填默认为当前时间 - 15min
*/
startTime?: string
startTime?: string;

/**
* 查询的结束时间,例如:2017-05-16 20:59:59,不填默认为当前时间。EndTime 需要晚于 StartTime。
*/
endTime?: string
endTime?: string;
}
24 changes: 14 additions & 10 deletions src/modules/scf/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
if (imageConfig.args) {
functionInputs.Code!.ImageConfig!.Args = imageConfig.args;
}

if (imageConfig?.containerImageAccelerate !== undefined) {
functionInputs.Code!.ImageConfig!.ContainerImageAccelerate =
imageConfig.containerImageAccelerate;
}
} else {
// 基于 COS 代码部署
functionInputs.Code = {
Expand Down Expand Up @@ -83,23 +88,22 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
functionInputs.ProtocolParams = protocolParams;
}
}

}
//sd应用类型
if(inputs?.sFType){

// sd应用类型
if (inputs?.sFType) {
functionInputs.SFType = inputs?.sFType;
}
//sd gpu并发数
if(inputs?.gpuReservedQuota){
// sd gpu并发数
if (inputs?.gpuReservedQuota) {
functionInputs.GpuReservedQuota = inputs?.gpuReservedQuota;
}
//请求并发
if(inputs?.instanceConcurrencyConfig){
// 请求并发
if (inputs?.instanceConcurrencyConfig) {
functionInputs.InstanceConcurrencyConfig = {
DynamicEnabled: inputs?.instanceConcurrencyConfig?.dynamicEnabled,
MaxConcurrency: inputs?.instanceConcurrencyConfig?.maxConcurrency
}
MaxConcurrency: inputs?.instanceConcurrencyConfig?.maxConcurrency,
};
}

if (inputs.role) {
Expand Down

0 comments on commit 72156eb

Please sign in to comment.