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: fetch instance view for report slices #360

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions backend/zeno_backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,10 @@ def get_charts_for_projects(req: list[str]):
def get_slices_for_projects(req: list[str]):
return select.slices_for_projects(req)

@api_app.post("/match-instance-view/", response_model=str, tags=["zeno"])
def match_instance_view(req: str):
return select.match_instance_view(req)

@api_app.post(
"/slice-metrics/{project}",
response_model=list[GroupMetric],
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/instances/ComparisonView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
</p>
<div class="instance">
<InstanceView
view={$project.view}
view={$project.view ?? ''}
{dataColumn}
{labelColumn}
modelColumn={modelAColumn?.id}
Expand All @@ -283,7 +283,7 @@
</p>
<div class="instance">
<InstanceView
view={$project.view}
view={$project.view ?? ''}
{dataColumn}
{labelColumn}
modelColumn={modelBColumn?.id}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/instances/ListView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{#each table as inst (inst[idColumn])}
<div class="mr-2 mt-2">
<InstanceView
view={$project.view}
view={$project.view ?? ''}
{dataColumn}
{labelColumn}
modelColumn={modelColumn?.id}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/instances/TableView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
{:else}
<div class="instance">
<InstanceView
view={$project.view}
view={$project.view ?? ''}
{dataColumn}
{labelColumn}
modelColumn={modelColumn?.id}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/project/Project.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
let showConfirmDelete = false;

function getProjectIcon() {
if (project.view.includes('image')) return mdiImage;
if (project.view.includes('chat') || project.view.includes('text')) return mdiText;
if (project.view?.includes('image')) return mdiImage;
if (project.view?.includes('chat') || project.view?.includes('text')) return mdiText;
else return mdiTag;
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/components/report/Element.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
</script>

{#if element.data !== null && element.data !== undefined}
{#if element.data !== null && element.data !== undefined && chartOptions.length > 0}
<div class="flex items-center my-2 ml-2" bind:clientWidth={width}>
{#if element.type === ReportElementType.TEXT}
<TextElement {element} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
let sliceElementOptions: SliceElementOptions | undefined;
let table: Record<string, string | number | boolean>[] | undefined = [];
let page = 0;
let view = '';

$: updateSliceElementSpec(element.data as string);

$: if (sliceElementSpec) {
$: if (sliceElementSpec && sliceElementOptions) {
zenoClient.matchInstanceView(sliceElementOptions.project.view ?? '').then((r) => (view = r));
zenoClient
.getSliceTable({
sliceId: sliceElementSpec.sliceId,
Expand Down Expand Up @@ -101,7 +103,7 @@
{#each table as inst (inst[sliceElementOptions.idColumn])}
<div class="m-auto mt-0">
<InstanceView
view={sliceElementOptions.project.view}
{view}
dataColumn={sliceElementOptions.dataColumn}
modelColumn={sliceElementOptions.modelColumn}
labelColumn={sliceElementOptions.labelColumn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export type Body_upload_dataset_schema = {
project_uuid: any;
id_column: any;
data_column: any;
data_column?: any;
label_column?: any;
file: Blob;
};
2 changes: 1 addition & 1 deletion frontend/src/lib/zenoapi/models/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type Project = {
description?: string;
metrics?: Array<Metric>;
ownerName: string;
view: string;
view?: string;
editor: boolean;
samplesPerPage?: number;
public?: boolean;
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/lib/zenoapi/services/ZenoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,25 @@ export class ZenoService {
});
}

/**
* Match Instance View
* @param req
* @returns string Successful Response
* @throws ApiError
*/
public matchInstanceView(req: string): CancelablePromise<string> {
return this.httpRequest.request({
method: 'POST',
url: '/match-instance-view/',
query: {
req: req
},
errors: {
422: `Validation Error`
}
});
}

/**
* Get Metrics For Slices
* @param project
Expand Down