Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-import-from-hugging-face-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
agatha197 authored Jul 9, 2024
2 parents 7fd4eff + a533296 commit f0f1be8
Show file tree
Hide file tree
Showing 53 changed files with 2,556 additions and 1,995 deletions.
2 changes: 1 addition & 1 deletion config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ isDirectorySizeVisible = true # If false, directory size in folder exp
maxCountForPreopenPorts = 10 # The maximum allowed number of preopen ports. If you set this option to 0, the feature of preopen ports is disabled.
allowCustomResourceAllocation = true # If true, display the custom allocation on the session launcher.
eduAppNamePrefix = "" # The prefix of edu applauncher's app name. If the app name starts with this prefix, split it by '-' and use the tail as the name of image.
supportModelStore = false # Enable model store feature. (From Backend.AI 24.03)
enableModelStore = false # Enable model store feature. (From Backend.AI 24.03)

[wsproxy]
proxyURL = "[Proxy URL]"
Expand Down
755 changes: 755 additions & 0 deletions react/package-lock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
"dependencies": {
"@ant-design/icons": "^5.3.6",
"@cloudscape-design/board-components": "3.0.60",
"@codemirror/language": "^6.10.2",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^15.0.5",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.4",
"@types/node": "^20.14.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@uiw/codemirror-extensions-langs": "^4.22.2",
"@uiw/react-codemirror": "^4.22.2",
"ahooks": "^3.8.0",
"ansi_up": "^6.0.2",
"antd": "5.18.0",
"antd-style": "^3.6.2",
"ansi_up": "^6.0.2",
"dayjs": "^1.11.11",
"i18next": "^23.11.5",
"i18next-http-backend": "^2.5.2",
Expand Down
34 changes: 34 additions & 0 deletions react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const ResourcesPage = React.lazy(() => import('./pages/ResourcesPage'));
const FolderExplorerOpener = React.lazy(
() => import('./components/FolderExplorerOpener'),
);
const ServiceLauncherCreatePage = React.lazy(
() => import('./components/ServiceLauncherPageContent'),
);
const ServiceLauncherUpdatePage = React.lazy(
() => import('./pages/ServiceLauncherPage'),
);
const InteractiveLoginPage = React.lazy(
() => import('./pages/InteractiveLoginPage'),
);
Expand Down Expand Up @@ -144,6 +150,34 @@ const router = createBrowserRouter([
),
handle: { labelKey: 'modelService.RoutingInfo' },
},
{
path: '/service',
handle: { labelKey: 'webui.menu.Serving' },
children: [
{
path: '',
element: <Navigate to="/serving" replace />,
},
{
path: 'start',
handle: { labelKey: 'modelService.StartNewService' },
element: (
<BAIErrorBoundary>
<ServiceLauncherCreatePage />
</BAIErrorBoundary>
),
},
{
path: 'update/:endpointId',
handle: { labelKey: 'modelService.UpdateService' },
element: (
<BAIErrorBoundary>
<ServiceLauncherUpdatePage />
</BAIErrorBoundary>
),
},
],
},
{
path: '/import',
handle: { labelKey: 'webui.menu.Import&Run' },
Expand Down
49 changes: 49 additions & 0 deletions react/src/components/BAICodeEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { loadLanguage, LanguageName } from '@uiw/codemirror-extensions-langs';
import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';
import { EditorView } from '@uiw/react-codemirror';
import { useControllableValue } from 'ahooks';

interface BAICodeEditorProps extends Omit<ReactCodeMirrorProps, 'language'> {
children: string;
onChange: (value: string) => void;
language: LanguageName;
editable?: boolean;
showLineNumbers?: boolean;
lineWrapping?: boolean;
}

const BAICodeEditor: React.FC<BAICodeEditorProps> = ({
children,
onChange,
language = 'shell',
editable = false,
showLineNumbers = true,
lineWrapping = false,
...CodeMirrorProps
}) => {
const [script, setScript] = useControllableValue<string>({
defaultValue: '',
value: children,
onChange,
});
const extensions = [loadLanguage(language)!];

return (
<CodeMirror
value={script}
onChange={(value, viewUpdate) => setScript(value)}
theme={'dark'}
extensions={
lineWrapping ? [EditorView.lineWrapping, ...extensions] : extensions
}
editable={editable}
readOnly={!editable}
basicSetup={{
lineNumbers: showLineNumbers,
}}
{...CodeMirrorProps}
/>
);
};

export default BAICodeEditor;
16 changes: 8 additions & 8 deletions react/src/components/ImageResourceFormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ const ImageResourceFormItem: React.FC<ImageResourceFormItemProps> = ({
return (
{
cpu: {
label: resourceSlotsDetails?.cpu.description,
label: resourceSlotsDetails?.cpu?.description,
steps: _.map(
['0', '1', '2', '3', '4', '5', '6', '7', '8'],
(value) => ({
value,
label: `${value} ${resourceSlotsDetails?.cpu.display_unit}`,
label: `${value} ${resourceSlotsDetails?.cpu?.display_unit}`,
}),
),
},
mem: {
label: resourceSlotsDetails?.mem.description,
label: resourceSlotsDetails?.mem?.description,
steps: _.map(
[
'64m',
Expand All @@ -62,24 +62,24 @@ const ImageResourceFormItem: React.FC<ImageResourceFormItemProps> = ({
),
},
'cuda.device': {
label: resourceSlotsDetails?.['cuda.device'].description,
label: resourceSlotsDetails?.['cuda.device']?.description,
steps: _.map(['0', '1', '2', '3', '4', '5', '6', '7', '8'], (v) => ({
value: v,
label: `${v} ${resourceSlotsDetails?.['cuda.device'].display_unit}`,
label: `${v} ${resourceSlotsDetails?.['cuda.device']?.display_unit}`,
})),
},
'cuda.shares': {
label: resourceSlotsDetails?.['cuda.shares'].description,
label: resourceSlotsDetails?.['cuda.shares']?.description,
steps: _.map(
['0', '0.1', '0.2', '0.5', '1.0', '2.0', '4.0', '8.0'],
(v) => ({
value: v,
label: `${v} ${resourceSlotsDetails?.['cuda.shares'].display_unit}`,
label: `${v} ${resourceSlotsDetails?.['cuda.shares']?.display_unit}`,
}),
),
},
'rocm.device': {
label: resourceSlotsDetails?.['rocm.device'].description,
label: resourceSlotsDetails?.['rocm.device']?.description,
steps: ['0', '1', '2', '3', '4', '5', '6', '7', '8'],
},
}[type] || {
Expand Down
14 changes: 7 additions & 7 deletions react/src/components/KeypairResourcePolicySettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,20 @@ const KeypairResourcePolicySettingModal: React.FC<
<FormItemWithUnlimited
name={['parsedTotalResourceSlots', 'cpu']}
unlimitedValue={undefined}
label={resourceSlotsDetails?.cpu.description}
label={resourceSlotsDetails?.cpu?.description}
>
<InputNumber
min={0}
max={512}
addonAfter={resourceSlotsDetails?.cpu.display_unit}
addonAfter={resourceSlotsDetails?.cpu?.display_unit}
/>
</FormItemWithUnlimited>
</Col>
<Col span={12}>
<FormItemWithUnlimited
name={['parsedTotalResourceSlots', 'mem']}
unlimitedValue={undefined}
label={resourceSlotsDetails?.mem.description}
label={resourceSlotsDetails?.mem?.description}
>
<DynamicUnitInputNumber />
</FormItemWithUnlimited>
Expand All @@ -323,13 +323,13 @@ const KeypairResourcePolicySettingModal: React.FC<
<FormItemWithUnlimited
name={['parsedTotalResourceSlots', 'cuda.device']}
unlimitedValue={undefined}
label={resourceSlotsDetails?.['cuda.device'].description}
label={resourceSlotsDetails?.['cuda.device']?.description}
>
<InputNumber
min={0}
max={64}
addonAfter={
resourceSlotsDetails?.['cuda.device'].display_unit
resourceSlotsDetails?.['cuda.device']?.display_unit
}
/>
</FormItemWithUnlimited>
Expand All @@ -338,14 +338,14 @@ const KeypairResourcePolicySettingModal: React.FC<
<FormItemWithUnlimited
name={['parsedTotalResourceSlots', 'cuda.shares']}
unlimitedValue={undefined}
label={resourceSlotsDetails?.['cuda.shares'].description}
label={resourceSlotsDetails?.['cuda.shares']?.description}
>
<InputNumber
min={0}
max={256}
step={0.1}
addonAfter={
resourceSlotsDetails?.['cuda.shares'].display_unit
resourceSlotsDetails?.['cuda.shares']?.display_unit
}
/>
</FormItemWithUnlimited>
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/ProjectSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ProjectSelector: React.FC<Props> = ({
email: currentUser.email,
type:
(userRole === 'admin' || userRole === 'superadmin') &&
baiClient._config.supportModelStore
baiClient._config.enableModelStore
? ['GENERAL', 'MODEL_STORE']
: ['GENERAL'],
},
Expand Down
10 changes: 6 additions & 4 deletions react/src/components/ResourceAllocationFormItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ const ResourceAllocationFormItems: React.FC<
style={{ marginBottom: token.marginXS }}
>
<ResourcePresetSelect
showCustom
showMinimumRequired
showCustom={baiClient._config.allowCustomResourceAllocation}
showMinimumRequired={
baiClient._config.allowCustomResourceAllocation
}
onChange={(value, options) => {
switch (value) {
case 'custom':
Expand Down Expand Up @@ -485,7 +487,7 @@ const ResourceAllocationFormItems: React.FC<
name={['resource', 'cpu']}
// initialValue={0}
label={
resourceSlotsDetails?.cpu.human_readable_name || 'CPU'
resourceSlotsDetails?.cpu?.human_readable_name || 'CPU'
}
tooltip={{
placement: 'right',
Expand Down Expand Up @@ -524,7 +526,7 @@ const ResourceAllocationFormItems: React.FC<
<InputNumberWithSlider
inputNumberProps={{
addonAfter:
resourceSlotsDetails?.cpu.display_unit ||
resourceSlotsDetails?.cpu?.display_unit ||
t('session.launcher.Core'),
}}
sliderProps={{
Expand Down
6 changes: 3 additions & 3 deletions react/src/components/ResourceNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
)}

<Typography.Text>
{resourceSlotsDetails?.[type].number_format.binary
{resourceSlotsDetails?.[type]?.number_format.binary
? Number(iSizeToSize(amount, 'g', 3, true)?.numberFixed).toString()
: (resourceSlotsDetails?.[type].number_format.round_length || 0) > 0
: (resourceSlotsDetails?.[type]?.number_format.round_length || 0) > 0
? parseFloat(amount).toFixed(2)
: amount}
</Typography.Text>
<Typography.Text type="secondary">
{resourceSlotsDetails?.[type].display_unit || ''}
{resourceSlotsDetails?.[type]?.display_unit || ''}
</Typography.Text>
{type === 'mem' && opts?.shmem && opts?.shmem > 0 ? (
<Typography.Text
Expand Down
Loading

0 comments on commit f0f1be8

Please sign in to comment.