Skip to content

Commit

Permalink
Internal cleanup
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 678786345
  • Loading branch information
Google AI Edge authored and copybara-github committed Sep 25, 2024
1 parent 154b960 commit fcbf075
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/ui/src/common/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@

/** Prefix for graphs json model sources. */
export const GRAPHS_MODEL_SOURCE_PREFIX = 'graphs://';

/** Prefix for data nexus model sources. */
export const DATA_NEXUS_MODEL_SOURCE_PREFIX = 'data-nexus://';
4 changes: 4 additions & 0 deletions src/ui/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum InternalAdapterExtId {
GRAPHDEF = 'builtin_graphdef',
MLIR = 'builtin_mlir',
JSON_LOADER = 'builtin_json',
DATA_NEXUS = 'builtin_data_nexus',
}

/** Extension types. */
Expand Down Expand Up @@ -87,6 +88,9 @@ export enum ModelItemType {
// Remote path/url.
REMOTE = 'remote',

// Data nexus models.
DATA_NEXUS = 'data_nexus',

// External only
//
// Graphs json specified when starting server.
Expand Down
20 changes: 19 additions & 1 deletion src/ui/src/components/model_source_input/model_source_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {MatSelectModule} from '@angular/material/select';
import {MatTooltipModule} from '@angular/material/tooltip';

import {GRAPHS_MODEL_SOURCE_PREFIX} from '../../common/consts';
import {
DATA_NEXUS_MODEL_SOURCE_PREFIX,
GRAPHS_MODEL_SOURCE_PREFIX,
} from '../../common/consts';
import {IS_EXTERNAL} from '../../common/flags';
import {type ModelLoaderServiceInterface} from '../../common/model_loader_service_interface';
import {
Expand Down Expand Up @@ -184,6 +187,21 @@ export class ModelSourceInput {
selectedAdapter: ext,
};
}
// Data nexus model source.
else if (modelSource.url.startsWith(DATA_NEXUS_MODEL_SOURCE_PREFIX)) {
const ext = this.adapterExtensionService.getExtensionById(
InternalAdapterExtId.DATA_NEXUS,
);
const adapterCandidates = ext == null ? [] : [ext];
return {
path: modelSource.url,
type: ModelItemType.DATA_NEXUS,
status: signal<ModelItemStatus>(ModelItemStatus.NOT_STARTED),
selected: true,
adapterCandidates,
selectedAdapter: ext,
};
}
// Other typical use cases.
else {
const adapterCandidates = getAdapterCandidates(
Expand Down
8 changes: 8 additions & 0 deletions src/ui/src/services/internal_adapter_extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ const jsonAdapterExtension: AdapterExtension = {
description:
'Loads JSON graphs data file or tfjs model from the given url or uploaded file and convert them to Model Explorer format.',
};
const dataNexusAdapterExtension: AdapterExtension = {
type: ExtensionType.ADAPTER,
fileExts: ['data_nexus'],
id: InternalAdapterExtId.DATA_NEXUS,
name: 'Data Nexus adapter',
description: 'Loads data from Data Nexus.',
};

/** All internal extensions. */
export const INTERNAL_ADAPTER_EXTENSIONS: AdapterExtension[] = [
Expand All @@ -91,4 +98,5 @@ export const INTERNAL_ADAPTER_EXTENSIONS: AdapterExtension[] = [
graphdefAdapterExtension,
mlirAdapterExtension,
jsonAdapterExtension,
dataNexusAdapterExtension,
];

0 comments on commit fcbf075

Please sign in to comment.