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

Habitat handle no supported gpu #48

Merged
merged 3 commits into from
Mar 23, 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 skyline-vscode/react-ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ function App() {
if (event.data["message_type"] === "connection") {
setConnectionStatus(event.data["status"]);
} else if (event.data["message_type"] === "analysis") {
if(event.data.habitat[0][0]==="unavailable" && event.data.habitat[0][1]===-1.0){
event.data.habitat = profiling_data.habitat
event.data.habitat.push(["demo",1])
}
processAnalysisState(event.data);
} else if (event.data["message_type"] === "text_change") {
setTextChanged(true);
Expand Down
20 changes: 20 additions & 0 deletions skyline-vscode/react-ui/src/sections/Habitat.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ import Card from "react-bootstrap/Card";
import { HabitatScatterGraph } from "../components/ScatterGraph";

export default function Habitat({ habitatData }) {
const habitatIsDemo = habitatData.find(
(item) => item[0] === "demo" && item[1] === 1
);
if (habitatIsDemo) {
return (
<>
<div className="innpv-memory innpv-subpanel">
<Subheader icon="database">Habitat</Subheader>
<div className="innpv-subpanel-content">
<Container fluid className="mt-2">
<Row className="justify-content-md-center">
<h6>The local GPU is not supported by Habitat</h6>
</Row>
</Container>
</div>
</div>
</>
);
}

return (
<>
<div className="innpv-memory innpv-subpanel">
Expand Down
23 changes: 23 additions & 0 deletions skyline-vscode/react-ui/src/sections/Habitat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ const data = [
["RTX4000", 20.2342],
];

const noHabitatData = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

["source", 22.029312],
["P100",14.069682],
["P4000", 127.268085], // 27.268085
["RTX2070", 16.088268],
["RTX2080Ti", 11.826558],
["T4", 22.029312],
["V100", 10.182922],
["A100", 10.068596],
["RTX3090", 9.841998],
["A40", 11.558072],
["A4000", 14.67059],
["RTX4000", 20.2342],
["demo",1]
]

beforeEach(() => {
delete window.ResizeObserver;
window.ResizeObserver = jest.fn().mockImplementation(() => ({
Expand Down Expand Up @@ -61,3 +77,10 @@ test("Shows graph when habitat data is present", () => {
expect(container.querySelector('.recharts-responsive-container')).toBeTruthy(); // eslint-disable-line

});

test("no habitat data received from backend", ()=>{
// ARRANGE
const { container } = render(<Habitat habitatData={noHabitatData}/>);
// ASSERT
expect(screen.getByText(/the local gpu is not supported by habitat/i)).toBeTruthy();
})
8 changes: 8 additions & 0 deletions skyline-vscode/react-ui/src/sections/ProviderPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Col from "react-bootstrap/Col";
import Image from "react-bootstrap/Image";
import Table from "react-bootstrap/Table";
import Form from "react-bootstrap/Form";
import Alert from 'react-bootstrap/Alert';

import {
cloudInstances,
Expand Down Expand Up @@ -68,6 +69,8 @@ const ProviderPanel = ({ numIterations, habitatData }) => {
estimated_time: 0,
});

const habitatIsDemo = habitatData.find(item=>item[0]==="demo" && item[1] === 1)

const MAX_GPU = [1, 2, 4, 0]; // 0 is all

const initial_data = populate_initial_data(habitatData);
Expand Down Expand Up @@ -175,6 +178,11 @@ const ProviderPanel = ({ numIterations, habitatData }) => {
<div className="innpv-memory innpv-subpanel">
<Subheader icon="database">Providers</Subheader>
<Container fluid>
{habitatIsDemo && (
<Row>
<Alert variant="danger">Currently showing a demo data because local GPU is not supported by Habitat</Alert>
</Row>
)}
<Row>
<Col xl={12} xxl={8}>
<Row>
Expand Down
23 changes: 23 additions & 0 deletions skyline-vscode/react-ui/src/sections/ProviderPanel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ const data = [
["RTX4000", 20.2342],
];

const noHabitatData = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

["source", 22.029312],
["P100",14.069682],
["P4000", 127.268085], // 27.268085
["RTX2070", 16.088268],
["RTX2080Ti", 11.826558],
["T4", 22.029312],
["V100", 10.182922],
["A100", 10.068596],
["RTX3090", 9.841998],
["A40", 11.558072],
["A4000", 14.67059],
["RTX4000", 20.2342],
["demo",1]
];

beforeEach(() => {
delete window.ResizeObserver;
window.ResizeObserver = jest.fn().mockImplementation(() => ({
Expand Down Expand Up @@ -62,3 +78,10 @@ test("Shows a scatter chart", () => {
).toBeTruthy();
expect(screen.getByText(/select a configuration/i)).toBeTruthy();
});

test("no habitat data received from backend", ()=>{
// ARRANGE
const { container } = render(<ProviderPanel numIterations={numIterations} habitatData={noHabitatData} />);
// ASSERT
expect(screen.getByText(/currently showing a demo data because local gpu is not supported by habitat/i)).toBeTruthy();
})