Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: send override fields #19

Merged
merged 32 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8fc975f
feat: add optional parameter to send changes on convert
madcampos Dec 17, 2024
cfcd375
fix: rename variable
madcampos Dec 17, 2024
682b813
feat: send changes on convert request
madcampos Dec 17, 2024
8eac839
fix: remove unused references to pane
madcampos Dec 17, 2024
ac43d5a
fix: remove cleanup of changes
madcampos Dec 17, 2024
b8fd98f
feat: add changes to execute command
madcampos Dec 17, 2024
eb3308b
chore: rebuild the project
madcampos Dec 17, 2024
a8a9943
fix: remove changes from convert command
madcampos Dec 18, 2024
a454d9a
feat: add code to remove previous perf data
madcampos Dec 18, 2024
89bec58
feat: readd part to delete overrides after an execute
madcampos Dec 18, 2024
8ec112e
chore: rebuild the project
madcampos Dec 18, 2024
5bd5fd1
fix: remove leftover properties
madcampos Dec 19, 2024
366d4dc
fix: rename changes to overrides
madcampos Dec 19, 2024
8db1eae
feat: add graph overlays and overrides properties
madcampos Dec 19, 2024
82879d3
feat: update format for overrides
madcampos Dec 19, 2024
f0256d4
fix: use separator to split text for grid editable attribute
madcampos Dec 19, 2024
06735dc
chore: add TODO for overrides and overlays
madcampos Dec 19, 2024
1107201
chore: rebuild the project
madcampos Dec 19, 2024
f86172e
fix: add missing separator for grid attributes
madcampos Dec 20, 2024
a8fb95c
chore: remove optimization policy mock
madcampos Dec 20, 2024
1998349
chore: remove most mocks
madcampos Dec 20, 2024
cc339ab
chore: rebuild the project
madcampos Dec 20, 2024
d4216f3
fix: use correct types for overrides
madcampos Dec 20, 2024
7361bca
feat: add overrides and overlays processing
madcampos Dec 20, 2024
4ffe3f0
chore: rebuild the project
madcampos Dec 20, 2024
09f7762
fix: add missing parameter to function to split grid text
madcampos Jan 7, 2025
fa5ed9a
fix: simplify logic for grid editable attribute
madcampos Jan 7, 2025
d671e5c
chore: update mock to make attributes with "grid" and "shape" in thei…
madcampos Jan 7, 2025
b726aa9
feat: rename "separator" to "visual_separator" to enforce it is only …
madcampos Jan 7, 2025
50f9ac7
chore: rebuild the project
madcampos Jan 7, 2025
5a402f8
Merge branch 'main' into fix/send-override-fields
madcampos Jan 9, 2025
5a3e9e9
chore: rebuild the project
madcampos Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/package/src/model_explorer/web_app/index.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions src/ui/src/common/extension_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/

import {Graph, GraphCollection,} from '../components/visualizer/common/input_graph';
import type { NodeDataProviderData } from '../components/visualizer/common/types';
import type { ChangesPerNode } from './model_loader_service_interface';
import type { OverridesPerNode } from './model_loader_service_interface';

