File tree Expand file tree Collapse file tree 2 files changed +46
-43
lines changed
Expand file tree Collapse file tree 2 files changed +46
-43
lines changed Original file line number Diff line number Diff line change 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 ( / " E X P O N E N T I A L _ M A R K E R _ ( .* ?) " / g, '$1' ) ;
44+
45+ console . log ( output ) ;
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments