Skip to content

Commit 1f3bb4d

Browse files
committed
Merge branch 'parse-submissions'
2 parents e1c81c1 + 58edee5 commit 1f3bb4d

File tree

2 files changed

+46
-43
lines changed

2 files changed

+46
-43
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const inputJsonString = process.argv[2];
2+
const data = JSON.parse(inputJsonString);
3+
4+
if (data.circuit) {
5+
data.circuit = data.circuit[0];
6+
}
7+
8+
if (data.hamiltonian) {
9+
data.hamiltonian = data.hamiltonian[0];
10+
}
11+
12+
delete data.methodProof;
13+
14+
const numericFields = [
15+
'runtimeQuantum',
16+
'runtimeClassical',
17+
'observableValue',
18+
'errorBoundLow',
19+
'errorBoundHigh',
20+
'energy',
21+
'qubits',
22+
'gates',
23+
];
24+
25+
for (const key of numericFields) {
26+
if (!(key in data)) continue;
27+
28+
const originalValue = data[key];
29+
const parsedNumber = Number(originalValue);
30+
if (isNaN(parsedNumber)) {
31+
delete data[key];
32+
} else {
33+
data[key] = originalValue.toLowerCase().includes('e')
34+
? 'EXPONENTIAL_MARKER_' + parsedNumber.toExponential()
35+
: parsedNumber;
36+
}
37+
}
38+
39+
const output = JSON.stringify({
40+
createdAt: process.env.ISSUE_CREATED_AT,
41+
url: process.env.ISSUE_URL,
42+
...data,
43+
}).replace(/"EXPONENTIAL_MARKER_(.*?)"/g, '$1');
44+
45+
console.log(output);

.github/workflows/verify-issue.yml

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -72,49 +72,7 @@ jobs:
7272
ISSUE_CREATED_AT: ${{ github.event.issue.created_at }}
7373
ISSUE_URL: ${{ github.event.issue.html_url }}
7474
run: |
75-
SUBMISSION=$(node -e "
76-
const data = JSON.parse(process.env.INPUT_JSON);
77-
78-
if (data.circuit) {
79-
data.circuit = data.circuit[0];
80-
}
81-
82-
if (data.hamiltonian) {
83-
data.hamiltonian = data.hamiltonian[0];
84-
}
85-
86-
delete data.methodProof;
87-
88-
const numericFields = [
89-
'runtimeQuantum',
90-
'runtimeClassical',
91-
'observableValue',
92-
'errorBoundLow',
93-
'errorBoundHigh',
94-
'energy',
95-
'qubits',
96-
'gates',
97-
];
98-
99-
for (const key of numericFields) {
100-
if (!(key in data)) continue;
101-
102-
const parsedNumber = Number(data[key]);
103-
if (isNaN(parsedNumber)) {
104-
delete data[key];
105-
} else {
106-
data[key] = parsedNumber;
107-
}
108-
}
109-
110-
const output = {
111-
createdAt: process.env.ISSUE_CREATED_AT,
112-
url: process.env.ISSUE_URL,
113-
...data,
114-
};
115-
116-
console.log(JSON.stringify(output));
117-
")
75+
SUBMISSION=$(node .github/workflows/parse-submission.js "$INPUT_JSON")
11876
echo "submission=$SUBMISSION" >> $GITHUB_OUTPUT
11977
12078
- name: Modify submissions file

0 commit comments

Comments
 (0)