/** A command sent to extension. */
export declare interface ExtensionCommand {
Expand Down Expand Up @@ -58,8 +57,6 @@ export declare interface AdapterConvertCommand extends ExtensionCommand {
settings: Record<string, any>;
// Whether to delete the model file at `modelPath` after conversion is done.
deleteAfterConversion: boolean;
perf_trace?: string;
perf_data?: NodeDataProviderData;
}

/** Adapter's "convert" command response. */
Expand All @@ -70,7 +67,7 @@ export declare interface AdapterOverrideCommand extends ExtensionCommand {
cmdId: 'override';
settings: {
graphs: Graph[];
changes: ChangesPerNode;
overrides: OverridesPerNode;
};
}

Expand Down
12 changes: 6 additions & 6 deletions src/ui/src/common/model_loader_service_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ import type { KeyValue } from '../components/visualizer/common/types';
import {ModelItem} from './types';
import type { AdapterStatusCheckResults } from './extension_command';

export type ChangesPerNode = Record<string, KeyValue[]>;
export type ChangesPerGraphAndNode = Record<string, ChangesPerNode>;
export type OverridesPerNode = Record<string, { named_location: string, attributes: KeyValue[] }>;
export type OverridesPerGraphAndNode = Record<string, OverridesPerNode>;

/** The interface of model load service. */
export interface ModelLoaderServiceInterface {
loadModels(modelItems: ModelItem[]): Promise<void>;
loadModel(modelItems: ModelItem): Promise<GraphCollection[]>;
executeModel(modelItem: ModelItem): Promise<boolean>;
executeModel(modelItem: ModelItem, overrides?: OverridesPerNode): Promise<boolean>;
checkExecutionStatus(modelItem: ModelItem, modelPath: string): Promise<AdapterStatusCheckResults>;
overrideModel(modelItem: ModelItem, graphCollection: GraphCollection, fieldsToUpdate: ChangesPerNode): Promise<boolean>;
overrideModel(modelItem: ModelItem, graphCollection: GraphCollection, fieldsToUpdate: OverridesPerNode): Promise<boolean>;
get loadedGraphCollections(): WritableSignal<GraphCollection[] | undefined>;
get models(): WritableSignal<ModelItem[]>;
get changesToUpload(): WritableSignal<ChangesPerGraphAndNode>;
get overrides(): WritableSignal<OverridesPerGraphAndNode>;
getOptimizationPolicies(extensionId: string): string[];
get selectedOptimizationPolicy(): WritableSignal<string>;
get graphErrors(): WritableSignal<string[] | undefined>;
get hasChangesToUpload(): boolean;
get hasOverrides(): boolean;
}
7 changes: 6 additions & 1 deletion src/ui/src/components/visualizer/common/input_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* ==============================================================================
*/

import type { OverridesPerNode } from '../../../common/model_loader_service_interface.js';
import {
GraphNodeConfig,
GraphNodeStyle,
Expand Down Expand Up @@ -90,7 +91,11 @@ export declare interface Graph {

// The level in the graph tree.
level?: number;
/** @deprecated Remove after we merge the changes that use only `overlays` */
perf_data?: NodeDataProviderData;
overlays?: Record<string, NodeDataProviderData>;
overrides?: OverridesPerNode;

}

/** A single node in the graph. */
Expand Down Expand Up @@ -170,7 +175,7 @@ export interface EditableValueListAttribute {

export interface EditableGridAttribute {
input_type: 'grid';
separator?: string;
visual_separator?: string;
min_value: number;
max_value: number;
step: number;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/components/visualizer/expandable_info_text.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
[max]="$any(editable)?.max_value ?? 100"
(change)="handleTextChange($event)"
/>
<span class="text-separator">&nbsp;{{$any(editable)?.separator ?? 'x'}}&nbsp;</span>
<span class="text-separator">&nbsp;{{$any(editable)?.visual_separator ?? 'x'}}&nbsp;</span>
}
} @else {
{{text}}
Expand Down Expand Up @@ -131,7 +131,7 @@
[max]="$any(editable)?.max_value ?? 100"
(change)="handleTextChange($event)"
/>
<span class="text-separator">&nbsp;{{$any(editable)?.separator ?? 'x'}}&nbsp;</span>
<span class="text-separator">&nbsp;{{$any(editable)?.visual_separator ?? 'x'}}&nbsp;</span>
}
} @else {
{{text}}
Expand Down
35 changes: 23 additions & 12 deletions src/ui/src/components/visualizer/expandable_info_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {MatTooltipModule} from '@angular/material/tooltip';
import {AppService} from './app_service';
import { ModelLoaderServiceInterface } from '../../common/model_loader_service_interface';
import type { EditableAttributeTypes, EditableValueListAttribute } from './common/input_graph';
import type { OpNode } from './common/model_graph.js';

/** Expandable info text component. */
@Component({
Expand Down Expand Up @@ -87,8 +88,9 @@ export class ExpandableInfoText implements AfterViewInit, OnDestroy, OnChanges {
}

this.text = this.modelLoaderService
.changesToUpload()[this.collectionLabel ?? '']
.overrides()[this.collectionLabel ?? '']
?.[this.nodeId]
?.attributes
?.find(({ key }) => key === this.type)
?.value ?? this.text;
}
Expand Down Expand Up @@ -145,29 +147,38 @@ export class ExpandableInfoText implements AfterViewInit, OnDestroy, OnChanges {
}).join(', ')}]`;
}

const collectionLabel = this.appService.getSelectedPane()?.modelGraph?.collectionLabel;
const nodeId = this.appService.getSelectedPane()?.selectedNodeInfo?.nodeId;
const modelGraph = this.appService.getSelectedPane()?.modelGraph;
const nodeId = this.appService.getSelectedPane()?.selectedNodeInfo?.nodeId ?? '';
const [, namedLocation] = Object.entries((modelGraph?.nodesById?.[nodeId] as OpNode | undefined)?.attrs ?? {}).find(([key]) => key === 'named_location') ?? [];

this.modelLoaderService.changesToUpload.update((changesToUpload) => {
if (collectionLabel && nodeId) {
changesToUpload[collectionLabel] = {...changesToUpload[collectionLabel] };
this.modelLoaderService.overrides.update((overrides) => {
if (modelGraph?.collectionLabel && nodeId) {
overrides[modelGraph.collectionLabel] = {...overrides[modelGraph.collectionLabel] };

const existingChanges = changesToUpload[collectionLabel][nodeId]?.findIndex(({ key }) => key === this.type) ?? -1;

if (existingChanges !== -1) {
changesToUpload[collectionLabel][nodeId].splice(existingChanges, 1);
if (!overrides[modelGraph.collectionLabel][nodeId]) {
overrides[modelGraph.collectionLabel][nodeId] = {
named_location: namedLocation ?? nodeId,
attributes: []
};
}

changesToUpload[collectionLabel][nodeId] = [
...(changesToUpload[collectionLabel][nodeId] ?? []),
const existingOverrides = overrides[modelGraph.collectionLabel][nodeId].attributes.findIndex(({ key }) => key === this.type) ?? -1;

if (existingOverrides !== -1) {
overrides[modelGraph.collectionLabel][nodeId].attributes.splice(existingOverrides, 1);
}

overrides[modelGraph.collectionLabel][nodeId].attributes = [
...(overrides[modelGraph.collectionLabel][nodeId].attributes ?? []),
{
key: this.type,
value: updatedValue
}
];
}

return changesToUpload;
return overrides;
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/src/components/visualizer/graph_edit.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@if (hasCurModel) {
<div class="mat-icon-container">
<button mat-icon-button matTooltip="Upload processed graphs json to server" (click)="handleClickUploadGraph()" [disabled]="!hasChangesToUpload || isProcessingExecuteRequest">
<button mat-icon-button matTooltip="Upload processed graphs json to server" (click)="handleClickUploadGraph()" [disabled]="!hasOverrides || isProcessingExecuteRequest">
<mat-icon>upload</mat-icon>
</button>
</div>
Expand All @@ -24,7 +24,7 @@
mat-icon-button
matTooltip="Execute graph"
(click)="handleClickExecuteGraph()"
[disabled]="isProcessingExecuteRequest && !hasChangesToUpload && !graphHasErrors"
[disabled]="isProcessingExecuteRequest && !hasOverrides && !graphHasErrors"
[ngStyle]="{ display: !isProcessingExecuteRequest ? 'block' : 'none' }"
>
<mat-icon>play_arrow</mat-icon>
Expand Down
Loading
Loading