Skip to content

Commit b8e5401

Browse files
Updated internal workloads loading to allow support for suites. Also updated how arrays are displayed.
1 parent 37f5589 commit b8e5401

File tree

13 files changed

+59
-47
lines changed

13 files changed

+59
-47
lines changed

__mocks__/resources-test.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
],
9999
"workload_name": "x86-print-this-15000-with-simpoints",
100100
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
101-
"workloads": [
101+
"workloads_mapping": [
102102
"x86-print-this-15000-with-simpoints",
103103
"x86-print-this-15000-with-simpoints-and-checkpoint"
104104
]
@@ -126,7 +126,7 @@
126126
],
127127
"workload_name": "x86-print-this-15000-with-simpoints",
128128
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
129-
"workloads": [
129+
"workloads_mapping": [
130130
"x86-print-this-15000-with-simpoints",
131131
"x86-print-this-15000-with-simpoints-and-checkpoint"
132132
]
@@ -154,7 +154,7 @@
154154
],
155155
"workload_name": "x86-print-this-15000-with-simpoints",
156156
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
157-
"workloads": [
157+
"workloads_mapping": [
158158
"x86-print-this-15000-with-simpoints",
159159
"x86-print-this-15000-with-simpoints-and-checkpoint"
160160
]
@@ -182,7 +182,7 @@
182182
],
183183
"workload_name": "x86-print-this-15000-with-simpoints",
184184
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
185-
"workloads": [
185+
"workloads_mapping": [
186186
"x86-print-this-15000-with-simpoints",
187187
"x86-print-this-15000-with-simpoints-and-checkpoint"
188188
]
@@ -210,7 +210,7 @@
210210
],
211211
"workload_name": "x86-print-this-15000-with-simpoints",
212212
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
213-
"workloads": [
213+
"workloads_mapping": [
214214
"x86-print-this-15000-with-simpoints",
215215
"x86-print-this-15000-with-simpoints-and-checkpoint"
216216
]
@@ -238,7 +238,7 @@
238238
],
239239
"workload_name": "x86-print-this-15000-with-simpoints",
240240
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
241-
"workloads": [
241+
"workloads_mapping": [
242242
"x86-print-this-15000-with-simpoints",
243243
"x86-print-this-15000-with-simpoints-and-checkpoint"
244244
]
@@ -266,7 +266,7 @@
266266
],
267267
"workload_name": "x86-print-this-15000-with-simpoints",
268268
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
269-
"workloads": [
269+
"workloads_mapping": [
270270
"x86-print-this-15000-with-simpoints",
271271
"x86-print-this-15000-with-simpoints-and-checkpoint"
272272
]
@@ -294,7 +294,7 @@
294294
],
295295
"workload_name": "x86-print-this-15000-with-simpoints",
296296
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
297-
"workloads": [
297+
"workloads_mapping": [
298298
"x86-print-this-15000-with-simpoints",
299299
"x86-print-this-15000-with-simpoints-and-checkpoint"
300300
]

__tests__/components/resourceMetadata.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('MetaData component', () => {
5050
"resource_version": "1.0.0",
5151
"database": "db1",
5252
"license": "MIT",
53-
"workloads": [
53+
"workloads_mapping": [
5454
"workload1",
5555
"workload2"
5656
],

__tests__/pages/api/findresources.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('findResources', () => {
7777
gem5_versions: ["23.0"],
7878
workload_name: 'x86-print-this-15000-with-simpoints',
7979
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
80-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
80+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
8181
totalMatches: 2,
8282
score: 21,
8383
ver_latest: '23.0',
@@ -208,7 +208,7 @@ describe('findResources', () => {
208208
gem5_versions: ["23.0"],
209209
workload_name: 'x86-print-this-15000-with-simpoints',
210210
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
211-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
211+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
212212
totalMatches: 1,
213213
score: 90,
214214
ver_latest: '23.0',
@@ -268,7 +268,7 @@ describe('findResources', () => {
268268
gem5_versions: ["23.0"],
269269
workload_name: 'x86-print-this-15000-with-simpoints',
270270
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
271-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
271+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
272272
totalMatches: 2,
273273
score: 21,
274274
ver_latest: '23.0',
@@ -325,7 +325,7 @@ describe('findResources', () => {
325325
gem5_versions: ["23.0"],
326326
workload_name: 'x86-print-this-15000-with-simpoints',
327327
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
328-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
328+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
329329
totalMatches: 2,
330330
score: 21,
331331
ver_latest: '23.0',
@@ -359,7 +359,7 @@ describe('findResources', () => {
359359
gem5_versions: ["23.0"],
360360
workload_name: 'x86-print-this-15000-with-simpoints',
361361
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
362-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
362+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
363363
totalMatches: 2,
364364
score: 21,
365365
ver_latest: '23.0',
@@ -418,7 +418,7 @@ describe('findResources', () => {
418418
gem5_versions: ["23.0"],
419419
workload_name: 'x86-print-this-15000-with-simpoints',
420420
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
421-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
421+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
422422
totalMatches: 1,
423423
score: 14,
424424
ver_latest: '23.0',
@@ -454,7 +454,7 @@ describe('findResources', () => {
454454
gem5_versions: ["23.0"],
455455
workload_name: 'x86-print-this-15000-with-simpoints',
456456
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
457-
workloads: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
457+
workloads_mapping: ["x86-print-this-15000-with-simpoints", "x86-print-this-15000-with-simpoints-and-checkpoint"],
458458
totalMatches: 1,
459459
score: 7,
460460
ver_latest: '23.0',

__tests__/pages/api/getTabs.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe("getTabs", () => {
8282
],
8383
"workload_name": "x86-print-this-15000-with-simpoints",
8484
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
85-
"workloads": [
85+
"workloads_mapping": [
8686
"x86-print-this-15000-with-simpoints",
8787
"x86-print-this-15000-with-simpoints-and-checkpoint"
8888
]

__tests__/pages/api/getresource.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ global.fetch = jest.fn((url) => {
2929
gem5_versions: ['23.0'],
3030
workload_name: 'x86-print-this-15000-with-simpoints',
3131
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
32-
workloads: [],
32+
workloads_mapping: [],
3333
database: 'db1'
3434
}],
3535
}),
@@ -102,7 +102,7 @@ describe('getResource', () => {
102102
gem5_versions: ['23.0'],
103103
workload_name: 'x86-print-this-15000-with-simpoints',
104104
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
105-
workloads: [],
105+
workloads_mapping: [],
106106
database: 'db1'
107107
})
108108
});
@@ -130,7 +130,7 @@ describe('getResource', () => {
130130
gem5_versions: ['23.0'],
131131
workload_name: 'x86-print-this-15000-with-simpoints',
132132
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
133-
workloads: [],
133+
workloads_mapping: [],
134134
database: 'db1'
135135
})
136136
});
@@ -173,7 +173,7 @@ describe('getResource', () => {
173173
gem5_versions: ['23.0'],
174174
workload_name: 'x86-print-this-15000-with-simpoints',
175175
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
176-
workloads: [],
176+
workloads_mapping: [],
177177
database: 'db1'
178178
})
179179
});
@@ -216,7 +216,7 @@ describe('getResource', () => {
216216
gem5_versions: ['23.0'],
217217
workload_name: 'x86-print-this-15000-with-simpoints',
218218
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
219-
workloads: [],
219+
workloads_mapping: [],
220220
database: 'db1'
221221
})
222222
});

__tests__/pages/api/resources.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
],
4646
"workload_name": "x86-print-this-15000-with-simpoints",
4747
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
48-
"workloads": [
48+
"workloads_mapping": [
4949
"x86-print-this-15000-with-simpoints",
5050
"x86-print-this-15000-with-simpoints-and-checkpoint"
5151
]
@@ -73,7 +73,7 @@
7373
],
7474
"workload_name": "x86-print-this-15000-with-simpoints",
7575
"example_usage": "get_resource(resource_name=\"x86-print-this-1500-simpoints\")",
76-
"workloads": [
76+
"workloads_mapping": [
7777
"x86-print-this-15000-with-simpoints",
7878
"x86-print-this-15000-with-simpoints-and-checkpoint"
7979
]

__tests__/pages/resources/[id]/[[...page]].test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ describe("Resource-specific component", () => {
155155
gem5_versions: ['23.0'],
156156
workload_name: 'x86-print-this-15000-with-simpoints',
157157
example_usage: 'get_resource(resource_name="x86-print-this-1500-simpoints")',
158-
workloads: [],
158+
workloads_mapping: [],
159159
database: 'db1'
160160
}))
161161
}))

components/resourceMetadata.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ export default function MetaData({ resource, className, metaFields, showMetadata
137137
: null
138138
}
139139
{
140-
(resource.workloads && resource.workloads.length > 0) ?
140+
(resource.workloads_mapping && resource.workloads_mapping.length > 0) ?
141141
<Row className="border-bottom">
142142
<p className="text-muted main-text-regular">Depend on this resource</p>
143143
<div className="main-text-regular">
144144
{
145-
resource.workloads.map((workload, index) => {
145+
resource.workloads_mapping.map((workload, index) => {
146146
return (
147147
<span key={workload}>
148148
<a
149149
href={process.env.BASE_PATH + '/resources/' + workload + `?database=${resource.database}`}
150150
>
151151
{workload}
152152
</a>
153-
{index != resource.workloads.length - 1 ? ', ' : ''}
153+
{index != resource.workloads_mapping.length - 1 ? ', ' : ''}
154154
</span>
155155
)
156156
})

components/resourceTab.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import rehypeHighlight from "rehype-highlight";
1616
import rehypeSlug from "rehype-slug";
1717
import rehypeRaw from "rehype-raw";
1818
import remarkFrontmatter from "remark-frontmatter";
19+
import CopyIcon from "./copyIcon";
1920

2021
export function createTab(tab) {
2122
if (!"content" in tab) return null;
@@ -30,13 +31,15 @@ export function createTab(tab) {
3031
content = String(tab.content);
3132
break;
3233
case "array":
33-
content = tab.content.map((item, index) => {
34-
return (
35-
<div key={index}>
36-
{item}
37-
</div>
38-
);
39-
});
34+
content = (
35+
<CopyIcon>
36+
<pre>
37+
<code class="hljs language-python">
38+
{JSON.stringify(tab.content, null, 4)}
39+
</code>
40+
</pre>
41+
</CopyIcon>
42+
);
4043
break;
4144
case "object":
4245
content = Object.keys(tab.content).map((key, index) => {
@@ -131,15 +134,15 @@ export default function ResourceTab({ resource, requiredTabs, additionalInfoTabs
131134
>
132135
<Tab eventKey="readme" title="Readme">
133136
<ReactMarkdown
134-
className="markdown-body mt-3"
135-
rehypePlugins={[
136-
[rehypeHighlight, { ignoreMissing: true }],
137-
rehypeRaw,
138-
rehypeSlug,
139-
]}
140-
remarkPlugins={[remarkGfm, remarkToc, remarkFrontmatter]}
141-
>
142-
{resource.description ?? 'This is a description of the resource.'}
137+
className="markdown-body mt-3"
138+
rehypePlugins={[
139+
[rehypeHighlight, { ignoreMissing: true }],
140+
rehypeRaw,
141+
rehypeSlug,
142+
]}
143+
remarkPlugins={[remarkGfm, remarkToc, remarkFrontmatter]}
144+
>
145+
{resource.description ?? 'This is a description of the resource.'}
143146
</ReactMarkdown>
144147
</Tab>
145148
<Tab eventKey="changelog" title="Changelog">

components/tabs/rawTab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function RawTab({ resource }) {
2626
resource = JSON.parse(JSON.stringify(resource));
2727
delete resource.database
2828
delete resource._id
29-
delete resource.workloads
29+
delete resource.workloads_mapping
3030
textToHtml(JSON.stringify(resource, null, 4));
3131
}, [resource]);
3232
return (

gem5.config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@
110110
}
111111
},
112112
"metadata": {}
113+
},
114+
"suite": {
115+
"tab": {
116+
"workloads": {
117+
"displayName": "Workloads"
118+
}
119+
},
120+
"additionalInfo": {},
121+
"metadata": {}
113122
}
114123
}
115124
}

pages/api/json/getResourceByID.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default async function getResourceByIDJSON(id, database, version) {
4949
if (!resource) {
5050
return { error: 'Resource not found' }
5151
}
52-
resource.workloads = workloads;
52+
resource.workloads_mapping = workloads;
5353
resource.database = database;
5454
return resource;
5555
}

pages/api/mongodb/getResourceByID.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function getResourceByID(token, url, dataSource, database, collection, id,
8686
})
8787
}).catch(err => console.log(err));
8888
let workloads = await dependendWorkloads.json();
89-
resource.workloads = Object.values(workloads['documents']).map(workload => workload['_id']);
89+
resource.workloads_mapping = Object.values(workloads['documents']).map(workload => workload['_id']);
9090

9191
return resource;
9292
}

0 commit comments

Comments
 (0)