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

Updated internal workloads loading to allow support for suites. #11

Merged
merged 1 commit into from
Feb 28, 2024
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
16 changes: 8 additions & 8 deletions __mocks__/resources-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -126,7 +126,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -154,7 +154,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -182,7 +182,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -210,7 +210,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -238,7 +238,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -266,7 +266,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -294,7 +294,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/resourceMetadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('MetaData component', () => {
"resource_version": "1.0.0",
"database": "db1",
"license": "MIT",
"workloads": [
"workloads_mapping": [
"workload1",
"workload2"
],
Expand Down
14 changes: 7 additions & 7 deletions __tests__/pages/api/findresources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 2,
score: 21,
ver_latest: '23.0',
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 1,
score: 90,
ver_latest: '23.0',
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 2,
score: 21,
ver_latest: '23.0',
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 2,
score: 21,
ver_latest: '23.0',
Expand Down Expand Up @@ -359,7 +359,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 2,
score: 21,
ver_latest: '23.0',
Expand Down Expand Up @@ -418,7 +418,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 1,
score: 14,
ver_latest: '23.0',
Expand Down Expand Up @@ -454,7 +454,7 @@ describe('findResources', () => {
gem5_versions: ["23.0"],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
totalMatches: 1,
score: 7,
ver_latest: '23.0',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/pages/api/getTabs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("getTabs", () => {
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down
10 changes: 5 additions & 5 deletions __tests__/pages/api/getresource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ global.fetch = jest.fn((url) => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
}],
}),
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('getResource', () => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
})
});
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('getResource', () => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
})
});
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('getResource', () => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
})
});
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('getResource', () => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
})
});
Expand Down
4 changes: 2 additions & 2 deletions __tests__/pages/api/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down Expand Up @@ -73,7 +73,7 @@
],
"workload_name": "x86-print-this-15000-with-simpoints",
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
"workloads": [
"workloads_mapping": [
"x86-print-this-15000-with-simpoints",
"x86-print-this-15000-with-simpoints-and-checkpoint"
]
Expand Down
2 changes: 1 addition & 1 deletion __tests__/pages/resources/[id]/[[...page]].test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("Resource-specific component", () => {
gem5_versions: ['23.0'],
workload_name: 'x86-print-this-15000-with-simpoints',
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
workloads: [],
workloads_mapping: [],
database: 'db1'
}))
}))
Expand Down
6 changes: 3 additions & 3 deletions components/resourceMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,20 @@ export default function MetaData({ resource, className, metaFields, showMetadata
: null
}
{
(resource.workloads && resource.workloads.length > 0) ?
(resource.workloads_mapping && resource.workloads_mapping.length > 0) ?
<Row className="border-bottom">
<p className="text-muted main-text-regular">Depend on this resource</p>
<div className="main-text-regular">
{
resource.workloads.map((workload, index) => {
resource.workloads_mapping.map((workload, index) => {
return (
<span key={workload}>
<a
href={process.env.BASE_PATH + '/resources/' + workload + `?database=${resource.database}`}
>
{workload}
</a>
{index != resource.workloads.length - 1 ? ', ' : ''}
{index != resource.workloads_mapping.length - 1 ? ', ' : ''}
</span>
)
})
Expand Down
35 changes: 19 additions & 16 deletions components/resourceTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import rehypeHighlight from "rehype-highlight";
import rehypeSlug from "rehype-slug";
import rehypeRaw from "rehype-raw";
import remarkFrontmatter from "remark-frontmatter";
import CopyIcon from "./copyIcon";

export function createTab(tab) {
if (!"content" in tab) return null;
Expand All @@ -30,13 +31,15 @@ export function createTab(tab) {
content = String(tab.content);
break;
case "array":
content = tab.content.map((item, index) => {
return (
<div key={index}>
{item}
</div>
);
});
content = (
<CopyIcon>
<pre>
<code class="hljs language-python">
{JSON.stringify(tab.content, null, 4)}
</code>
</pre>
</CopyIcon>
);
break;
case "object":
content = Object.keys(tab.content).map((key, index) => {
Expand Down Expand Up @@ -131,15 +134,15 @@ export default function ResourceTab({ resource, requiredTabs, additionalInfoTabs
>
<Tab eventKey="readme" title="Readme">
<ReactMarkdown
className="markdown-body mt-3"
rehypePlugins={[
[rehypeHighlight, { ignoreMissing: true }],
rehypeRaw,
rehypeSlug,
]}
remarkPlugins={[remarkGfm, remarkToc, remarkFrontmatter]}
>
{resource.description ?? 'This is a description of the resource.'}
className="markdown-body mt-3"
rehypePlugins={[
[rehypeHighlight, { ignoreMissing: true }],
rehypeRaw,
rehypeSlug,
]}
remarkPlugins={[remarkGfm, remarkToc, remarkFrontmatter]}
>
{resource.description ?? 'This is a description of the resource.'}
</ReactMarkdown>
</Tab>
<Tab eventKey="changelog" title="Changelog">
Expand Down
2 changes: 1 addition & 1 deletion components/tabs/rawTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function RawTab({ resource }) {
resource = JSON.parse(JSON.stringify(resource));
delete resource.database
delete resource._id
delete resource.workloads
delete resource.workloads_mapping
textToHtml(JSON.stringify(resource, null, 4));
}, [resource]);
return (
Expand Down
9 changes: 9 additions & 0 deletions gem5.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@
}
},
"metadata": {}
},
"suite": {
"tab": {
"workloads": {
"displayName": "Workloads"
}
},
"additionalInfo": {},
"metadata": {}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pages/api/json/getResourceByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default async function getResourceByIDJSON(id, database, version) {
if (!resource) {
return { error: 'Resource not found' }
}
resource.workloads = workloads;
resource.workloads_mapping = workloads;
resource.database = database;
return resource;
}
2 changes: 1 addition & 1 deletion pages/api/mongodb/getResourceByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function getResourceByID(token, url, dataSource, database, collection, id,
})
}).catch(err => console.log(err));
let workloads = await dependendWorkloads.json();
resource.workloads = Object.values(workloads['documents']).map(workload => workload['_id']);
resource.workloads_mapping = Object.values(workloads['documents']).map(workload => workload['_id']);

return resource;
}
Expand Down
Loading