Skip to content

Commit

Permalink
FIx bug of endpoint page (#704)
Browse files Browse the repository at this point in the history
* Sync endpoint page

* Update EndpointPage.vue

* Reset code

* Update endpoint settings to fetch resources by cluster id

---------

Co-authored-by: 朱鑫睿 <[email protected]>
Co-authored-by: Hiveer <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2024
1 parent f078827 commit 2a07dba
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/endpoints/EndpointDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
:settingsVisibility="canManage"
:can-write="canWrite"
repo-type="endpoint"
:hardware="endpoint.hardware"
:clusterId="endpoint.cluster_id"
:sku="endpoint.sku"
:modelId="endpoint.model_id"
:private="endpoint.private"
:endpointReplica="endpoint.actual_replica"
Expand Down Expand Up @@ -96,7 +97,6 @@
const ownerUrl = computed(() => {
const { namespace } = modelInfo.value
if (!namespace) return ''
const baseUrl = namespace.Type === 'user' ? '/profile/' : '/organizations/'
return baseUrl + namespace.Path
})
Expand Down
29 changes: 27 additions & 2 deletions frontend/src/components/endpoints/EndpointPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<span>{{ $t('endpoints.detail.cloudResource')}}</span>
</p>
<p class="w-[390px] lg:w-[370px] mlg:w-full h-[35px] leading-[18px] text-gray-500 text-xs overflow-hidden text-ellipsis line-clamp-2 text-left">
{{ hardware }}
{{ resource.name }}
</p>
</div>

Expand All @@ -62,12 +62,15 @@
</template>

<script setup>
import { watch, ref } from 'vue'
import useFetchApi from '../../packs/useFetchApi'
import EndpointPlayground from './EndpointPlayground.vue'
const props = defineProps({
appEndpoint: String,
appStatus: String,
hardware: String,
clusterId: String,
sku: String,
modelId: String,
private: String,
replicaList: Array,
Expand All @@ -76,4 +79,26 @@
default: 0
}
})
const resource = ref({})
const fetchResources = async () => {
const { data, error } = await useFetchApi(`/space_resources?cluster_id=${props.clusterId}`).json()
if (error.value) {
ElMessage({
message: error.value.msg,
type: 'warning'
})
} else {
const body = data.value
resource.value = body.data.find((cloudResource) => {
return String(cloudResource.id) === props.sku
}) || {}
}
}
watch(() => props.clusterId, () => {
fetchResources()
})
</script>
19 changes: 12 additions & 7 deletions frontend/src/components/endpoints/EndpointSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@
cloudResource: String,
framework: String,
maxReplica: Number,
minReplica: Number
minReplica: Number,
clusterId: String
})
const { t } = useI18n()
Expand Down Expand Up @@ -359,8 +360,10 @@
return !!framework.frame_npu_image
} else if (currentResource.value.type === 'gpu') {
return !!framework.frame_image
} else {
} else if (currentResource.value.type === 'cpu') {
return !!framework.frame_cpu_image
} else {
return true
}
})
})
Expand All @@ -378,6 +381,12 @@
}
})
watch(() => props.clusterId, () => {
if (props.clusterId) {
fetchResources()
}
})
const stopEndpoint = async () => {
const stopUrl = `/models/${props.modelId}/run/${props.endpointId}/stop`
const { response, error } = await useFetchApi(stopUrl).put().json()
Expand Down Expand Up @@ -439,7 +448,7 @@
}
const fetchResources = async () => {
const { data, error } = await useFetchApi('/space_resources').json()
const { data, error } = await useFetchApi(`/space_resources?cluster_id=${props.clusterId}`).json()
if (error.value) {
ElMessage({
Expand Down Expand Up @@ -551,8 +560,4 @@
})
}
}
onMounted(() => {
fetchResources()
})
</script>
6 changes: 4 additions & 2 deletions frontend/src/components/shared/RepoTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
:modelId="modelId"
:private="private"
:endpointReplica="endpointReplica"
:hardware="hardware"
:clusterId="repoDetail.cluster_id"
:sku="sku"
:replicaList="replicaList"
/>
<repo-summary
Expand Down Expand Up @@ -232,6 +233,7 @@
:framework="repoDetail.runtime_framework"
:maxReplica="repoDetail.max_replica"
:minReplica="repoDetail.min_replica"
:clusterId="repoDetail.cluster_id"
/>
</template>
</tab-container>
Expand Down Expand Up @@ -280,7 +282,7 @@
sdk: String,
userName: String,
commitId: String,
hardware: String,
sku: String,
modelId: String,
private: Boolean,
endpointReplica: Number,
Expand Down

0 comments on commit 2a07dba

Please sign in to comment.