Skip to content

SOF-7915: refactor espresso regex schemas#4

Open
pranabdas wants to merge 47 commits into
mainfrom
feat/SOF-7915
Open

SOF-7915: refactor espresso regex schemas#4
pranabdas wants to merge 47 commits into
mainfrom
feat/SOF-7915

Conversation

@pranabdas

Copy link
Copy Markdown
Member

No description provided.

@@ -0,0 +1,89 @@
_fingerprints:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should keep the version

Comment thread src/js/functions.ts
fs.writeFileSync(path.resolve(filePath), JSON.stringify(schema) + "\n", "utf8");
}

export function interpolatePrimitives(schema: any, primitives: Record<string, string>): any {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can have this in utils

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As these are used only build time, and not exported as runtime utility, we keep them here for now.

Comment thread data/schemas.json Outdated
@@ -1 +1 @@
{"applications":{"espresso":{"5.2.1":{"pw.x":{"_fingerprints":[{"regex":"^&control","flags":["g","i"],"isRequired":true},{"regex":"^&electrons","flags":["g","i"],"isRequired":true}],"control":{"_format":{"namelist":{"regex":"(\\$|&){{BLOCK_NAME}}\\n(?:\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+)(?:\\n\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+))*)?\\s*\\/","flags":["g","m"],"params":{"BLOCK_NAME":["CONTROL","ELECTRONS","IONS","CELL","SYSTEM"]}}},"calculation":{"regex":"calculation\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"title":{"regex":"title\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"restart_mode":{"regex":"restart_mode\\s*=\\s*'([^']+)'","flags":["g","m","i"]}}}},"7.1":{"pw.x":{"_fingerprints":[{"regex":"^&control","flags":["g","i"],"isRequired":true},{"regex":"^&electrons","flags":["g","i"],"isRequired":true}],"control":{"_format":{"namelist":{"regex":"(\\$|&){{BLOCK_NAME}}\\n(?:\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+)(?:\\n\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+))*)?\\s*\\/","flags":["g","m"],"params":{"BLOCK_NAME":["CONTROL","ELECTRONS","IONS","CELL","SYSTEM"]}}},"calculation":{"regex":"...","flags":["g","m","i"]}}}}}}}
{"applications":{"espresso":{"5.2.1":{"pw.x":{"_fingerprints":[{"regex":"^&control","flags":["g","i"],"isRequired":true},{"regex":"^&electrons","flags":["g","i"],"isRequired":true}],"control":{"_format":{"namelist":{"regex":"(\\$|&)(CONTROL|ELECTRONS|IONS|CELL|SYSTEM)\\n(?:\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+)(?:\\n\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+))*)?\\s*\\/","flags":["g","m"],"params":{"BLOCK_NAME":["CONTROL","ELECTRONS","IONS","CELL","SYSTEM"]}}},"calculation":{"regex":"calculation\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"title":{"regex":"title\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"restart_mode":{"regex":"restart_mode\\s*=\\s*'([^']+)'","flags":["g","m","i"]}},"kv_pair":{"regex":"(\\w+)\\s*=\\s*([^,\\n/=]+)","flags":["g","i","m"]},"kv_pair_with_index":{"regex":"(\\w+)\\s*\\(\\s*(\\d+)\\s*\\)\\s*=\\s*([^,\\n/]+)","flags":["g","i","m"]},"namelist_block":{"regex":"&(CONTROL|SYSTEM|ELECTRONS|IONS|CELL|FCP|RISM)\\s*([\\s\\S]*?)\\/","flags":["i","m"],"params":{"BLOCK_NAME":["CONTROL","SYSTEM","ELECTRONS","IONS","CELL","FCP","RISM"]}},"cell_parameters_card":{"regex":"CELL_PARAMETERS\\s*[{(]?\\s*(alat|bohr|angstrom)?\\s*[)}]?\\s*\\n((?:[ \\t]*[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]*\\n?){3})","flags":["i"],"params":{"UNIT":["alat","bohr","angstrom"]}},"atomic_positions_card":{"regex":"ATOMIC_POSITIONS\\s*[{(]?\\s*(alat|bohr|angstrom|crystal|crystal_sg)?\\s*[)}]?\\s*\\n((?:[ \\t]*\\w+(?:[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?){3}(?:(?:[ \\t]+[01]){3})?[ \\t]*\\n?)+)","flags":["i"],"params":{"UNIT":["alat","bohr","angstrom","crystal","crystal_sg"]}}}},"7.1":{"pw.x":{"_fingerprints":[{"regex":"^&control","flags":["g","i"],"isRequired":true},{"regex":"^&electrons","flags":["g","i"],"isRequired":true}],"control":{"_format":{"namelist":{"regex":"(\\$|&)(CONTROL|ELECTRONS|IONS|CELL|SYSTEM)\\n(?:\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+)(?:\\n\\s+[A-Za-z_]+\\s*=\\s*(?:['\"].*?['\"]|[^\\/\\n]+))*)?\\s*\\/","flags":["g","m"],"params":{"BLOCK_NAME":["CONTROL","ELECTRONS","IONS","CELL","SYSTEM"]}}},"calculation":{"regex":"calculation\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"title":{"regex":"title\\s*=\\s*'([^']+)'","flags":["g","m","i"]},"restart_mode":{"regex":"restart_mode\\s*=\\s*'([^']+)'","flags":["g","m","i"]}},"kv_pair":{"regex":"(\\w+)\\s*=\\s*([^,\\n/=]+)","flags":["g","i","m"]},"kv_pair_with_index":{"regex":"(\\w+)\\s*\\(\\s*(\\d+)\\s*\\)\\s*=\\s*([^,\\n/]+)","flags":["g","i","m"]},"namelist_block":{"regex":"&(CONTROL|SYSTEM|ELECTRONS|IONS|CELL|FCP|RISM)\\s*([\\s\\S]*?)\\/","flags":["i","m"],"params":{"BLOCK_NAME":["CONTROL","SYSTEM","ELECTRONS","IONS","CELL","FCP","RISM"]}},"cell_parameters_card":{"regex":"CELL_PARAMETERS\\s*[{(]?\\s*(alat|bohr|angstrom)?\\s*[)}]?\\s*\\n((?:[ \\t]*[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?[ \\t]*\\n?){3})","flags":["i"],"params":{"UNIT":["alat","bohr","angstrom"]}},"atomic_positions_card":{"regex":"ATOMIC_POSITIONS\\s*[{(]?\\s*(alat|bohr|angstrom|crystal|crystal_sg)?\\s*[)}]?\\s*\\n((?:[ \\t]*\\w+(?:[ \\t]+[-+]?(?:\\d+\\.\\d*|\\.\\d+|\\d+)(?:[eEdD][-+]?\\d+)?){3}(?:(?:[ \\t]+[01]){3})?[ \\t]*\\n?)+)","flags":["i"],"params":{"UNIT":["alat","bohr","angstrom","crystal","crystal_sg"]}}}}}}}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe this should be further nested under /applications/espresso/5.2.1/pw.x/stdin.

# regex keys above cannot match these because '(' follows the name instead of '='.
kv_pair_with_index:
regex: '(\w+)\s*\(\s*(\d+)\s*\)\s*=\s*([^,\n/]+)'
flags: ["g", "i", "m"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This and the above seem too generic to be included here

- IONS
- CELL
- FCP
- RISM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

- "CELL"
- "SYSTEM"
regex: !listToString
- '(\$|&){{BLOCK_NAME}}\s*\n'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

$CONTROL is likely a legacy convention. Do we need to support it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants