forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add stream feature view in the Web UI (feast-dev#3257)
* add stream feature view to ui Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * update source Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * update example Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * add registry Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * fix lint Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * fix bug Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * add batch source Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> * fix warning Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com> Signed-off-by: hao-affirm <104030690+hao-affirm@users.noreply.github.com>
- Loading branch information
1 parent
532d8a1
commit 1f70b3a
Showing
16 changed files
with
625 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from "react"; | ||
|
||
import { | ||
// Feature View Custom Tabs will get these props | ||
StreamFeatureViewCustomTabProps, | ||
} from "../types"; | ||
|
||
import { | ||
EuiLoadingContent, | ||
EuiEmptyPrompt, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiCode, | ||
EuiSpacer, | ||
} from "@elastic/eui"; | ||
|
||
// Separating out the query is not required, | ||
// but encouraged for code readability | ||
import useDemoQuery from "./useDemoQuery"; | ||
|
||
const DemoCustomTab = ({ | ||
id, | ||
feastObjectQuery, | ||
}: StreamFeatureViewCustomTabProps) => { | ||
// Use React Query to fetch data | ||
// that is custom to this tab. | ||
// See: https://react-query.tanstack.com/guides/queries | ||
const { isLoading, isError, isSuccess, data } = useDemoQuery({ | ||
featureView: id, | ||
}); | ||
|
||
if (isLoading) { | ||
// Handle Loading State | ||
// https://elastic.github.io/eui/#/display/loading | ||
return <EuiLoadingContent lines={3} />; | ||
} | ||
|
||
if (isError) { | ||
// Handle Data Fetching Error | ||
// https://elastic.github.io/eui/#/display/empty-prompt | ||
return ( | ||
<EuiEmptyPrompt | ||
iconType="alert" | ||
color="danger" | ||
title={<h2>Unable to load your demo page</h2>} | ||
body={ | ||
<p> | ||
There was an error loading the Dashboard application. Contact your | ||
administrator for help. | ||
</p> | ||
} | ||
/> | ||
); | ||
} | ||
|
||
// Feast UI uses the Elastic UI component system. | ||
// <EuiFlexGroup> and <EuiFlexItem> are particularly | ||
// useful for layouts. | ||
return ( | ||
<React.Fragment> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={1}> | ||
<p>Hello World. The following is fetched data.</p> | ||
<EuiSpacer /> | ||
{isSuccess && data && ( | ||
<EuiCode> | ||
<pre>{JSON.stringify(data, null, 2)}</pre> | ||
</EuiCode> | ||
)} | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={2}> | ||
<p>... and this is data from Feast UI’s own query.</p> | ||
<EuiSpacer /> | ||
{feastObjectQuery.isSuccess && feastObjectQuery.data && ( | ||
<EuiCode> | ||
<pre>{JSON.stringify(feastObjectQuery.data, null, 2)}</pre> | ||
</EuiCode> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default DemoCustomTab; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useQuery } from "react-query"; | ||
import { z } from "zod"; | ||
|
||
// Use Zod to check the shape of the | ||
// json object being loaded | ||
const demoSchema = z.object({ | ||
hello: z.string(), | ||
name: z.string().optional(), | ||
}); | ||
|
||
// Make the type of the object available | ||
type DemoDataType = z.infer<typeof demoSchema>; | ||
|
||
interface DemoQueryInterface { | ||
featureView: string | undefined; | ||
} | ||
|
||
const useDemoQuery = ({ featureView }: DemoQueryInterface) => { | ||
// React Query manages caching for you based on query keys | ||
// See: https://react-query.tanstack.com/guides/query-keys | ||
const queryKey = `demo-tab-namespace:${featureView}`; | ||
|
||
// Pass the type to useQuery | ||
// so that components consuming the | ||
// result gets nice type hints | ||
// on the other side. | ||
return useQuery<DemoDataType>( | ||
queryKey, | ||
() => { | ||
// Customizing the URL based on your needs | ||
const url = `/demo-custom-tabs/demo.json`; | ||
|
||
return fetch(url) | ||
.then((res) => res.json()) | ||
.then((data) => demoSchema.parse(data)); // Use zod to parse results | ||
}, | ||
{ | ||
enabled: !!featureView, // Only start the query when the variable is not undefined | ||
} | ||
); | ||
}; | ||
|
||
export default useDemoQuery; | ||
export type { DemoDataType }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.