Skip to content

Commit

Permalink
chore(controller): add draft field to model version vo (star-whale#2982)
Browse files Browse the repository at this point in the history
  • Loading branch information
anda-ren authored Nov 16, 2023
1 parent 855b540 commit 0b768e5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions client/starwhale/base/client/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ class ModelVersionVo(SwBaseModel):
owner: Optional[UserVo] = None
shared: bool
built_in_runtime: Optional[str] = Field(None, alias='builtInRuntime')
draft: bool


class ModelVo(SwBaseModel):
Expand Down
3 changes: 3 additions & 0 deletions client/tests/core/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ def test_list_with_project(self, req: Mocker, mock_list: MagicMock):
alias="v2",
created_time=5,
shared=False,
draft=False,
),
)
mock_list.return_value = ([model_foo, model_foo], {})
Expand Down Expand Up @@ -1200,6 +1201,7 @@ def test_run(self, rm: Mocker) -> None:
"createdTime": 1697042331000,
"owner": None,
"shared": True,
"draft": False,
"stepSpecs": [
{
"name": "mnist.evaluator:MNISTInference.predict",
Expand Down Expand Up @@ -1247,6 +1249,7 @@ def test_run(self, rm: Mocker) -> None:
"versionTag": "t1",
"createdTime": 1697042331000,
"shared": 1,
"draft": False,
"id": "1",
}
},
Expand Down
1 change: 1 addition & 0 deletions client/tests/data/job/job_list_resp.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"createdTime": 1685593961000,
"owner": null,
"shared": 0,
"draft": false,
"builtInRuntime": null
}
},
Expand Down
3 changes: 3 additions & 0 deletions client/tests/sdk/test_job_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def test_list_jobs_from_server(
alias="v2",
created_time=789,
shared=False,
draft=False,
),
),
runtime=RuntimeVo(
Expand Down Expand Up @@ -286,6 +287,7 @@ def test_create_remote_job(self, rm: Mocker, mock_load_conf: MagicMock) -> None:
"createdTime": 1697042331000,
"owner": None,
"shared": True,
"draft": False,
"stepSpecs": [
{
"name": "mnist.evaluator:MNISTInference.predict",
Expand Down Expand Up @@ -333,6 +335,7 @@ def test_create_remote_job(self, rm: Mocker, mock_load_conf: MagicMock) -> None:
"versionTag": "t1",
"createdTime": 1697042331000,
"shared": 1,
"draft": False,
"id": "1",
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public class ModelVersionVo implements Serializable {
@NotNull
private List<StepSpec> stepSpecs;

@NotNull
@JsonProperty("draft")
private Boolean draft;

public static ModelVersionVo empty() {
return new ModelVersionVo("", "", "", false, List.of(), 0L, -1L, UserVo.empty(), false, "", List.of());
return new ModelVersionVo("", "", "", false, List.of(), 0L, -1L, UserVo.empty(), false, "", List.of(), false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public ModelVersionVo convert(
.stepSpecs(jobSpecParser.parseAndFlattenStepFromYaml(entity.getJobs()))
.size(entity.getStorageSize())
.shared(entity.getShared())
.draft(entity.getDraft())
.build();
} catch (JsonProcessingException e) {
log.error("convert ModelVersionVo error", e);
Expand Down

0 comments on commit 0b768e5

Please sign in to comment.