Skip to content
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

refactor(controller): rename manifest field of runtime to image #1105

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class RuntimeVersionVO implements Serializable {
@JsonProperty("meta")
private Object meta;

@JsonProperty("manifest")
private String manifest;
@JsonProperty("image")
private String image;

@JsonProperty("createdTime")
private Long createdTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import ai.starwhale.mlops.domain.runtime.mapper.RuntimeVersionMapper;
import ai.starwhale.mlops.domain.swds.bo.SWDataSet;
import ai.starwhale.mlops.domain.swds.converter.SWDSBOConverter;
import ai.starwhale.mlops.domain.swds.po.SWDatasetVersionEntity;
import ai.starwhale.mlops.domain.swmp.SWModelPackage;
import ai.starwhale.mlops.domain.swmp.po.SWModelPackageEntity;
import ai.starwhale.mlops.domain.swmp.mapper.SWModelPackageMapper;
Expand Down Expand Up @@ -108,8 +107,8 @@ public Job fromEntity(JobEntity jobEntity){
.storagePath(runtimeVersionEntity.getStoragePath())
.deviceAmount(jobEntity.getDeviceAmount())
.deviceClass(Device.Clazz.from(jobEntity.getDeviceType()))
.image(null == runtimeVersionEntity.getManifest() ? defaultRuntimeImage
: runtimeVersionEntity.getManifest())
.image(null == runtimeVersionEntity.getImage() ? defaultRuntimeImage
: runtimeVersionEntity.getImage())
.build())
.status(jobEntity.getJobStatus())
.type(jobEntity.getType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,11 @@ public void upload(MultipartFile dsFile, ClientRuntimeRequest uploadRequest){
}
/* create new entity */
if(!entityExists) {
RuntimeManifest runtimeManifestObj = null;
RuntimeManifest runtimeManifestObj;
String runtimeManifest ;
try(final InputStream inputStream = dsFile.getInputStream()){
// only extract the eval job file content
String runtimeManifest = new String(
runtimeManifest = new String(
Objects.requireNonNull(
TarFileUtil.getContentFromTarFile(inputStream, "", "_manifest.yaml")));
runtimeManifestObj = yamlMapper.readValue(runtimeManifest,
Expand All @@ -357,8 +358,8 @@ public void upload(MultipartFile dsFile, ClientRuntimeRequest uploadRequest){
.storagePath(runtimePath)
.runtimeId(entity.getId())
.versionName(uploadRequest.version())
.versionMeta(uploadRequest.getRuntime())
.manifest(null == runtimeManifestObj? null : runtimeManifestObj.getBaseImage())
.versionMeta(runtimeManifest)
.image(null == runtimeManifestObj? null : runtimeManifestObj.getBaseImage())
.build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public RuntimeVersionVO convert(RuntimeVersionEntity entity)
.owner(userConvertor.convert(entity.getOwner()))
.tag(entity.getVersionTag())
.meta(entity.getVersionMeta())
.manifest(entity.getManifest())
.image(entity.getImage())
.createdTime(localDateTimeConvertor.convert(entity.getCreatedTime()))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class RuntimeVersionEntity extends BaseEntity implements BundleVersionEnt

private String storagePath;

private String manifest;
private String image;

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2022 Starwhale, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
ALTER TABLE runtime_version RENAME COLUMN manifest TO image;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
rv.version_tag as rv_version_tag,
rv.version_meta as rv_version_meta,
rv.storage_path as rv_storage_path,
rv.manifest as rv_manifest,
rv.image as rv_image,
rv.created_time as rv_created_time,
rv.modified_time as rv_modified_time,
u.id as user_id,
Expand Down Expand Up @@ -78,21 +78,21 @@
</select>

<insert id="revertTo">
replace into runtime_version (runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, manifest)
select runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, manifest
replace into runtime_version (runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, image)
select runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, image
from runtime_version
where id = #{rtVersionId}
</insert>

<insert id="addNewVersion" parameterType="ai.starwhale.mlops.domain.runtime.po.RuntimeVersionEntity" useGeneratedKeys="true" keyProperty="id">
insert into runtime_version (runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, manifest)
insert into runtime_version (runtime_id, owner_id, version_name, version_tag, version_meta, storage_path, image)
values(#{version.runtimeId},
#{version.ownerId},
#{version.versionName},
#{version.versionTag},
#{version.versionMeta},
#{version.storagePath},
#{version.manifest})
#{version.image})
</insert>

<update id="update" parameterType="ai.starwhale.mlops.domain.runtime.po.RuntimeVersionEntity">
Expand All @@ -110,7 +110,7 @@
<result property="versionTag" column="rv_version_tag" />
<result property="versionMeta" column="rv_version_meta" />
<result property="storagePath" column="rv_storage_path" />
<result property="manifest" column="rv_manifest" />
<result property="image" column="rv_image" />
<result property="createdTime" column="rv_created_time"/>
<result property="modifiedTime" column="rv_modified_time"/>
<result property="ownerId" column="owner_id" />
Expand Down