Skip to content

Commit

Permalink
fix(controller): make resource pool feature compatible with the old d…
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui authored and dreamlandliu committed Aug 25, 2022
1 parent 81c2123 commit 0dd4822
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ai.starwhale.mlops.domain.swds.po.SWDatasetVersionEntity;
import ai.starwhale.mlops.domain.system.mapper.ResourcePoolMapper;
import ai.starwhale.mlops.domain.system.po.ResourcePoolEntity;
import ai.starwhale.mlops.domain.system.resourcepool.ResourcePoolConverter;
import ai.starwhale.mlops.domain.user.UserConvertor;
import ai.starwhale.mlops.exception.ConvertException;
import ai.starwhale.mlops.exception.SWProcessException;
Expand Down Expand Up @@ -61,6 +62,9 @@ public class JobConvertor implements Convertor<JobEntity, JobVO> {
@Resource
private ResourcePoolMapper resourcePoolMapper;

@Resource
private ResourcePoolConverter resourcePoolConverter;

@Override
public JobVO convert(JobEntity jobEntity) throws ConvertException {
List<RuntimeVO> runtimeByVersionIds = runtimeService.findRuntimeByVersionIds(
Expand All @@ -76,6 +80,7 @@ public JobVO convert(JobEntity jobEntity) throws ConvertException {
.collect(Collectors.toList());

ResourcePoolEntity resourcePoolEntity = resourcePoolMapper.findById(jobEntity.getResourcePoolId());
var resourcePool = resourcePoolConverter.toResourcePool(resourcePoolEntity);

return JobVO.builder()
.id(idConvertor.convert(jobEntity.getId()))
Expand All @@ -91,7 +96,7 @@ public JobVO convert(JobEntity jobEntity) throws ConvertException {
.jobStatus(jobEntity.getJobStatus())
.stopTime(localDateTimeConvertor.convert(jobEntity.getFinishedTime()))
.comment(jobEntity.getComment())
.resourcePool(resourcePoolEntity.getLabel())
.resourcePool(resourcePool.getLabel())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public ResourcePoolEntity toEntity(ResourcePool pool) {
}

public ResourcePool toResourcePool(ResourcePoolEntity entity) {
if (entity == null) {
return ResourcePool.empty();
}

return ResourcePool.builder().label(entity.getLabel()).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,7 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(label);
}
public static ResourcePool empty() {
return new ResourcePool("default");
}
}

0 comments on commit 0dd4822

Please sign in to comment.