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

Draft of SQLAlchemy-based EntryCollection #1656

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jun 4, 2023

Based on the initial work by @jensj at https://gitlab.com/jensj/ase-optimade, this PR introduces a SQLAlchemy-based backend for the reference server. This collection is intended to be used "from scratch", by e.g., ingesting OPTIMADE data into a new set of tables, rather than attaching to an existing database of a given format. It has no corresponding filter transformer class as filtering requires access to the table metadata, so as such, it is bundled as part of the collection.

Still very WIP and currently only handles structure data (not links etc).

Co-authored-by: Jens Jørgen Mortensen <[email protected]>
@ml-evs ml-evs added enhancement New feature or request server Issues pertaining to the example server implementation labels Jun 4, 2023
@codecov
Copy link

codecov bot commented Jun 4, 2023

Codecov Report

Merging #1656 (445d714) into master (03ab81e) will decrease coverage by 3.94%.
The diff coverage is 0.95%.

@@            Coverage Diff             @@
##           master    #1656      +/-   ##
==========================================
- Coverage   91.04%   87.11%   -3.94%     
==========================================
  Files          74       75       +1     
  Lines        4580     4787     +207     
==========================================
  Hits         4170     4170              
- Misses        410      617     +207     
Flag Coverage Δ
project 87.11% <0.95%> (-3.94%) ⬇️
validator 87.00% <0.95%> (-3.94%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/server/entry_collections/sqlalchemy.py 0.00% <0.00%> (ø)
optimade/server/config.py 93.75% <100.00%> (+0.13%) ⬆️

... and 1 file with indirect coverage changes

@ml-evs ml-evs self-assigned this Jun 9, 2023
@blokhin
Copy link
Member

blokhin commented Jun 19, 2024

Isn't this a filter transformer?

def parse_lark_tree(node: Tree | Token) -> Any:
"""Convert Lark tree to simple data structure.
See examples in ``parser_test.py``.
"""
if isinstance(node, Token):
if node.type == "SIGNED_INT":
return int(node.value)
if node.type == "SIGNED_FLOAT":
return float(node.value)
if node.type == "ESCAPED_STRING":
return node.value[1:-1]
return (node.type, node.value)
children = [parse_lark_tree(child) for child in node.children] # type: ignore
if len(children) == 1:
return children[0]
if node.data == "expression":
return ("OR", children)
if node.data == "expression_clause":
return ("AND", children)
return children

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server Issues pertaining to the example server implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants