forked from zstackio/zstack
-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[ai] ZSTAC-84025: schema + SDK actions for inference template auto-match #3870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zstack-robot-2
wants to merge
3
commits into
5.5.16
Choose a base branch
from
sync/ye.zou/feat/ZSTAC-84025-auto-match
base: 5.5.16
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5525586
<feature>[ai]: schema add ModelVO.pipelineTag/manifestJson and ModelS…
AlanJager e088888
<feature>[ai]: sdk AutoMatchModelServiceByModel action and UpdateMode…
AlanJager 8ccf27b
<chore>[ai]: regenerate ApiHelper.groovy with autoMatchModelServiceBy…
AlanJager File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| -- ZSTAC-84025: Add pipelineTag to ModelVO for inference template auto-matching | ||
| CALL ADD_COLUMN('ModelVO', 'pipelineTag', 'VARCHAR(64)', 1, NULL); | ||
|
|
||
| -- ZSTAC-84025: Add isDefault to ModelServiceRefVO to mark the default inference template per model | ||
| ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `isDefault` TINYINT(1) NOT NULL DEFAULT 0; | ||
|
|
||
| -- Backfill isDefault: all existing refs default to 0 (no default template designated) | ||
| UPDATE `zstack`.`ModelServiceRefVO` SET `isDefault` = 0; | ||
|
|
||
| -- ZSTAC-84025-F2: Add manifestJson to ModelVO so Step 1 (file format) of the auto-match Matcher can | ||
| -- parse file_types/file_extensions from the manifest returned by the aios agent. | ||
| CALL ADD_COLUMN('ModelVO', 'manifestJson', 'TEXT', 1, NULL); | ||
|
|
||
| -- ZSTAC-84025: Add createDate/lastOpDate to ModelServiceRefVO so the auto-match Matcher can | ||
| -- pick the earliest isDefault=true row when DB has the rare 2+ defaults anomaly (Q5). | ||
| ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `lastOpDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; | ||
| ALTER TABLE `zstack`.`ModelServiceRefVO` ADD COLUMN `createDate` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'; | ||
101 changes: 101 additions & 0 deletions
101
sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class AutoMatchModelServiceByModelAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.AutoMatchModelServiceByModelResult value; | ||
|
|
||
| public Result throwExceptionIfError() { | ||
| if (error != null) { | ||
| throw new ApiException( | ||
| String.format("error[code: %s, description: %s, details: %s, globalErrorCode: %s]", error.code, error.description, error.details, error.globalErrorCode) | ||
| ); | ||
| } | ||
|
|
||
| return this; | ||
| } | ||
| } | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) | ||
| public java.lang.String modelUuid; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List systemTags; | ||
|
|
||
| @Param(required = false) | ||
| public java.util.List userTags; | ||
|
|
||
| @Param(required = false) | ||
| public String sessionId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeyId; | ||
|
|
||
| @Param(required = false) | ||
| public String accessKeySecret; | ||
|
|
||
| @Param(required = false) | ||
| public String requestIp; | ||
|
|
||
| @NonAPIParam | ||
| public long timeout = -1; | ||
|
|
||
| @NonAPIParam | ||
| public long pollingInterval = -1; | ||
|
|
||
|
|
||
| private Result makeResult(ApiResult res) { | ||
| Result ret = new Result(); | ||
| if (res.error != null) { | ||
| ret.error = res.error; | ||
| return ret; | ||
| } | ||
|
|
||
| org.zstack.sdk.AutoMatchModelServiceByModelResult value = res.getResult(org.zstack.sdk.AutoMatchModelServiceByModelResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.AutoMatchModelServiceByModelResult() : value; | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| public Result call() { | ||
| ApiResult res = ZSClient.call(this); | ||
| return makeResult(res); | ||
| } | ||
|
|
||
| public void call(final Completion<Result> completion) { | ||
| ZSClient.call(this, new InternalCompletion() { | ||
| @Override | ||
| public void complete(ApiResult res) { | ||
| completion.complete(makeResult(res)); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getParameterMap() { | ||
| return parameterMap; | ||
| } | ||
|
|
||
| protected Map<String, Parameter> getNonAPIParameterMap() { | ||
| return nonAPIParameterMap; | ||
| } | ||
|
|
||
| protected RestInfo getRestInfo() { | ||
| RestInfo info = new RestInfo(); | ||
| info.httpMethod = "GET"; | ||
| info.path = "/ai/models/{modelUuid}/auto-match-service"; | ||
| info.needSession = true; | ||
| info.needPoll = false; | ||
| info.parameterName = ""; | ||
| return info; | ||
| } | ||
|
|
||
| } |
39 changes: 39 additions & 0 deletions
39
sdk/src/main/java/org/zstack/sdk/AutoMatchModelServiceByModelResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| public class AutoMatchModelServiceByModelResult { | ||
| /** | ||
| * UUID of the recommended ModelServiceVO. May be null if FALLBACK step | ||
| * found no Transformers candidate. | ||
| */ | ||
| public java.lang.String recommendedServiceUuid; | ||
| public void setRecommendedServiceUuid(java.lang.String recommendedServiceUuid) { | ||
| this.recommendedServiceUuid = recommendedServiceUuid; | ||
| } | ||
| public java.lang.String getRecommendedServiceUuid() { | ||
| return this.recommendedServiceUuid; | ||
| } | ||
|
|
||
| /** | ||
| * Which matching step produced this recommendation: | ||
| * USER_PRESET | FILE_FORMAT | PIPELINE_TAG | FALLBACK | ||
| */ | ||
| public java.lang.String matchedByStep; | ||
| public void setMatchedByStep(java.lang.String matchedByStep) { | ||
| this.matchedByStep = matchedByStep; | ||
| } | ||
| public java.lang.String getMatchedByStep() { | ||
| return this.matchedByStep; | ||
| } | ||
|
|
||
| /** | ||
| * Diagnostic evidence for the match decision. | ||
| */ | ||
| public java.util.LinkedHashMap evidence; | ||
| public void setEvidence(java.util.LinkedHashMap evidence) { | ||
| this.evidence = evidence; | ||
| } | ||
| public java.util.LinkedHashMap getEvidence() { | ||
| return this.evidence; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
升级脚本加列方式不一致,存在重复执行失败风险。
Line 5、Line 16、Line 17 直接使用
ALTER TABLE ... ADD COLUMN,而同文件 Line 2/12 使用了ADD_COLUMN封装。若目标环境已存在这些列,直接ALTER会中断升级。建议统一改为带存在性检查的方式(如ADD_COLUMN或information_schema判存)。As per coding guidelines: "Upgrading scene has been carefully handled".
Also applies to: 16-17
🤖 Prompt for AI Agents