Skip to content

Commit

Permalink
feat: update desired_session_count field name to replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Dec 31, 2024
1 parent 84ed0b5 commit a8eabef
Show file tree
Hide file tree
Showing 26 changed files with 180 additions and 152 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"wsproxy",
"ahooks",
"lucide",
"Signout"
"Signout",
"Talkativot"
],
"flagWords": [
"데이터레이크",
Expand Down
30 changes: 19 additions & 11 deletions react/src/components/ServiceLauncherPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ interface ServiceCreateConfigType {
}
export interface ServiceCreateType {
name: string;
desired_session_count: number;
desired_session_count?: number;
replicas?: number;
image: string;
runtime_variant: string;
architecture: string;
Expand All @@ -106,7 +107,7 @@ export interface ServiceCreateType {
interface ServiceLauncherInput extends ImageEnvironmentFormInput {
serviceName: string;
vFolderID: string;
desiredRoutingCount: number;
replicas: number;
openToPublic: boolean;
modelMountDestination: string;
modelDefinitionPath: string;
Expand Down Expand Up @@ -153,7 +154,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
graphql`
fragment ServiceLauncherPageContentFragment on Endpoint {
endpoint_id
desired_session_count
desired_session_count @deprecatedSince(version: "24.12.0")
replicas @since(version: "24.12.0")
resource_group
resource_slots
resource_opts
Expand Down Expand Up @@ -264,7 +266,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
const legacyMutationToUpdateService = useTanMutation({
mutationFn: (values: ServiceLauncherFormValue) => {
const body = {
to: values.desiredRoutingCount,
to: values.replicas,
};
return baiSignedRequestWithPromise({
method: 'POST',
Expand All @@ -289,7 +291,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
}
const body: ServiceCreateType = {
name: values.serviceName,
desired_session_count: values.desiredRoutingCount,
// REST API does not support `replicas` field. To use `replicas` field, we need `create_endpoint` mutation.
desired_session_count: values.replicas,
...getImageInfoFromInputInCreating(
checkManualImageAllowed(
baiClient._config.allow_manual_image_name_for_session,
Expand Down Expand Up @@ -407,7 +410,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
msg
endpoint {
endpoint_id
desired_session_count
desired_session_count @deprecatedSince(version: "24.12.0")
replicas @since(version: "24.12.0")
resource_group
resource_slots
resource_opts
Expand Down Expand Up @@ -500,7 +504,11 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
? 'SINGLE_NODE'
: 'MULTI_NODE',
cluster_size: values.cluster_size,
desired_session_count: values.desiredRoutingCount,
...(baiClient.supports('replicas')
? { replicas: values.replicas }
: {
desired_session_count: values.replicas,
}),
...getImageInfoFromInputInEditing(
checkManualImageAllowed(
baiClient._config.allow_manual_image_name_for_session,
Expand Down Expand Up @@ -643,7 +651,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
serviceName: endpoint?.name,
resourceGroup: endpoint?.resource_group,
allocationPreset: 'custom',
desiredRoutingCount: endpoint?.desired_session_count ?? 1,
replicas: endpoint?.replicas ?? endpoint?.desired_session_count ?? 1,
// FIXME: memory doesn't applied to resource allocation
resource: {
cpu: parseInt(JSON.parse(endpoint?.resource_slots || '{}')?.cpu),
Expand Down Expand Up @@ -692,7 +700,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
// TODO: set mounts alias map according to extra_mounts if possible
}
: {
desiredRoutingCount: 1,
replicas: 1,
runtimeVariant: 'custom',
...RESOURCE_ALLOCATION_INITIAL_FORM_VALUES,
...(baiClient._config?.default_session_environment && {
Expand Down Expand Up @@ -899,8 +907,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
</>
)}
<Form.Item
label={t('modelService.DesiredRoutingCount')}
name="desiredRoutingCount"
label={t('modelService.Replicas')}
name={'replicas'}
rules={[
{
required: true,
Expand Down
6 changes: 5 additions & 1 deletion react/src/components/ServiceValidationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ const ServiceValidationView: React.FC<ServiceValidationModalProps> = ({
const image: string = `${values.environments.image?.registry}/${values.environments.image?.name}:${values.environments.image?.tag}`;
const body: ServiceCreateType = {
name: values.serviceName,
desired_session_count: values.desiredRoutingCount,
...(baiClient.supports('replicas')
? { replicas: values.replicas }
: {
desired_session_count: values.replicas,
}),
image: image,
runtime_variant: values.runtimeVariant,
architecture: values.environments.image?.architecture as string,
Expand Down
58 changes: 28 additions & 30 deletions react/src/pages/EndpointDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useWebUINavigate,
} from '../hooks';
import { useCurrentUserInfo } from '../hooks/backendai';
import { useBAIPaginationOptionState } from '../hooks/reactPaginationQueryOptions';
import { useTanMutation } from '../hooks/reactQueryAlias';
import { isDestroyingStatus } from './EndpointListPage';
import {
Expand Down Expand Up @@ -68,7 +69,8 @@ interface RoutingInfo {
export interface ModelServiceInfo {
endpoint_id: string;
name: string;
desired_session_count: number;
desired_session_count?: number;
replicas?: number;
active_routes: RoutingInfo[];
service_endpoint: string;
is_public: boolean;
Expand All @@ -91,12 +93,14 @@ const dayDiff = (a: any, b: any) => {
const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
const { t } = useTranslation();
const { token } = theme.useToken();
const baiClient = useSuspendedBackendaiClient();
const navigate = useNavigate();
const { message } = App.useApp();
const { baiPaginationOption } = useBAIPaginationOptionState({
current: 1,
pageSize: 100,
});
const { serviceId } = useParams<{
serviceId: string;
}>();

const [fetchKey, updateFetchKey] = useUpdatableState('initial-fetch');
const [isPendingRefetch, startRefetchTransition] = useTransition();
const [isPendingClearError, startClearErrorTransition] = useTransition();
Expand All @@ -107,14 +111,8 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
const [openChatModal, setOpenChatModal] = useState(false);
const [currentUser] = useCurrentUserInfo();
// const curProject = useCurrentProjectValue();
const [paginationState] = useState<{
current: number;
pageSize: number;
}>({
current: 1,
pageSize: 100,
});
const { message } = App.useApp();
const baiClient = useSuspendedBackendaiClient();
const navigate = useNavigate();
const webuiNavigate = useWebUINavigate();
const { open } = useFolderExplorerOpener();
const [selectedSessionId, setSelectedSessionId] = useState<string>();
Expand Down Expand Up @@ -151,7 +149,8 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
size_bytes
supported_accelerators
}
desired_session_count
desired_session_count @deprecatedSince(version: "24.12.0")
replicas @since(version: "24.12.0")
url
open_to_public
errors {
Expand Down Expand Up @@ -207,9 +206,8 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
}
`,
{
tokenListOffset:
(paginationState.current - 1) * paginationState.pageSize,
tokenListLimit: paginationState.pageSize,
tokenListOffset: baiPaginationOption.offset,
tokenListLimit: baiPaginationOption.limit,
endpointId: serviceId || '',
},
{
Expand Down Expand Up @@ -298,7 +296,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
},
{
label: t('modelService.DesiredSessionCount'),
children: endpoint?.desired_session_count,
children: endpoint?.desired_session_count ?? endpoint?.replicas,
},
{
label: t('modelService.ServiceEndpoint'),
Expand Down Expand Up @@ -481,7 +479,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
loading={isPendingRefetch}
icon={<ReloadOutlined />}
disabled={isDestroyingStatus(
endpoint?.desired_session_count,
endpoint?.desired_session_count ?? endpoint?.replicas,
endpoint?.status,
)}
onClick={() => {
Expand All @@ -502,7 +500,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
icon={<SettingOutlined />}
disabled={
isDestroyingStatus(
endpoint?.desired_session_count,
endpoint?.desired_session_count ?? endpoint?.replicas,
endpoint?.status,
) ||
(!!endpoint?.created_user_email &&
Expand Down Expand Up @@ -532,7 +530,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
type="primary"
icon={<PlusOutlined />}
disabled={isDestroyingStatus(
endpoint?.desired_session_count,
endpoint?.desired_session_count ?? endpoint?.replicas,
endpoint?.status,
)}
onClick={() => {
Expand Down Expand Up @@ -562,14 +560,14 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
fixed: 'left',
render: (text, row) => (
<Typography.Text ellipsis copyable style={{ width: 150 }}>
{row.token}
{row?.token}
</Typography.Text>
),
},
{
title: 'Status',
render: (text, row) => {
const isExpired = dayjs.utc(row.valid_until).isBefore();
const isExpired = dayjs.utc(row?.valid_until).isBefore();
return (
<Tag color={isExpired ? 'red' : 'green'}>
{isExpired ? 'Expired' : 'Valid'}
Expand All @@ -585,7 +583,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
{
// FIXME: temporally parse UTC and change to timezone (timezone need to be added in server side)
row.valid_until
? dayjs.utc(row.valid_until).tz().format('ll LTS')
? dayjs.utc(row?.valid_until).tz().format('ll LTS')
: '-'
}
</span>
Expand All @@ -598,7 +596,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
title: 'Created at',
dataIndex: 'created_at',
render: (text, row) => (
<span>{dayjs(row.created_at).format('ll LT')}</span>
<span>{dayjs(row?.created_at).format('ll LT')}</span>
),
defaultSortOrder: 'descend',
sortDirections: ['descend', 'ascend', 'descend'],
Expand All @@ -618,7 +616,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
icon={<SyncOutlined />}
loading={mutationToSyncRoutes.isPending}
disabled={isDestroyingStatus(
endpoint?.desired_session_count,
endpoint?.desired_session_count ?? endpoint?.replicas,
endpoint?.status,
)}
onClick={() => {
Expand Down Expand Up @@ -674,20 +672,20 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
row.status && (
<>
<Tag
color={applyStatusColor(row.status)}
key={row.status}
color={applyStatusColor(row?.status)}
key={row?.status}
style={{ marginRight: 0 }}
>
{row.status.toUpperCase()}
{row?.status.toUpperCase()}
</Tag>
{row.status === 'FAILED_TO_START' && row.session && (
{row?.status === 'FAILED_TO_START' && row?.session && (
<Button
size="small"
type="text"
icon={<QuestionCircleOutlined />}
style={{ color: token.colorTextSecondary }}
onClick={() => {
row.session && openSessionErrorModal(row.session);
row?.session && openSessionErrorModal(row?.session);
}}
/>
)}
Expand Down
Loading

0 comments on commit a8eabef

Please sign in to comment.