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

Update database API #394

Open
lukasturcani opened this issue Sep 1, 2021 · 1 comment
Open

Update database API #394

lukasturcani opened this issue Sep 1, 2021 · 1 comment

Comments

@lukasturcani
Copy link
Owner

lukasturcani commented Sep 1, 2021

the database API needs to support fetch of multiple molecules and values in one go, to minimize database reads and writes

# get mulitple molecules in one database read
molecules = db.get(
    keys=(
        {"inchi": "one"}, 
        {"inchi": "two"},
    ),
)
# put multiple molecules in one database write
db.put(
    molecules=( 
        stk.BuildingBlock(...),
        stk.BuildingBlock(...),
    ),
)
# get multple values
values = value_db.get(
    molecules=(
        stk.BuildingBlock(...), 
        stk.BuildingBlock(...),
    ),
)
# put multiple values
value_db.put(
     (stk.BuildingBlock(...), {"prop1": 1, "prop2": 21}),
     (stk.BuildingBlock(...), {"prop1": 2}),
)
# not sure how to deal with the current API of 
value_db.put(
    stk.BuildingBLock(...), 
    1,
)
# I might continue to support it, or I could depcrate it in favour of 
value_db.put((stk.BuildingBlock(...), 1))

ofc the single instance approach will still work, as it does in the stk api normally, however, the result will always be
returned as an iterable

molecule, = db.get({"smiles": "CC"})

However, in order to not break users, initially, if you do

result = db.get({"smiles": "CC"})

you will get a warning, that your return value will turn into an iterable in a future release, to remove the warning you should explicilty set change to

molecule, = db.get(
    keys=(
        {"smiles": "CC"}, 
    )
)

So

molecule, = db.get({"smiles": "CC"})

will always work, just the return type will change.

@lukasturcani
Copy link
Owner Author

I think this issue needs to keep an eye on #395

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

No branches or pull requests

1 participant