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

Preflight client callback to allow queries to be customised per provider #2188

Open
ml-evs opened this issue Nov 19, 2024 · 1 comment
Open
Labels
client Issues/PRs relating to the OPTIMADE client. suggestions

Comments

@ml-evs
Copy link
Member

ml-evs commented Nov 19, 2024

cc @mehmetgiritli & @alex-belozerov

It would be nice to have a mechanism to adjust filters before sending them when using custom fields. As an example, when querying a structures endpoint for custom fields e.g. band_gap, we would like to be able to control how that field gets mapped depending on the database being queried. In the simplest case, if someone asks to filter band_gap, then each database-specific prefix can be added so that COD recieves a query for _cod_band_gap, MP receives _mp_band_gap and so on. This avoids the user needing to construct some contorted query for _cod_band_gap > 0 OR _mp_band_gap > 0 for an indeterminate number of prefixes.

This could be straightforwardly implemented by parsing the filter and checking whether fields exist within the standard, then simply prefixing them if not.

In the more general case, it would also be very helpful to perform arbitrary mapping of field names programmatically, which could e.g., map bandgap to _cod_band_gap (note the field name is not the same), and potentially even map input values to reflect differing unit definitions. This could either be via some kind of local mapping or just by allowing general preflight callbacks that can define arbitrary logic (similar to the response callbacks we allow now).

I'm not sure if this is exactly we had in mind in discussions, so please do give your thoughts! This would be a very useful feature, so I'd be happy to help, but if you want it sooner rather than later it might be wise if someone took the lead on developing it.

@ml-evs ml-evs added suggestions client Issues/PRs relating to the OPTIMADE client. labels Nov 19, 2024
@alex-belozerov
Copy link
Member

Thank you Matthew for putting this into words. From my perspective, you have conveyed exactly what we discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Issues/PRs relating to the OPTIMADE client. suggestions
Projects
None yet
Development

No branches or pull requests

2 participants