Skip to content

Commit

Permalink
Merge branch 'main' into 25.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yomybaby committed Jan 17, 2025
2 parents 1dac46a + 5e36c40 commit 4e6cced
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 42 deletions.
10 changes: 8 additions & 2 deletions react/src/components/ImageInstallModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ const ImageInstallModal: React.FC<ImageInstallModalInterface> = ({
const handleClick = () => {
onRequestClose();
const installPromises = imagesToInstall.map(async (image) => {
const imageName = image?.registry + '/' + image?.name + ':' + image?.tag;
const imageName =
image?.registry +
'/' +
(image?.namespace ?? image?.name) +
':' +
image?.tag;
let isGPURequired = false;
const imageResource = {} as { [key: string]: any };
image?.resource_limits?.forEach((resourceLimit) => {
Expand Down Expand Up @@ -163,7 +168,8 @@ const ImageInstallModal: React.FC<ImageInstallModalInterface> = ({
<List
size="small"
dataSource={imagesToInstall.map(
(image) => `${image?.registry}/${image?.name}/${image?.tag}`,
(image) =>
`${image?.registry}/${image?.namespace ?? image?.name}/${image?.tag}`,
)}
style={{
width: '100%',
Expand Down
8 changes: 0 additions & 8 deletions react/src/components/ModelCardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,6 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
size="small"
disabled={!model_card?.vfolder?.cloneable}
onClick={() => {
// const event = new CustomEvent('backend-ai-vfolder-cloning', {
// detail: {
// // TODO: change this to vfolder name
// name: mode_card?.name,
// },
// });
// onRequestClose();
// document.dispatchEvent(event);
setVisibleCloneModal(true);
}}
>
Expand Down
4 changes: 2 additions & 2 deletions react/src/components/ModelCloneModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ const ModelCloneModal: React.FC<ModelCloneModalProps> = ({
formRef.current
?.validateFields()
.then((values) => {
if (vfolder?.name && vfolder.host) {
if (vfolder?.id && vfolder.host) {
mutationToClone.mutate(
{
input: values,
name: vfolder.name,
name: vfolder.id,
},
{
onSuccess(data) {
Expand Down
13 changes: 8 additions & 5 deletions react/src/components/ServiceLauncherPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
row_id
}
image_object @since(version: "23.09.9") {
name
name @deprecatedSince(version: "24.12.0")
namespace @since(version: "24.12.0")
humanized_name
tag
registry
Expand Down Expand Up @@ -256,7 +257,7 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
return {
image: (isManualImageEnabled
? formInput.environments.manual?.split('@')[0]
: `${formInput.environments.image?.registry}/${formInput.environments.image?.name}:${formInput.environments.image?.tag}`) as string,
: formInput.environments.version?.split('@')[0]) as string,
architecture: (isManualImageEnabled
? formInput.environments.manual?.split('@')[1]
: formInput.environments.image?.architecture) as string,
Expand Down Expand Up @@ -420,7 +421,8 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
open_to_public
model
image_object @since(version: "23.09.9") {
name
name @deprecatedSince(version: "24.12.0")
namespace @since(version: "24.12.0")
humanized_name
tag
registry
Expand Down Expand Up @@ -682,8 +684,9 @@ const ServiceLauncherPageContent: React.FC<ServiceLauncherPageContentProps> = ({
cluster_size: endpoint?.cluster_size,
openToPublic: endpoint?.open_to_public,
environments: {
environment: endpoint?.image_object?.name,
version: `${endpoint?.image_object?.registry}/${endpoint?.image_object?.name}:${endpoint?.image_object?.tag}@${endpoint?.image_object?.architecture}`,
environment:
endpoint?.image_object?.namespace ?? endpoint?.image_object?.name,
version: `${endpoint?.image_object?.registry}/${endpoint?.image_object?.namespace ?? endpoint?.image_object?.name}:${endpoint?.image_object?.tag}@${endpoint?.image_object?.architecture}`,
image: endpoint?.image_object,
},
vFolderID: endpoint?.model,
Expand Down
2 changes: 1 addition & 1 deletion react/src/components/ServiceValidationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ServiceValidationView: React.FC<ServiceValidationModalProps> = ({
ServiceLauncherFormValue
>({
mutationFn: (values) => {
const image: string = `${values.environments.image?.registry}/${values.environments.image?.name}:${values.environments.image?.tag}`;
const image: string = `${values.environments.image?.registry}/${values.environments.image?.namespace ?? values.environments.image?.name}:${values.environments.image?.tag}`;
const body: ServiceCreateType = {
name: values.serviceName,
...(baiClient.supports('replicas')
Expand Down
12 changes: 6 additions & 6 deletions react/src/pages/EndpointDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
image @deprecatedSince(version: "23.09.9")
image_object @since(version: "23.09.9") {
name
namespace @since(version: "24.12.0")
humanized_name
tag
registry
Expand Down Expand Up @@ -268,11 +269,10 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
return color;
};

const fullImageString: string = (
baiClient.supports('modify-endpoint')
? `${endpoint?.image_object?.registry}/${endpoint?.image_object?.name}:${endpoint?.image_object?.tag}@${endpoint?.image_object?.architecture}`
: endpoint?.image
) as string;
const fullImageString =
baiClient.supports('modify-endpoint') && endpoint?.image_object
? `${endpoint.image_object.registry}/${endpoint.image_object.namespace ?? endpoint.image_object.name}:${endpoint.image_object.tag}@${endpoint.image_object.architecture}`
: endpoint?.image;

const resource_opts = JSON.parse(endpoint?.resource_opts || '{}');

Expand Down Expand Up @@ -420,7 +420,7 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
? endpoint?.image_object
: endpoint?.image) && (
<Flex direction="row" gap={'xs'}>
<ImageMetaIcon image={fullImageString} />
<ImageMetaIcon image={fullImageString || null} />
<CopyableCodeText>{fullImageString}</CopyableCodeText>
{endpoint?.runtime_variant?.human_readable_name ? (
<Tag>{endpoint?.runtime_variant?.human_readable_name}</Tag>
Expand Down
10 changes: 8 additions & 2 deletions src/components/backend-ai-data-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default class BackendAIData extends BackendAIPage {
@property({ type: Object }) options;
@property({ type: Number }) capacity;
@property({ type: String }) cloneFolderName = '';
@property({ type: String }) cloneFolder = '';
@property({ type: Object }) storageProxyInfo = Object();
@property({ type: String }) folderType = 'user';
@property({ type: Number }) currentGroupIdx = 0;
Expand Down Expand Up @@ -820,6 +821,11 @@ export default class BackendAIData extends BackendAIPage {
if (e.detail) {
const selectedItems = e.detail;
this.cloneFolderName = selectedItems.name;
this.cloneFolder = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? selectedItems.id
: selectedItems.name;
this._cloneFolderDialog();
}
});
Expand Down Expand Up @@ -1257,7 +1263,7 @@ export default class BackendAIData extends BackendAIPage {
}
cloneable = cloneableEl ? cloneableEl.selected : false;
this.cloneFolderNameInput.reportValidity();
if (this.cloneFolderNameInput.checkValidity()) {
if (this.cloneFolderNameInput.checkValidity() && this.cloneFolder) {
const input = {
cloneable: cloneable,
permission: permission,
Expand All @@ -1267,7 +1273,7 @@ export default class BackendAIData extends BackendAIPage {
};
const job = globalThis.backendaiclient.vfolder.clone(
input,
this.cloneFolderName,
this.cloneFolder,
);
job
.then(() => {
Expand Down
18 changes: 11 additions & 7 deletions src/components/backend-ai-folder-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
// [target vfolder information]
@property({ type: String }) vfolderID = '';
@property({ type: String }) vfolderName = '';
@property({ type: String }) vfolder = '';
@property({ type: Array }) vfolderFiles = [];
@property({ type: String }) vhost = '';
@property({ type: Boolean }) isWritable = false;
Expand Down Expand Up @@ -496,7 +497,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const path = this.breadcrumb.concat(fn).join('/');
const job = globalThis.backendaiclient.vfolder.request_download_token(
path,
this.vfolderName,
this.vfolder,
archive,
);
job
Expand Down Expand Up @@ -777,6 +778,9 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
return vfolder.id === this.vfolderID;
});
this.vfolderName = vfolder.name;
this.vfolder = globalThis.backendaiclient.supports('vfolder-id-based')
? vfolder.id
: vfolder.name;
this.vhost = vfolder.host;
this.isWritable = vfolder.permission.includes('w');

Expand All @@ -791,7 +795,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
this.fileListGrid.selectedItems = [];
const filesInfo = await globalThis.backendaiclient.vfolder.list_files(
this.breadcrumb.join('/'),
this.vfolderName,
this.vfolder,
);

const details = filesInfo.items;
Expand Down Expand Up @@ -968,7 +972,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.rename_file(
path,
newName,
this.vfolderName,
this.vfolder,
this.is_dir,
);
job
Expand Down Expand Up @@ -1034,7 +1038,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.delete_files(
filenames,
true,
this.vfolderName,
this.vfolder,
);
job.then((res) => {
this.notification.text =
Expand All @@ -1054,7 +1058,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.delete_files(
[path],
true,
this.vfolderName,
this.vfolder,
);
job
.then((res) => {
Expand Down Expand Up @@ -1121,7 +1125,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
this.mkdirNameInput.reportValidity();
if (this.mkdirNameInput.checkValidity()) {
const job = globalThis.backendaiclient.vfolder
.mkdir([...this.breadcrumb, newfolder].join('/'), this.vfolderName)
.mkdir([...this.breadcrumb, newfolder].join('/'), this.vfolder)
.catch((err) => {
if (err & err.message) {
this.notification.text = PainKiller.relieve(err.title);
Expand Down Expand Up @@ -1290,7 +1294,7 @@ export default class BackendAIFolderExplorer extends BackendAIPage {
const job = globalThis.backendaiclient.vfolder.create_upload_session(
path,
fileObj,
this.vfolderName,
this.vfolder,
);
job.then((url) => {
const start_date = new Date().getTime();
Expand Down
24 changes: 20 additions & 4 deletions src/components/backend-ai-storage-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default class BackendAiStorageList extends BackendAIPage {
@property({ type: Boolean }) enableVfolderTrashBin = false;
@property({ type: Boolean }) authenticated = false;
@property({ type: String }) renameFolderName = '';
@property({ type: String }) renameFolderID = '';
@property({ type: String }) deleteFolderName = '';
@property({ type: String }) deleteFolderID = '';
@property({ type: String }) leaveFolderName = '';
Expand Down Expand Up @@ -1932,8 +1933,10 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the info icon button
* */
_infoFolder(e) {
const folderName = this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(folderName);
const folder = globalThis.backendaiclient.supports('vfolder-id-based')
? this._getControlID(e)
: this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(folder);
job
.then((value) => {
this.folderInfo = value;
Expand All @@ -1955,7 +1958,10 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the settings icon button
* */
_modifyFolderOptionDialog(e) {
globalThis.backendaiclient.vfolder.name = this._getControlName(e);
globalThis.backendaiclient.vfolder.name =
globalThis.backendaiclient.supports('vfolder-id-based')
? this._getControlID(e)
: this._getControlName(e);
const job = globalThis.backendaiclient.vfolder.info(
globalThis.backendaiclient.vfolder.name,
);
Expand Down Expand Up @@ -2075,6 +2081,7 @@ export default class BackendAiStorageList extends BackendAIPage {
*/
async _updateFolderName() {
globalThis.backendaiclient.vfolder.name = this.renameFolderName;
globalThis.backendaiclient.vfolder.id = this.renameFolderID;
const newName = this.newFolderNameInput.value;
this.newFolderNameInput.reportValidity();
if (newName) {
Expand All @@ -2101,6 +2108,11 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the
*/
_renameFolderDialog(e) {
this.renameFolderID = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? this._getControlID(e)
: this._getControlName(e);
this.renameFolderName = this._getControlName(e);
this.newFolderNameInput.value = '';
this.openDialog('modify-folder-name-dialog');
Expand Down Expand Up @@ -2427,7 +2439,11 @@ export default class BackendAiStorageList extends BackendAIPage {
* @param {Event} e - click the share button
* */
_shareFolderDialog(e) {
this.selectedFolder = this._getControlName(e);
this.selectedFolder = globalThis.backendaiclient.supports(
'vfolder-id-based',
)
? this._getControlID(e)
: this._getControlName(e);
this.selectedFolderType = this._getControlType(e);
this._initializeSharingFolderDialogLayout();
this.openDialog('share-folder-dialog');
Expand Down
7 changes: 4 additions & 3 deletions src/components/backend-ai-summary-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ export default class BackendAISummary extends BackendAIPage {
}
try {
await globalThis.backendaiclient.vfolder.accept_invitation(invitation.id);
const vfolderInfo = await globalThis.backendaiclient.vfolder.info(
invitation.vfolder_name,
);
const folder = globalThis.backendaiclient.supports('vfolder-id-based')
? invitation.vfolder_id
: invitation.vfolder_name;
const vfolderInfo = await globalThis.backendaiclient.vfolder.info(folder);
const tabName = BackendAISummary.getVFolderTabByVFolderInfo(vfolderInfo);
this.notification.url = `/data?tab=${tabName}&folder=${invitation.vfolder_id.replace('-', '')}`;
this.notification.text =
Expand Down
10 changes: 8 additions & 2 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ class Client {
this._features['max_network_count'] = true;
this._features['replicas'] = true;
}
if (this.isManagerVersionCompatibleWith(['25.1.0', '24.09.6', '24.03.12'])) {
this._features['vfolder-id-based'] = true;
}
}

/**
Expand Down Expand Up @@ -2079,6 +2082,7 @@ class ResourcePreset {
class VFolder {
public client: any;
public name: any;
public id: any;
public urlPrefix: any;

/**
Expand All @@ -2087,9 +2091,10 @@ class VFolder {
* @param {Client} client - the Client API wrapper object to bind
* @param {string} name - Virtual folder name.
*/
constructor(client, name = null) {
constructor(client, name = null, id = null) {
this.client = client;
this.name = name;
this.id = id;
this.urlPrefix = '/folders';
}

Expand Down Expand Up @@ -2259,9 +2264,10 @@ class VFolder {
*/
async rename(new_name = null): Promise<any> {
const body = { new_name };
const vfolder = this.client.supports('vfolder-id-based') ? this.id : this.name;
let rqst = this.client.newSignedRequest(
'POST',
`${this.urlPrefix}/${this.name}/rename`,
`${this.urlPrefix}/${vfolder}/rename`,
body,
);
return this.client._wrapWithPromise(rqst);
Expand Down
5 changes: 5 additions & 0 deletions src/lib/pep440.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,10 @@ describe('isCompatibleMultipleConditions', ()=>{
expect(isCompatibleMultipleConditions('23.03.3', ['24.3.1', '23.03.4'])).toBe(false)
expect(isCompatibleMultipleConditions('25.03.3', ['24.3.1', '23.03.4'])).toBe(true)
expect(isCompatibleMultipleConditions('22.03.3', ['24.3.1', '23.03.4'])).toBe(false)
expect(isCompatibleMultipleConditions('24.12.1', ['25.1.0', '24.09.6', '24.03.12'])).toBe(false)
expect(isCompatibleMultipleConditions('25.1.1', ['25.1.0', '24.09.6', '24.03.12'])).toBe(true)
expect(isCompatibleMultipleConditions('25.0.0', ['25.1.0', '24.09.6', '24.03.12'])).toBe(false)
expect(isCompatibleMultipleConditions('24.09.5', ['25.1.0', '24.09.6', '24.03.12'])).toBe(false)
expect(isCompatibleMultipleConditions('24.09.7', ['25.1.0', '24.09.6', '24.03.12'])).toBe(true)
});
})

0 comments on commit 4e6cced

Please sign in to comment.